diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index bc61d005..e4477f5f 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -29,20 +29,6 @@ const SSMethods = { BLAKE3_CHACHA20_POLY1305: '2022-blake3-chacha20-poly1305', }; -const RULE_IP = { - PRIVATE: 'geoip:private', - CN: 'geoip:cn', -}; - -const RULE_DOMAIN = { - ADS: 'geosite:category-ads', - ADS_ALL: 'geosite:category-ads-all', - CN: 'geosite:cn', - GOOGLE: 'geosite:google', - FACEBOOK: 'geosite:facebook', - SPEEDTEST: 'geosite:speedtest', -}; - const TLS_FLOW_CONTROL = { VISION: "xtls-rprx-vision", VISION_UDP443: "xtls-rprx-vision-udp443", @@ -97,8 +83,6 @@ const ALPN_OPTION = { Object.freeze(Protocols); Object.freeze(VmessMethods); Object.freeze(SSMethods); -Object.freeze(RULE_IP); -Object.freeze(RULE_DOMAIN); Object.freeze(TLS_FLOW_CONTROL); Object.freeze(TLS_VERSION_OPTION); Object.freeze(TLS_CIPHER_OPTION); @@ -451,18 +435,20 @@ class QuicStreamSettings extends XrayCommonClass { } class GrpcStreamSettings extends XrayCommonClass { - constructor(serviceName="") { + constructor(serviceName="", multiMode=false) { super(); this.serviceName = serviceName; + this.multiMode = multiMode; } static fromJson(json={}) { - return new GrpcStreamSettings(json.serviceName); + return new GrpcStreamSettings(json.serviceName, json.multiMode); } toJson() { return { serviceName: this.serviceName, + multiMode: this.multiMode, } } } @@ -1106,50 +1092,6 @@ class Inbound extends XrayCommonClass { if (this.protocol !== Protocols.VMESS) { return ''; } - let network = this.stream.network; - let type = 'none'; - let host = ''; - let path = ''; - if (network === 'tcp') { - let tcp = this.stream.tcp; - type = tcp.type; - if (type === 'http') { - let request = tcp.request; - path = request.path.join(','); - let index = request.headers.findIndex(header => header.name.toLowerCase() === 'host'); - if (index >= 0) { - host = request.headers[index].value; - } - } - } else if (network === 'kcp') { - let kcp = this.stream.kcp; - type = kcp.type; - path = kcp.seed; - } else if (network === 'ws') { - let ws = this.stream.ws; - path = ws.path; - let index = ws.headers.findIndex(header => header.name.toLowerCase() === 'host'); - if (index >= 0) { - host = ws.headers[index].value; - } - } else if (network === 'http') { - network = 'h2'; - path = this.stream.http.path; - host = this.stream.http.host.join(','); - } else if (network === 'quic') { - type = this.stream.quic.type; - host = this.stream.quic.security; - path = this.stream.quic.key; - } else if (network === 'grpc') { - path = this.stream.grpc.serviceName; - } - - if (this.stream.security === 'tls') { - if (!ObjectUtil.isEmpty(this.stream.tls.server)) { - address = this.stream.tls.server; - } - } - let obj = { v: '2', ps: remark, @@ -1157,16 +1099,66 @@ class Inbound extends XrayCommonClass { port: this.port, id: this.settings.vmesses[clientIndex].id, aid: this.settings.vmesses[clientIndex].alterId, - net: network, - type: type, - host: host, - path: path, + net: this.stream.network, + type: 'none', tls: this.stream.security, - sni: this.stream.tls.settings.serverName, - fp: this.stream.tls.settings.fingerprint, - alpn: this.stream.tls.alpn.join(','), - allowInsecure: this.stream.tls.settings.allowInsecure, }; + let network = this.stream.network; + if (network === 'tcp') { + let tcp = this.stream.tcp; + obj.type = tcp.type; + if (tcp.type === 'http') { + let request = tcp.request; + obj.path = request.path.join(','); + let index = request.headers.findIndex(header => header.name.toLowerCase() === 'host'); + if (index >= 0) { + obj.host = request.headers[index].value; + } + } + } else if (network === 'kcp') { + let kcp = this.stream.kcp; + obj.type = kcp.type; + obj.path = kcp.seed; + } else if (network === 'ws') { + let ws = this.stream.ws; + obj.path = ws.path; + let index = ws.headers.findIndex(header => header.name.toLowerCase() === 'host'); + if (index >= 0) { + obj.host = ws.headers[index].value; + } + } else if (network === 'http') { + obj.net = 'h2'; + obj.path = this.stream.http.path; + obj.host = this.stream.http.host.join(','); + } else if (network === 'quic') { + obj.type = this.stream.quic.type; + obj.host = this.stream.quic.security; + obj.path = this.stream.quic.key; + } else if (network === 'grpc') { + obj.path = this.stream.grpc.serviceName; + if (this.stream.grpc.multiMode){ + obj.type = 'multi' + } + } + + if (this.stream.security === 'tls') { + if (!ObjectUtil.isEmpty(this.stream.tls.server)) { + obj.add = this.stream.tls.server; + } + if (!ObjectUtil.isEmpty(this.stream.tls.settings.serverName)){ + obj.sni = this.stream.tls.settings.serverName; + } + if (!ObjectUtil.isEmpty(this.stream.tls.settings.fingerprint)){ + obj.fp = this.stream.tls.settings.fingerprint; + } + if (this.stream.tls.alpn.length>0){ + obj.alpn = this.stream.tls.alpn.join(','); + } + if (this.stream.tls.settings.allowInsecure){ + obj.allowInsecure = this.stream.tls.settings.allowInsecure; + } + } + return 'vmess://' + base64(JSON.stringify(obj, null, 2)); } @@ -1219,6 +1211,9 @@ class Inbound extends XrayCommonClass { case "grpc": const grpc = this.stream.grpc; params.set("serviceName", grpc.serviceName); + if(grpc.multiMode){ + params.set("mode", "multi"); + } break; } @@ -1332,6 +1327,9 @@ class Inbound extends XrayCommonClass { case "grpc": const grpc = this.stream.grpc; params.set("serviceName", grpc.serviceName); + if(grpc.multiMode){ + params.set("mode", "multi"); + } break; } diff --git a/web/html/xui/form/stream/stream_grpc.html b/web/html/xui/form/stream/stream_grpc.html index 15041a51..0e24ce83 100644 --- a/web/html/xui/form/stream/stream_grpc.html +++ b/web/html/xui/form/stream/stream_grpc.html @@ -9,6 +9,14 @@ +