diff options
| author | mhsanaei <ho3ein.sanaei@gmail.com> | 2025-09-16 14:41:05 +0300 |
|---|---|---|
| committer | mhsanaei <ho3ein.sanaei@gmail.com> | 2025-09-16 14:41:05 +0300 |
| commit | 1de7accd7cfea4aa834fbcf80ff05e0f072971b4 (patch) | |
| tree | cbf359d4737c2dd8ad06d05f60ad295597cc7be4 /web | |
| parent | 76afff2a6f5bcc2fad72955f15a216d0eebacacd (diff) | |
vnext removed
Diffstat (limited to 'web')
| -rw-r--r-- | web/assets/js/model/outbound.js | 68 | ||||
| -rw-r--r-- | web/html/form/outbound.html | 2 | ||||
| -rw-r--r-- | web/html/xray.html | 4 | ||||
| -rw-r--r-- | web/web.go | 19 |
4 files changed, 47 insertions, 46 deletions
diff --git a/web/assets/js/model/outbound.js b/web/assets/js/model/outbound.js index 2d5660fb..3e481dff 100644 --- a/web/assets/js/model/outbound.js +++ b/web/assets/js/model/outbound.js @@ -219,7 +219,7 @@ class KcpStreamSettings extends CommonClass { class WsStreamSettings extends CommonClass { constructor( - path = '/', + path = '/', host = '', heartbeatPeriod = 0, @@ -647,10 +647,6 @@ class Outbound extends CommonClass { ].includes(this.protocol); } - hasVnext() { - return [Protocols.VMess, Protocols.VLESS].includes(this.protocol); - } - hasServers() { return [Protocols.Trojan, Protocols.Shadowsocks, Protocols.Socks, Protocols.HTTP].includes(this.protocol); } @@ -690,13 +686,22 @@ class Outbound extends CommonClass { if (this.stream?.sockopt) stream = { sockopt: this.stream.sockopt.toJson() }; } + // For VMess/VLESS, emit settings as a flat object + let settingsOut = this.settings instanceof CommonClass ? this.settings.toJson() : this.settings; + // Remove undefined/null keys + if (settingsOut && typeof settingsOut === 'object') { + Object.keys(settingsOut).forEach(k => { + if (settingsOut[k] === undefined || settingsOut[k] === null) delete settingsOut[k]; + }); + } return { - tag: this.tag == '' ? undefined : this.tag, protocol: this.protocol, - settings: this.settings instanceof CommonClass ? this.settings.toJson() : this.settings, - streamSettings: stream, - sendThrough: this.sendThrough != "" ? this.sendThrough : undefined, - mux: this.mux?.enabled ? this.mux : undefined, + settings: settingsOut, + // Only include tag, streamSettings, sendThrough, mux if present and not empty + ...(this.tag ? { tag: this.tag } : {}), + ...(stream ? { streamSettings: stream } : {}), + ...(this.sendThrough ? { sendThrough: this.sendThrough } : {}), + ...(this.mux?.enabled ? { mux: this.mux } : {}), }; } @@ -908,7 +913,7 @@ Outbound.FreedomSettings = class extends CommonClass { toJson() { return { domainStrategy: ObjectUtil.isEmpty(this.domainStrategy) ? undefined : this.domainStrategy, - redirect: ObjectUtil.isEmpty(this.redirect) ? undefined: this.redirect, + redirect: ObjectUtil.isEmpty(this.redirect) ? undefined : this.redirect, fragment: Object.keys(this.fragment).length === 0 ? undefined : this.fragment, noises: this.noises.length === 0 ? undefined : Outbound.FreedomSettings.Noise.toJsonArray(this.noises), }; @@ -1026,22 +1031,21 @@ Outbound.VmessSettings = class extends CommonClass { } static fromJson(json = {}) { - if (ObjectUtil.isArrEmpty(json.vnext)) return new Outbound.VmessSettings(); + if (ObjectUtil.isEmpty(json.address) || ObjectUtil.isEmpty(json.port)) return new Outbound.VmessSettings(); return new Outbound.VmessSettings( - json.vnext[0].address, - json.vnext[0].port, - json.vnext[0].users[0].id, - json.vnext[0].users[0].security, + json.address, + json.port, + json.id, + json.security, ); } toJson() { return { - vnext: [{ - address: this.address, - port: this.port, - users: [{ id: this.id, security: this.security }], - }], + address: this.address, + port: this.port, + id: this.id, + security: this.security, }; } }; @@ -1056,23 +1060,23 @@ Outbound.VLESSSettings = class extends CommonClass { } static fromJson(json = {}) { - if (ObjectUtil.isArrEmpty(json.vnext)) return new Outbound.VLESSSettings(); + if (ObjectUtil.isEmpty(json.address) || ObjectUtil.isEmpty(json.port)) return new Outbound.VLESSSettings(); return new Outbound.VLESSSettings( - json.vnext[0].address, - json.vnext[0].port, - json.vnext[0].users[0].id, - json.vnext[0].users[0].flow, - json.vnext[0].users[0].encryption, + json.address, + json.port, + json.id, + json.flow, + json.encryption ); } toJson() { return { - vnext: [{ - address: this.address, - port: this.port, - users: [{ id: this.id, flow: this.flow, encryption: this.encryption }], - }], + address: this.address, + port: this.port, + id: this.id, + flow: this.flow, + encryption: this.encryption, }; } }; diff --git a/web/html/form/outbound.html b/web/html/form/outbound.html index d2149b6d..aa6aa323 100644 --- a/web/html/form/outbound.html +++ b/web/html/form/outbound.html @@ -210,7 +210,7 @@ </a-form-item> </template> - <!-- Vnext (vless/vmess) settings --> + <!-- VLESS/VMess user settings --> <template v-if="[Protocols.VMess, Protocols.VLESS].includes(outbound.protocol)"> <a-form-item label='ID'> <a-input v-model.trim="outbound.settings.id"></a-input> diff --git a/web/html/xray.html b/web/html/xray.html index 9f528e03..258c81c9 100644 --- a/web/html/xray.html +++ b/web/html/xray.html @@ -535,7 +535,9 @@ switch (o.protocol) { case Protocols.VMess: case Protocols.VLESS: - serverObj = o.settings.vnext; + if (o.settings && o.settings.address && o.settings.port) { + return [o.settings.address + ':' + o.settings.port]; + } break; case Protocols.HTTP: case Protocols.Mixed: @@ -289,18 +289,13 @@ func (s *Server) startTask() { // check client ips from log file every day s.cron.AddJob("@daily", job.NewClearLogsJob()) - // Periodic traffic resets - logger.Info("Scheduling periodic traffic reset jobs") - { - // Inbound traffic reset jobs - // Run once a day, midnight - s.cron.AddJob("@daily", job.NewPeriodicTrafficResetJob("daily")) - // Run once a week, midnight between Sat/Sun - s.cron.AddJob("@weekly", job.NewPeriodicTrafficResetJob("weekly")) - // Run once a month, midnight, first of month - s.cron.AddJob("@monthly", job.NewPeriodicTrafficResetJob("monthly")) - - } + // Inbound traffic reset jobs + // Run once a day, midnight + s.cron.AddJob("@daily", job.NewPeriodicTrafficResetJob("daily")) + // Run once a week, midnight between Sat/Sun + s.cron.AddJob("@weekly", job.NewPeriodicTrafficResetJob("weekly")) + // Run once a month, midnight, first of month + s.cron.AddJob("@monthly", job.NewPeriodicTrafficResetJob("monthly")) // Make a traffic condition every day, 8:30 var entry cron.EntryID |
