UNPKG

@localzet/xtls-sdk

Version:

TypeScript SDK for XRAY/AURA Core

843 lines (842 loc) 29.6 kB
"use strict"; // Code generated by protoc-gen-ts_proto. DO NOT EDIT. // versions: // protoc-gen-ts_proto v2.2.7 // protoc v5.28.3 // source: app/stats/command/command.proto Object.defineProperty(exports, "__esModule", { value: true }); exports.StatsServiceDefinition = exports.Config = exports.GetStatsOnlineIpListResponse_IpsEntry = exports.GetStatsOnlineIpListResponse = exports.SysStatsResponse = exports.SysStatsRequest = exports.QueryStatsResponse = exports.QueryStatsRequest = exports.GetStatsResponse = exports.Stat = exports.GetStatsRequest = exports.protobufPackage = void 0; /* eslint-disable */ const wire_1 = require("@bufbuild/protobuf/wire"); const typeRegistry_1 = require("../../../typeRegistry"); exports.protobufPackage = 'xray.app.stats.command'; function createBaseGetStatsRequest() { return { $type: 'xray.app.stats.command.GetStatsRequest', name: '', reset: false }; } exports.GetStatsRequest = { $type: 'xray.app.stats.command.GetStatsRequest', encode(message, writer = new wire_1.BinaryWriter()) { if (message.name !== '') { writer.uint32(10).string(message.name); } if (message.reset !== false) { writer.uint32(16).bool(message.reset); } return writer; }, decode(input, length) { const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGetStatsRequest(); 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.reset = reader.bool(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { $type: exports.GetStatsRequest.$type, name: isSet(object.name) ? globalThis.String(object.name) : '', reset: isSet(object.reset) ? globalThis.Boolean(object.reset) : false, }; }, toJSON(message) { const obj = {}; if (message.name !== '') { obj.name = message.name; } if (message.reset !== false) { obj.reset = message.reset; } return obj; }, create(base) { return exports.GetStatsRequest.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseGetStatsRequest(); message.name = object.name ?? ''; message.reset = object.reset ?? false; return message; }, }; typeRegistry_1.messageTypeRegistry.set(exports.GetStatsRequest.$type, exports.GetStatsRequest); function createBaseStat() { return { $type: 'xray.app.stats.command.Stat', name: '', value: 0 }; } exports.Stat = { $type: 'xray.app.stats.command.Stat', encode(message, writer = new wire_1.BinaryWriter()) { if (message.name !== '') { writer.uint32(10).string(message.name); } if (message.value !== 0) { writer.uint32(16).int64(message.value); } return writer; }, decode(input, length) { const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseStat(); 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.value = longToNumber(reader.int64()); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { $type: exports.Stat.$type, name: isSet(object.name) ? globalThis.String(object.name) : '', value: isSet(object.value) ? globalThis.Number(object.value) : 0, }; }, toJSON(message) { const obj = {}; if (message.name !== '') { obj.name = message.name; } if (message.value !== 0) { obj.value = Math.round(message.value); } return obj; }, create(base) { return exports.Stat.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseStat(); message.name = object.name ?? ''; message.value = object.value ?? 0; return message; }, }; typeRegistry_1.messageTypeRegistry.set(exports.Stat.$type, exports.Stat); function createBaseGetStatsResponse() { return { $type: 'xray.app.stats.command.GetStatsResponse', stat: undefined }; } exports.GetStatsResponse = { $type: 'xray.app.stats.command.GetStatsResponse', encode(message, writer = new wire_1.BinaryWriter()) { if (message.stat !== undefined) { exports.Stat.encode(message.stat, writer.uint32(10).fork()).join(); } return writer; }, decode(input, length) { const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGetStatsResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.stat = exports.Stat.decode(reader, reader.uint32()); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { $type: exports.GetStatsResponse.$type, stat: isSet(object.stat) ? exports.Stat.fromJSON(object.stat) : undefined }; }, toJSON(message) { const obj = {}; if (message.stat !== undefined) { obj.stat = exports.Stat.toJSON(message.stat); } return obj; }, create(base) { return exports.GetStatsResponse.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseGetStatsResponse(); message.stat = (object.stat !== undefined && object.stat !== null) ? exports.Stat.fromPartial(object.stat) : undefined; return message; }, }; typeRegistry_1.messageTypeRegistry.set(exports.GetStatsResponse.$type, exports.GetStatsResponse); function createBaseQueryStatsRequest() { return { $type: 'xray.app.stats.command.QueryStatsRequest', pattern: '', reset: false }; } exports.QueryStatsRequest = { $type: 'xray.app.stats.command.QueryStatsRequest', encode(message, writer = new wire_1.BinaryWriter()) { if (message.pattern !== '') { writer.uint32(10).string(message.pattern); } if (message.reset !== false) { writer.uint32(16).bool(message.reset); } return writer; }, decode(input, length) { const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryStatsRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.pattern = reader.string(); continue; } case 2: { if (tag !== 16) { break; } message.reset = reader.bool(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { $type: exports.QueryStatsRequest.$type, pattern: isSet(object.pattern) ? globalThis.String(object.pattern) : '', reset: isSet(object.reset) ? globalThis.Boolean(object.reset) : false, }; }, toJSON(message) { const obj = {}; if (message.pattern !== '') { obj.pattern = message.pattern; } if (message.reset !== false) { obj.reset = message.reset; } return obj; }, create(base) { return exports.QueryStatsRequest.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseQueryStatsRequest(); message.pattern = object.pattern ?? ''; message.reset = object.reset ?? false; return message; }, }; typeRegistry_1.messageTypeRegistry.set(exports.QueryStatsRequest.$type, exports.QueryStatsRequest); function createBaseQueryStatsResponse() { return { $type: 'xray.app.stats.command.QueryStatsResponse', stat: [] }; } exports.QueryStatsResponse = { $type: 'xray.app.stats.command.QueryStatsResponse', encode(message, writer = new wire_1.BinaryWriter()) { for (const v of message.stat) { exports.Stat.encode(v, writer.uint32(10).fork()).join(); } return writer; }, decode(input, length) { const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseQueryStatsResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.stat.push(exports.Stat.decode(reader, reader.uint32())); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { $type: exports.QueryStatsResponse.$type, stat: globalThis.Array.isArray(object?.stat) ? object.stat.map((e) => exports.Stat.fromJSON(e)) : [], }; }, toJSON(message) { const obj = {}; if (message.stat?.length) { obj.stat = message.stat.map((e) => exports.Stat.toJSON(e)); } return obj; }, create(base) { return exports.QueryStatsResponse.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseQueryStatsResponse(); message.stat = object.stat?.map((e) => exports.Stat.fromPartial(e)) || []; return message; }, }; typeRegistry_1.messageTypeRegistry.set(exports.QueryStatsResponse.$type, exports.QueryStatsResponse); function createBaseSysStatsRequest() { return { $type: 'xray.app.stats.command.SysStatsRequest' }; } exports.SysStatsRequest = { $type: 'xray.app.stats.command.SysStatsRequest', encode(_, writer = new wire_1.BinaryWriter()) { return writer; }, decode(input, length) { const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSysStatsRequest(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(_) { return { $type: exports.SysStatsRequest.$type }; }, toJSON(_) { const obj = {}; return obj; }, create(base) { return exports.SysStatsRequest.fromPartial(base ?? {}); }, fromPartial(_) { const message = createBaseSysStatsRequest(); return message; }, }; typeRegistry_1.messageTypeRegistry.set(exports.SysStatsRequest.$type, exports.SysStatsRequest); function createBaseSysStatsResponse() { return { $type: 'xray.app.stats.command.SysStatsResponse', NumGoroutine: 0, NumGC: 0, Alloc: 0, TotalAlloc: 0, Sys: 0, Mallocs: 0, Frees: 0, LiveObjects: 0, PauseTotalNs: 0, Uptime: 0, }; } exports.SysStatsResponse = { $type: 'xray.app.stats.command.SysStatsResponse', encode(message, writer = new wire_1.BinaryWriter()) { if (message.NumGoroutine !== 0) { writer.uint32(8).uint32(message.NumGoroutine); } if (message.NumGC !== 0) { writer.uint32(16).uint32(message.NumGC); } if (message.Alloc !== 0) { writer.uint32(24).uint64(message.Alloc); } if (message.TotalAlloc !== 0) { writer.uint32(32).uint64(message.TotalAlloc); } if (message.Sys !== 0) { writer.uint32(40).uint64(message.Sys); } if (message.Mallocs !== 0) { writer.uint32(48).uint64(message.Mallocs); } if (message.Frees !== 0) { writer.uint32(56).uint64(message.Frees); } if (message.LiveObjects !== 0) { writer.uint32(64).uint64(message.LiveObjects); } if (message.PauseTotalNs !== 0) { writer.uint32(72).uint64(message.PauseTotalNs); } if (message.Uptime !== 0) { writer.uint32(80).uint32(message.Uptime); } return writer; }, decode(input, length) { const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseSysStatsResponse(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 8) { break; } message.NumGoroutine = reader.uint32(); continue; } case 2: { if (tag !== 16) { break; } message.NumGC = reader.uint32(); continue; } case 3: { if (tag !== 24) { break; } message.Alloc = longToNumber(reader.uint64()); continue; } case 4: { if (tag !== 32) { break; } message.TotalAlloc = longToNumber(reader.uint64()); continue; } case 5: { if (tag !== 40) { break; } message.Sys = longToNumber(reader.uint64()); continue; } case 6: { if (tag !== 48) { break; } message.Mallocs = longToNumber(reader.uint64()); continue; } case 7: { if (tag !== 56) { break; } message.Frees = longToNumber(reader.uint64()); continue; } case 8: { if (tag !== 64) { break; } message.LiveObjects = longToNumber(reader.uint64()); continue; } case 9: { if (tag !== 72) { break; } message.PauseTotalNs = longToNumber(reader.uint64()); continue; } case 10: { if (tag !== 80) { break; } message.Uptime = reader.uint32(); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { $type: exports.SysStatsResponse.$type, NumGoroutine: isSet(object.NumGoroutine) ? globalThis.Number(object.NumGoroutine) : 0, NumGC: isSet(object.NumGC) ? globalThis.Number(object.NumGC) : 0, Alloc: isSet(object.Alloc) ? globalThis.Number(object.Alloc) : 0, TotalAlloc: isSet(object.TotalAlloc) ? globalThis.Number(object.TotalAlloc) : 0, Sys: isSet(object.Sys) ? globalThis.Number(object.Sys) : 0, Mallocs: isSet(object.Mallocs) ? globalThis.Number(object.Mallocs) : 0, Frees: isSet(object.Frees) ? globalThis.Number(object.Frees) : 0, LiveObjects: isSet(object.LiveObjects) ? globalThis.Number(object.LiveObjects) : 0, PauseTotalNs: isSet(object.PauseTotalNs) ? globalThis.Number(object.PauseTotalNs) : 0, Uptime: isSet(object.Uptime) ? globalThis.Number(object.Uptime) : 0, }; }, toJSON(message) { const obj = {}; if (message.NumGoroutine !== 0) { obj.NumGoroutine = Math.round(message.NumGoroutine); } if (message.NumGC !== 0) { obj.NumGC = Math.round(message.NumGC); } if (message.Alloc !== 0) { obj.Alloc = Math.round(message.Alloc); } if (message.TotalAlloc !== 0) { obj.TotalAlloc = Math.round(message.TotalAlloc); } if (message.Sys !== 0) { obj.Sys = Math.round(message.Sys); } if (message.Mallocs !== 0) { obj.Mallocs = Math.round(message.Mallocs); } if (message.Frees !== 0) { obj.Frees = Math.round(message.Frees); } if (message.LiveObjects !== 0) { obj.LiveObjects = Math.round(message.LiveObjects); } if (message.PauseTotalNs !== 0) { obj.PauseTotalNs = Math.round(message.PauseTotalNs); } if (message.Uptime !== 0) { obj.Uptime = Math.round(message.Uptime); } return obj; }, create(base) { return exports.SysStatsResponse.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseSysStatsResponse(); message.NumGoroutine = object.NumGoroutine ?? 0; message.NumGC = object.NumGC ?? 0; message.Alloc = object.Alloc ?? 0; message.TotalAlloc = object.TotalAlloc ?? 0; message.Sys = object.Sys ?? 0; message.Mallocs = object.Mallocs ?? 0; message.Frees = object.Frees ?? 0; message.LiveObjects = object.LiveObjects ?? 0; message.PauseTotalNs = object.PauseTotalNs ?? 0; message.Uptime = object.Uptime ?? 0; return message; }, }; typeRegistry_1.messageTypeRegistry.set(exports.SysStatsResponse.$type, exports.SysStatsResponse); function createBaseGetStatsOnlineIpListResponse() { return { $type: 'xray.app.stats.command.GetStatsOnlineIpListResponse', name: '', ips: {} }; } exports.GetStatsOnlineIpListResponse = { $type: 'xray.app.stats.command.GetStatsOnlineIpListResponse', encode(message, writer = new wire_1.BinaryWriter()) { if (message.name !== '') { writer.uint32(10).string(message.name); } Object.entries(message.ips).forEach(([key, value]) => { exports.GetStatsOnlineIpListResponse_IpsEntry.encode({ $type: 'xray.app.stats.command.GetStatsOnlineIpListResponse.IpsEntry', key: key, value, }, writer.uint32(18).fork()).join(); }); return writer; }, decode(input, length) { const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGetStatsOnlineIpListResponse(); 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 !== 18) { break; } const entry2 = exports.GetStatsOnlineIpListResponse_IpsEntry.decode(reader, reader.uint32()); if (entry2.value !== undefined) { message.ips[entry2.key] = entry2.value; } continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { $type: exports.GetStatsOnlineIpListResponse.$type, name: isSet(object.name) ? globalThis.String(object.name) : '', ips: isObject(object.ips) ? Object.entries(object.ips).reduce((acc, [key, value]) => { acc[key] = Number(value); return acc; }, {}) : {}, }; }, toJSON(message) { const obj = {}; if (message.name !== '') { obj.name = message.name; } if (message.ips) { const entries = Object.entries(message.ips); if (entries.length > 0) { obj.ips = {}; entries.forEach(([k, v]) => { obj.ips[k] = Math.round(v); }); } } return obj; }, create(base) { return exports.GetStatsOnlineIpListResponse.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseGetStatsOnlineIpListResponse(); message.name = object.name ?? ''; message.ips = Object.entries(object.ips ?? {}).reduce((acc, [key, value]) => { if (value !== undefined) { acc[key] = globalThis.Number(value); } return acc; }, {}); return message; }, }; typeRegistry_1.messageTypeRegistry.set(exports.GetStatsOnlineIpListResponse.$type, exports.GetStatsOnlineIpListResponse); function createBaseGetStatsOnlineIpListResponse_IpsEntry() { return { $type: 'xray.app.stats.command.GetStatsOnlineIpListResponse.IpsEntry', key: '', value: 0 }; } exports.GetStatsOnlineIpListResponse_IpsEntry = { $type: 'xray.app.stats.command.GetStatsOnlineIpListResponse.IpsEntry', encode(message, writer = new wire_1.BinaryWriter()) { if (message.key !== '') { writer.uint32(10).string(message.key); } if (message.value !== 0) { writer.uint32(16).int64(message.value); } return writer; }, decode(input, length) { const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseGetStatsOnlineIpListResponse_IpsEntry(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: { if (tag !== 10) { break; } message.key = reader.string(); continue; } case 2: { if (tag !== 16) { break; } message.value = longToNumber(reader.int64()); continue; } } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(object) { return { $type: exports.GetStatsOnlineIpListResponse_IpsEntry.$type, key: isSet(object.key) ? globalThis.String(object.key) : '', value: isSet(object.value) ? globalThis.Number(object.value) : 0, }; }, toJSON(message) { const obj = {}; if (message.key !== '') { obj.key = message.key; } if (message.value !== 0) { obj.value = Math.round(message.value); } return obj; }, create(base) { return exports.GetStatsOnlineIpListResponse_IpsEntry.fromPartial(base ?? {}); }, fromPartial(object) { const message = createBaseGetStatsOnlineIpListResponse_IpsEntry(); message.key = object.key ?? ''; message.value = object.value ?? 0; return message; }, }; typeRegistry_1.messageTypeRegistry.set(exports.GetStatsOnlineIpListResponse_IpsEntry.$type, exports.GetStatsOnlineIpListResponse_IpsEntry); function createBaseConfig() { return { $type: 'xray.app.stats.command.Config' }; } exports.Config = { $type: 'xray.app.stats.command.Config', encode(_, writer = new wire_1.BinaryWriter()) { return writer; }, decode(input, length) { const reader = input instanceof wire_1.BinaryReader ? input : new wire_1.BinaryReader(input); let end = length === undefined ? reader.len : reader.pos + length; const message = createBaseConfig(); while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { } if ((tag & 7) === 4 || tag === 0) { break; } reader.skip(tag & 7); } return message; }, fromJSON(_) { return { $type: exports.Config.$type }; }, toJSON(_) { const obj = {}; return obj; }, create(base) { return exports.Config.fromPartial(base ?? {}); }, fromPartial(_) { const message = createBaseConfig(); return message; }, }; typeRegistry_1.messageTypeRegistry.set(exports.Config.$type, exports.Config); exports.StatsServiceDefinition = { name: 'StatsService', fullName: 'xray.app.stats.command.StatsService', methods: { getStats: { name: 'GetStats', requestType: exports.GetStatsRequest, requestStream: false, responseType: exports.GetStatsResponse, responseStream: false, options: {}, }, getStatsOnline: { name: 'GetStatsOnline', requestType: exports.GetStatsRequest, requestStream: false, responseType: exports.GetStatsResponse, responseStream: false, options: {}, }, queryStats: { name: 'QueryStats', requestType: exports.QueryStatsRequest, requestStream: false, responseType: exports.QueryStatsResponse, responseStream: false, options: {}, }, getSysStats: { name: 'GetSysStats', requestType: exports.SysStatsRequest, requestStream: false, responseType: exports.SysStatsResponse, responseStream: false, options: {}, }, getStatsOnlineIpList: { name: 'GetStatsOnlineIpList', requestType: exports.GetStatsRequest, requestStream: false, responseType: exports.GetStatsOnlineIpListResponse, responseStream: false, options: {}, }, }, }; function longToNumber(int64) { const num = globalThis.Number(int64.toString()); if (num > globalThis.Number.MAX_SAFE_INTEGER) { throw new globalThis.Error('Value is larger than Number.MAX_SAFE_INTEGER'); } if (num < globalThis.Number.MIN_SAFE_INTEGER) { throw new globalThis.Error('Value is smaller than Number.MIN_SAFE_INTEGER'); } return num; } function isObject(value) { return typeof value === 'object' && value !== null; } function isSet(value) { return value !== null && value !== undefined; }