diff --git a/go.mod b/go.mod index 2b74b7af..ae6ea7d7 100644 --- a/go.mod +++ b/go.mod @@ -18,8 +18,8 @@ require ( go.uber.org/atomic v1.11.0 golang.org/x/text v0.9.0 google.golang.org/grpc v1.55.0 - gorm.io/driver/sqlite v1.5.1 - gorm.io/gorm v1.25.1 + gorm.io/driver/sqlite v1.5.2 + gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55 ) require ( diff --git a/go.sum b/go.sum index 8af92e75..9adea1cb 100644 --- a/go.sum +++ b/go.sum @@ -272,10 +272,10 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20200605160147-a5ece683394c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gorm.io/driver/sqlite v1.5.1 h1:hYyrLkAWE71bcarJDPdZNTLWtr8XrSjOWyjUYI6xdL4= -gorm.io/driver/sqlite v1.5.1/go.mod h1:7MZZ2Z8bqyfSQA1gYEV6MagQWj3cpUkJj9Z+d1HEMEQ= -gorm.io/gorm v1.25.1 h1:nsSALe5Pr+cM3V1qwwQ7rOkw+6UeLrX5O4v3llhHa64= -gorm.io/gorm v1.25.1/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= +gorm.io/driver/sqlite v1.5.2 h1:TpQ+/dqCY4uCigCFyrfnrJnrW9zjpelWVoEVNy5qJkc= +gorm.io/driver/sqlite v1.5.2/go.mod h1:qxAuCol+2r6PannQDpOP1FP6ag3mKi4esLnB/jHed+4= +gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55 h1:sC1Xj4TYrLqg1n3AN10w871An7wJM0gzgcm8jkIkECQ= +gorm.io/gorm v1.25.2-0.20230530020048-26663ab9bf55/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k= gvisor.dev/gvisor v0.0.0-20220901235040-6ca97ef2ce1c h1:m5lcgWnL3OElQNVyp3qcncItJ2c0sQlSGjYK2+nJTA4= lukechampine.com/blake3 v1.1.7 h1:GgRMhmdsuK8+ii6UZFDL8Nb+VyMwadAgcJyfYHxG6n0= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index 33cd10d5..0e737bb0 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -4,7 +4,6 @@ const Protocols = { TROJAN: 'trojan', SHADOWSOCKS: 'shadowsocks', DOKODEMO: 'dokodemo-door', - MTPROTO: 'mtproto', SOCKS: 'socks', HTTP: 'http', }; @@ -379,10 +378,15 @@ class WsStreamSettings extends XrayCommonClass { } class HttpStreamSettings extends XrayCommonClass { - constructor(path='/', host=['']) { + constructor( + path='/', + host=[''], + sockopt={acceptProxyProtocol: false} + ) { super(); this.path = path; this.host = host.length === 0 ? [''] : host; + this.sockopt = sockopt; } addHost(host) { @@ -394,7 +398,7 @@ class HttpStreamSettings extends XrayCommonClass { } static fromJson(json={}) { - return new HttpStreamSettings(json.path, json.host); + return new HttpStreamSettings(json.path, json.host, json.sockopt); } toJson() { @@ -407,10 +411,12 @@ class HttpStreamSettings extends XrayCommonClass { return { path: this.path, host: host, + sockopt: this.sockopt, } } } + class QuicStreamSettings extends XrayCommonClass { constructor(security=VmessMethods.NONE, key='', type='none') { @@ -442,33 +448,39 @@ class QuicStreamSettings extends XrayCommonClass { class GrpcStreamSettings extends XrayCommonClass { constructor( serviceName="", - multiMode=false + multiMode=false, + sockopt={acceptProxyProtocol: false} ) { super(); this.serviceName = serviceName; this.multiMode = multiMode; + this.sockopt = sockopt; } static fromJson(json={}) { return new GrpcStreamSettings( json.serviceName, - json.multiMode + json.multiMode, + json.sockopt ); } toJson() { return { serviceName: this.serviceName, - multiMode: this.multiMode + multiMode: this.multiMode, + sockopt: this.sockopt } } } + class TlsStreamSettings extends XrayCommonClass { constructor(serverName='', minVersion = TLS_VERSION_OPTION.TLS12, maxVersion = TLS_VERSION_OPTION.TLS13, cipherSuites = '', + rejectUnknownSni = false, certificates=[new TlsStreamSettings.Cert()], alpn=[ALPN_OPTION.H2,ALPN_OPTION.HTTP1], settings=new TlsStreamSettings.Settings()) { @@ -477,6 +489,7 @@ class TlsStreamSettings extends XrayCommonClass { this.minVersion = minVersion; this.maxVersion = maxVersion; this.cipherSuites = cipherSuites; + this.rejectUnknownSni = rejectUnknownSni; this.certs = certificates; this.alpn = alpn; this.settings = settings; @@ -504,6 +517,7 @@ class TlsStreamSettings extends XrayCommonClass { json.minVersion, json.maxVersion, json.cipherSuites, + json.rejectUnknownSni, certs, json.alpn, settings, @@ -516,6 +530,7 @@ class TlsStreamSettings extends XrayCommonClass { minVersion: this.minVersion, maxVersion: this.maxVersion, cipherSuites: this.cipherSuites, + rejectUnknownSni: this.rejectUnknownSni, certificates: TlsStreamSettings.toJsonArray(this.certs), alpn: this.alpn, settings: this.settings, @@ -708,7 +723,7 @@ class RealityStreamSettings extends XrayCommonClass { minClient = '', maxClient = '', maxTimediff = 0, - shortIds = RandomUtil.randomShortId(8), + shortIds = RandomUtil.randomShortId(), settings= new RealityStreamSettings.Settings() ){ super(); @@ -1586,7 +1601,6 @@ Inbound.Settings = class extends XrayCommonClass { case Protocols.TROJAN: return new Inbound.TrojanSettings(protocol); case Protocols.SHADOWSOCKS: return new Inbound.ShadowsocksSettings(protocol); case Protocols.DOKODEMO: return new Inbound.DokodemoSettings(protocol); - case Protocols.MTPROTO: return new Inbound.MtprotoSettings(protocol); case Protocols.SOCKS: return new Inbound.SocksSettings(protocol); case Protocols.HTTP: return new Inbound.HttpSettings(protocol); default: return null; @@ -1600,7 +1614,6 @@ Inbound.Settings = class extends XrayCommonClass { case Protocols.TROJAN: return Inbound.TrojanSettings.fromJson(json); case Protocols.SHADOWSOCKS: return Inbound.ShadowsocksSettings.fromJson(json); case Protocols.DOKODEMO: return Inbound.DokodemoSettings.fromJson(json); - case Protocols.MTPROTO: return Inbound.MtprotoSettings.fromJson(json); case Protocols.SOCKS: return Inbound.SocksSettings.fromJson(json); case Protocols.HTTP: return Inbound.HttpSettings.fromJson(json); default: return null; @@ -1655,7 +1668,7 @@ Inbound.VmessSettings = class extends Inbound.Settings { } }; Inbound.VmessSettings.Vmess = class extends XrayCommonClass { - constructor(id=RandomUtil.randomUUID(), alterId=0, email=RandomUtil.randomText(8),limitIp=0, totalGB=0, expiryTime=0, enable=true, tgId='', subId=RandomUtil.randomText(16)) { + constructor(id=RandomUtil.randomUUID(), alterId=0, email=RandomUtil.randomLowerAndNum(8),limitIp=0, totalGB=0, expiryTime=0, enable=true, tgId='', subId=RandomUtil.randomLowerAndNum(16)) { super(); this.id = id; this.alterId = alterId; @@ -1747,7 +1760,7 @@ Inbound.VLESSSettings = class extends Inbound.Settings { }; Inbound.VLESSSettings.VLESS = class extends XrayCommonClass { - constructor(id=RandomUtil.randomUUID(), flow='', email=RandomUtil.randomText(8),limitIp=0, totalGB=0, expiryTime=0, enable=true, tgId='', subId=RandomUtil.randomText(16)) { + constructor(id=RandomUtil.randomUUID(), flow='', email=RandomUtil.randomLowerAndNum(8),limitIp=0, totalGB=0, expiryTime=0, enable=true, tgId='', subId=RandomUtil.randomLowerAndNum(16)) { super(); this.id = id; this.flow = flow; @@ -1870,7 +1883,7 @@ Inbound.TrojanSettings = class extends Inbound.Settings { } }; Inbound.TrojanSettings.Trojan = class extends XrayCommonClass { - constructor(password=RandomUtil.randomSeq(10), flow='', email=RandomUtil.randomText(8),limitIp=0, totalGB=0, expiryTime=0, enable=true, tgId='', subId=RandomUtil.randomText(16)) { + constructor(password=RandomUtil.randomSeq(10), flow='', email=RandomUtil.randomLowerAndNum(8),limitIp=0, totalGB=0, expiryTime=0, enable=true, tgId='', subId=RandomUtil.randomLowerAndNum(16)) { super(); this.password = password; this.flow = flow; @@ -2012,7 +2025,7 @@ Inbound.ShadowsocksSettings = class extends Inbound.Settings { }; Inbound.ShadowsocksSettings.Shadowsocks = class extends XrayCommonClass { - constructor(password=RandomUtil.randomShadowsocksPassword(), email=RandomUtil.randomText(8),limitIp=0, totalGB=0, expiryTime=0, enable=true, tgId='', subId=RandomUtil.randomText(16)) { + constructor(password=RandomUtil.randomShadowsocksPassword(), email=RandomUtil.randomLowerAndNum(8),limitIp=0, totalGB=0, expiryTime=0, enable=true, tgId='', subId=RandomUtil.randomLowerAndNum(16)) { super(); this.password = password; this.email = email; @@ -2106,36 +2119,6 @@ Inbound.DokodemoSettings = class extends Inbound.Settings { } }; -Inbound.MtprotoSettings = class extends Inbound.Settings { - constructor(protocol, users=[new Inbound.MtprotoSettings.MtUser()]) { - super(protocol); - this.users = users; - } - - static fromJson(json={}) { - return new Inbound.MtprotoSettings( - Protocols.MTPROTO, - json.users.map(user => Inbound.MtprotoSettings.MtUser.fromJson(user)), - ); - } - - toJson() { - return { - users: XrayCommonClass.toJsonArray(this.users), - }; - } -}; -Inbound.MtprotoSettings.MtUser = class extends XrayCommonClass { - constructor(secret=RandomUtil.randomMTSecret()) { - super(); - this.secret = secret; - } - - static fromJson(json={}) { - return new Inbound.MtprotoSettings.MtUser(json.secret); - } -}; - Inbound.SocksSettings = class extends Inbound.Settings { constructor(protocol, auth='password', accounts=[new Inbound.SocksSettings.SocksAccount()], udp=false, ip='127.0.0.1') { super(protocol); diff --git a/web/assets/js/util/utils.js b/web/assets/js/util/utils.js index 5644df2e..781e13a8 100644 --- a/web/assets/js/util/utils.js +++ b/web/assets/js/util/utils.js @@ -94,43 +94,32 @@ class RandomUtil { return str; } - static randomShortId(count) { + static randomShortId() { let str = ''; - for (let i = 0; i < count; ++i) { + for (let i = 0; i < 8; ++i) { str += seq[this.randomInt(16)]; } return str; } - static randomText(len) { + static randomLowerAndNum(len) { let str = ''; - for (let i = 0; i < len; i++) { + for (let i = 0; i < len; ++i) { str += seq[this.randomInt(36)]; } return str; } - static randomMTSecret() { - let str = ''; - for (let i = 0; i < 32; ++i) { - let index = this.randomInt(16); - if (index <= 9) { - str += index; - } else { - str += seq[index - 10]; - } - } - return str; - } - static randomUUID() { - let d = new Date().getTime(); - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { - let r = (d + Math.random() * 16) % 16 | 0; - d = Math.floor(d / 16); - return (c === 'x' ? r : (r & 0x7 | 0x8)).toString(16); + const template = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'; + return template.replace(/[xy]/g, function (c) { + const randomValues = new Uint8Array(1); + crypto.getRandomValues(randomValues); + let randomValue = randomValues[0] % 16; + let calculatedValue = (c === 'x') ? randomValue : (randomValue & 0x3 | 0x8); + return calculatedValue.toString(16); }); - } + } static randomShadowsocksPassword() { let array = new Uint8Array(32); diff --git a/web/html/xui/form/client.html b/web/html/xui/form/client.html index cfac5cff..bd6b08af 100644 --- a/web/html/xui/form/client.html +++ b/web/html/xui/form/client.html @@ -18,7 +18,7 @@ - + @@ -44,7 +44,7 @@ - + diff --git a/web/html/xui/form/protocol/shadowsocks.html b/web/html/xui/form/protocol/shadowsocks.html index e4eaf155..e9b01ea5 100644 --- a/web/html/xui/form/protocol/shadowsocks.html +++ b/web/html/xui/form/protocol/shadowsocks.html @@ -11,7 +11,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -112,6 +112,7 @@ + diff --git a/web/html/xui/form/protocol/trojan.html b/web/html/xui/form/protocol/trojan.html index cf56f438..f494adb9 100644 --- a/web/html/xui/form/protocol/trojan.html +++ b/web/html/xui/form/protocol/trojan.html @@ -11,7 +11,7 @@ - + @@ -28,7 +28,7 @@ - + diff --git a/web/html/xui/form/protocol/vless.html b/web/html/xui/form/protocol/vless.html index 59ba7672..f661a839 100644 --- a/web/html/xui/form/protocol/vless.html +++ b/web/html/xui/form/protocol/vless.html @@ -11,7 +11,7 @@ - + @@ -28,7 +28,7 @@ - + diff --git a/web/html/xui/form/protocol/vmess.html b/web/html/xui/form/protocol/vmess.html index de6e5250..6dd31307 100644 --- a/web/html/xui/form/protocol/vmess.html +++ b/web/html/xui/form/protocol/vmess.html @@ -11,7 +11,7 @@ - +
@@ -33,7 +33,7 @@ - + diff --git a/web/html/xui/form/stream/stream_grpc.html b/web/html/xui/form/stream/stream_grpc.html index 21c95f99..f34a3457 100644 --- a/web/html/xui/form/stream/stream_grpc.html +++ b/web/html/xui/form/stream/stream_grpc.html @@ -1,5 +1,9 @@ {{define "form/streamGRPC"}} + + + +
diff --git a/web/html/xui/form/stream/stream_http.html b/web/html/xui/form/stream/stream_http.html index 57574ce5..17bd3759 100644 --- a/web/html/xui/form/stream/stream_http.html +++ b/web/html/xui/form/stream/stream_http.html @@ -1,5 +1,9 @@ {{define "form/streamHTTP"}} + + + +
diff --git a/web/html/xui/form/stream/stream_ws.html b/web/html/xui/form/stream/stream_ws.html index ec9d3755..25d1299c 100644 --- a/web/html/xui/form/stream/stream_ws.html +++ b/web/html/xui/form/stream/stream_ws.html @@ -3,8 +3,7 @@ -
- +
diff --git a/web/html/xui/form/tls_settings.html b/web/html/xui/form/tls_settings.html index d0692e13..227c5466 100644 --- a/web/html/xui/form/tls_settings.html +++ b/web/html/xui/form/tls_settings.html @@ -35,7 +35,6 @@ - @@ -85,9 +84,14 @@ [[ value ]] +
+
+ + +