UNPKG

@remnawave/xtls-sdk

Version:

A Typescript SDK for XRAY (XTLS) Core GRPC Api

183 lines (182 loc) 6.62 kB
"use strict"; // Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v2.11.2 // protoc v6.33.4 // source: proxy/tun/config.proto Object.defineProperty(exports, "__esModule", { value: true }); exports.Config = exports.protobufPackage = void 0; /* eslint-disable */ const wire_1 = require("@bufbuild/protobuf/wire"); const typeRegistry_1 = require("../../typeRegistry"); exports.protobufPackage = "xray.proxy.tun"; function createBaseConfig() { return { $type: "xray.proxy.tun.Config", name: "", MTU: 0, gateway: [], DNS: [], userLevel: 0, autoSystemRoutingTable: [], autoOutboundsInterface: "", }; } exports.Config = { $type: "xray.proxy.tun.Config", encode(message, writer = new wire_1.BinaryWriter()) { if (message.name !== "") { writer.uint32(10).string(message.name); } if (message.MTU !== 0) { writer.uint32(16).uint32(message.MTU); } for (const v of message.gateway) { writer.uint32(26).string(v); } for (const v of message.DNS) { writer.uint32(34).string(v); } if (message.userLevel !== 0) { writer.uint32(40).uint32(message.userLevel); } for (const v of message.autoSystemRoutingTable) { writer.uint32(50).string(v); } if (message.autoOutboundsInterface !== "") { writer.uint32(58).string(message.autoOutboundsInterface); } return writer; }, decode(input, length) { const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input); const end = length === undefined ? reader.len : reader.pos + length; const message = createBaseConfig(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.name = reader.string(); continue; } case 2: { if (tag !== 16) { break; } message.MTU = reader.uint32(); continue; } case 3: { if (tag !== 26) { break; } message.gateway.push(reader.string()); continue; } case 4: { if (tag !== 34) { break; } message.DNS.push(reader.string()); continue; } case 5: { if (tag !== 40) { break; } message.userLevel = reader.uint32(); continue; } case 6: { if (tag !== 50) { break; } message.autoSystemRoutingTable.push(reader.string()); continue; } case 7: { if (tag !== 58) { break; } message.autoOutboundsInterface = reader.string(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { $type: exports.Config.$type, name: isSet(object.name) ? globalThis.String(object.name) : "", MTU: isSet(object.MTU) ? globalThis.Number(object.MTU) : 0, gateway: globalThis.Array.isArray(object?.gateway) ? object.gateway.map((e) => globalThis.String(e)) : [], DNS: globalThis.Array.isArray(object?.DNS) ? object.DNS.map((e) => globalThis.String(e)) : [], userLevel: isSet(object.userLevel) ? globalThis.Number(object.userLevel) : isSet(object.user_level) ? globalThis.Number(object.user_level) : 0, autoSystemRoutingTable: globalThis.Array.isArray(object?.autoSystemRoutingTable) ? object.autoSystemRoutingTable.map((e) => globalThis.String(e)) : globalThis.Array.isArray(object?.auto_system_routing_table) ? object.auto_system_routing_table.map((e) => globalThis.String(e)) : [], autoOutboundsInterface: isSet(object.autoOutboundsInterface) ? globalThis.String(object.autoOutboundsInterface) : isSet(object.auto_outbounds_interface) ? globalThis.String(object.auto_outbounds_interface) : "", }; }, toJSON(message) { const obj = {}; if (message.name !== "") { obj.name = message.name; } if (message.MTU !== 0) { obj.MTU = Math.round(message.MTU); } if (message.gateway?.length) { obj.gateway = message.gateway; } if (message.DNS?.length) { obj.DNS = message.DNS; } if (message.userLevel !== 0) { obj.userLevel = Math.round(message.userLevel); } if (message.autoSystemRoutingTable?.length) { obj.autoSystemRoutingTable = message.autoSystemRoutingTable; } if (message.autoOutboundsInterface !== "") { obj.autoOutboundsInterface = message.autoOutboundsInterface; } return obj; }, create(base) { return exports.Config.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseConfig(); message.name = object.name ?? ""; message.MTU = object.MTU ?? 0; message.gateway = object.gateway?.map((e) => e) || []; message.DNS = object.DNS?.map((e) => e) || []; message.userLevel = object.userLevel ?? 0; message.autoSystemRoutingTable = object.autoSystemRoutingTable?.map((e) => e) || []; message.autoOutboundsInterface = object.autoOutboundsInterface ?? ""; return message; }, }; typeRegistry_1.messageTypeRegistry.set(exports.Config.$type, exports.Config); function isSet(value) { return value !== null && value !== undefined; }