From e1da43053d23c995bcd6e7267cb20042398cd64f Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Sun, 9 Apr 2023 23:13:18 +0330 Subject: alireza update pack Co-Authored-By: Alireza Ahmadi --- web/assets/css/custom.css | 57 +++++++++- web/assets/js/model/models.js | 4 +- web/assets/js/model/xray.js | 257 +++++++++++++++++++++++------------------- 3 files changed, 198 insertions(+), 120 deletions(-) (limited to 'web/assets') diff --git a/web/assets/css/custom.css b/web/assets/css/custom.css index 038e30a1..229d8500 100644 --- a/web/assets/css/custom.css +++ b/web/assets/css/custom.css @@ -156,6 +156,12 @@ padding:16px; } +.ant-table-expand-icon-th, +.ant-table-row-expand-icon-cell { + width: 30px; + min-width: 30px; +} + .ant-menu-dark, .ant-menu-dark .ant-menu-sub, .ant-layout-header, @@ -174,6 +180,7 @@ .ant-card-dark:hover { border-color: #e8e8e8; + box-shadow: 0 2px 8px rgba(255,255,255,.15); } .ant-card-dark .ant-table-thead th { @@ -216,20 +223,25 @@ .ant-card-dark .ant-table-tbody>tr:hover:not(.ant-table-expanded-row):not(.ant-table-row-selected)>td, .ant-card-dark .ant-select-dropdown-menu-item:hover:not(.ant-select-dropdown-menu-item-disabled), -.ant-card-dark .ant-calendar-date:hover { +.ant-card-dark .ant-calendar-date:hover, +.ant-card-dark .ant-select-dropdown-menu-item-active, +.ant-card-dark li.ant-calendar-time-picker-select-option-selected { background-color: #004488; } -.ant-card-dark tbody .ant-table-expanded-row { +.ant-card-dark tbody .ant-table-expanded-row, +.ant-card-dark .ant-calendar-time-picker-inner { color: hsla(0,0%,100%,.65); background-color: #1a212a; } .ant-card-dark .ant-input, .ant-card-dark .ant-input-number, +.ant-card-dark .ant-input-number-handler-wrap, .ant-card-dark .ant-calendar-input, .ant-card-dark .ant-select-dropdown-menu-item-selected, -.ant-card-dark .ant-select-selection { +.ant-card-dark .ant-select-selection, +.ant-card-dark .ant-calendar-picker-clear { color: hsla(0,0%,100%,.65); background-color: #2e3b52; } @@ -239,6 +251,12 @@ background-color: #161b22; } +.ant-dropdown-menu-dark, +.ant-card-dark .ant-modal-content { + border: 1px solid rgba(255, 255, 255, 0.65); + box-shadow: 0 2px 8px rgba(255,255,255,.15); +} + .ant-card-dark .ant-modal-content, .ant-card-dark .ant-modal-body, .ant-card-dark .ant-modal-header, @@ -280,6 +298,12 @@ border: 1px solid hsla(0,0%,100%,.30); } +.ant-card-dark .ant-tag { + color: hsla(0,0%,100%,.65); + background: rgba(255,255,255,.04); + border-color: #434343; +} + .ant-card-dark .ant-tag-blue { color: #3c9ae8; background: #111d2c; @@ -334,6 +358,29 @@ color: hsla(0,0%,100%,.65); background-color: #073763; border-color: #1890ff; - text-shadow: 0 -1px 0 rgba(0,0,0,.12); - box-shadow: 0 2px 0 rgba(0,0,0,.045); + text-shadow: 0 -1px 0 rgba(255,255,255,.12); + box-shadow: 0 2px 0 rgba(255,255,255,.045); +} +.ant-card-dark .ant-btn-primary:hover { + background-color: #40a9ff; + border-color: #40a9ff; +} + +.ant-dark .ant-popover-content { + border: 1px solid #e8e8e8; + border-radius: 4px; + box-shadow: 0 2px 8px rgba(255,255,255,.15); +} + +.ant-dark .ant-popover-inner { + background: #222a37; +} + +.ant-dark .ant-popover-title, +.ant-dark .ant-popover-inner-content { + color: hsla(0,0%,100%,.65); +} + +.ant-dark .ant-popover-placement-top>.ant-popover-content>.ant-popover-arrow { + border-color: transparent #2e3b52 #2e3b52 transparent; } \ No newline at end of file diff --git a/web/assets/js/model/models.js b/web/assets/js/model/models.js index 485464e4..1de76850 100644 --- a/web/assets/js/model/models.js +++ b/web/assets/js/model/models.js @@ -171,13 +171,13 @@ class AllSetting { this.webCertFile = ""; this.webKeyFile = ""; this.webBasePath = "/"; + this.expireDiff = ""; + this.trafficDiff = ""; this.tgBotEnable = false; this.tgBotToken = ""; this.tgBotChatId = ""; this.tgRunTime = "@daily"; this.tgBotBackup = false; - this.tgExpireDiff = ""; - this.tgTrafficDiff = ""; this.tgCpu = ""; this.xrayTemplateConfig = ""; diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index eb6d07f3..65f4bfd9 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -92,6 +92,7 @@ const UTLS_FINGERPRINT = { }; const ALPN_OPTION = { + H3: "h3", H2: "h2", HTTP1: "http/1.1", }; @@ -166,20 +167,20 @@ class XrayCommonClass { } class TcpStreamSettings extends XrayCommonClass { - constructor( - type = 'none', - acceptProxyProtocol = false, - request = new TcpStreamSettings.TcpRequest(), - response = new TcpStreamSettings.TcpResponse(), - ) { + constructor(acceptProxyProtocol=false, + type='none', + request=new TcpStreamSettings.TcpRequest(), + response=new TcpStreamSettings.TcpResponse(), + ) { super(); + this.acceptProxyProtocol = acceptProxyProtocol; this.type = type; this.request = request; this.response = response; this.acceptProxyProtocol = acceptProxyProtocol; } - static fromJson(json = {}) { + static fromJson(json={}) { let header = json.header; if (!header) { header = {}; @@ -194,6 +195,7 @@ class TcpStreamSettings extends XrayCommonClass { toJson() { return { + acceptProxyProtocol: this.acceptProxyProtocol, header: { type: this.type, request: this.type === 'http' ? this.request.toJson() : undefined, @@ -205,10 +207,10 @@ class TcpStreamSettings extends XrayCommonClass { } TcpStreamSettings.TcpRequest = class extends XrayCommonClass { - constructor(version = '1.1', - method = 'GET', - path = ['/'], - headers = [], + constructor(version='1.1', + method='GET', + path=['/'], + headers=[], ) { super(); this.version = version; @@ -242,7 +244,7 @@ TcpStreamSettings.TcpRequest = class extends XrayCommonClass { this.headers.splice(index, 1); } - static fromJson(json = {}) { + static fromJson(json={}) { return new TcpStreamSettings.TcpRequest( json.version, json.method, @@ -261,10 +263,10 @@ TcpStreamSettings.TcpRequest = class extends XrayCommonClass { }; TcpStreamSettings.TcpResponse = class extends XrayCommonClass { - constructor(version = '1.1', - status = '200', - reason = 'OK', - headers = [], + constructor(version='1.1', + status='200', + reason='OK', + headers=[], ) { super(); this.version = version; @@ -281,7 +283,7 @@ TcpStreamSettings.TcpResponse = class extends XrayCommonClass { this.headers.splice(index, 1); } - static fromJson(json = {}) { + static fromJson(json={}) { return new TcpStreamSettings.TcpResponse( json.version, json.status, @@ -474,9 +476,13 @@ class GrpcStreamSettings extends XrayCommonClass { } class TlsStreamSettings extends XrayCommonClass { - constructor(serverName = '', minVersion = TLS_VERSION_OPTION.TLS10, maxVersion = TLS_VERSION_OPTION.TLS12, - cipherSuites = '', - certificates = [new TlsStreamSettings.Cert()], alpn=[''] ,settings=[new TlsStreamSettings.Settings()]) { + constructor(serverName='', + minVersion = TLS_VERSION_OPTION.TLS12, + maxVersion = TLS_VERSION_OPTION.TLS13, + cipherSuites = '', + certificates=[new TlsStreamSettings.Cert()], + alpn=[], + settings=[new TlsStreamSettings.Settings()]) { super(); this.server = serverName; this.minVersion = minVersion; @@ -484,7 +490,7 @@ class TlsStreamSettings extends XrayCommonClass { this.cipherSuites = cipherSuites; this.certs = certificates; this.alpn = alpn; - this.settings = settings; + this.settings = settings; } addCert(cert) { @@ -497,15 +503,15 @@ class TlsStreamSettings extends XrayCommonClass { static fromJson(json={}) { let certs; - let settings; + let settings; if (!ObjectUtil.isEmpty(json.certificates)) { certs = json.certificates.map(cert => TlsStreamSettings.Cert.fromJson(cert)); } + if (!ObjectUtil.isEmpty(json.settings)) { let values = json.settings[0]; settings = [new TlsStreamSettings.Settings(values.allowInsecure , values.fingerprint, values.serverName)]; } - return new TlsStreamSettings( json.serverName, json.minVersion, @@ -513,7 +519,7 @@ class TlsStreamSettings extends XrayCommonClass { json.cipherSuites, certs, json.alpn, - settings, + settings, ); } @@ -526,7 +532,6 @@ class TlsStreamSettings extends XrayCommonClass { certificates: TlsStreamSettings.toJsonArray(this.certs), alpn: this.alpn, settings: TlsStreamSettings.toJsonArray(this.settings), - }; } } @@ -573,40 +578,39 @@ TlsStreamSettings.Cert = class extends XrayCommonClass { }; TlsStreamSettings.Settings = class extends XrayCommonClass { - constructor(allowInsecure = false, fingerprint = '', serverName = '') { - super(); - this.allowInsecure = allowInsecure; - this.fingerprint = fingerprint; - this.serverName = serverName; - } - static fromJson(json = {}) { - return new TlsStreamSettings.Settings( - json.allowInsecure, - json.fingerprint, - json.servername, - ); - } - toJson() { - return { - allowInsecure: this.allowInsecure, - fingerprint: this.fingerprint, - serverName: this.serverName, - }; - } + constructor(allowInsecure = false, fingerprint = '', serverName = '') { + super(); + this.allowInsecure = allowInsecure; + this.fingerprint = fingerprint; + this.serverName = serverName; + } + static fromJson(json = {}) { + return new TlsStreamSettings.Settings( + json.allowInsecure, + json.fingerprint, + json.servername, + ); + } + toJson() { + return { + allowInsecure: this.allowInsecure, + fingerprint: this.fingerprint, + serverName: this.serverName, + }; + } }; - class StreamSettings extends XrayCommonClass { constructor(network='tcp', - security='none', - tlsSettings=new TlsStreamSettings(), - tcpSettings=new TcpStreamSettings(), - kcpSettings=new KcpStreamSettings(), - wsSettings=new WsStreamSettings(), - httpSettings=new HttpStreamSettings(), - quicSettings=new QuicStreamSettings(), - grpcSettings=new GrpcStreamSettings(), - ) { + security='none', + tlsSettings=new TlsStreamSettings(), + tcpSettings=new TcpStreamSettings(), + kcpSettings=new KcpStreamSettings(), + wsSettings=new WsStreamSettings(), + httpSettings=new HttpStreamSettings(), + quicSettings=new QuicStreamSettings(), + grpcSettings=new GrpcStreamSettings(), + ) { super(); this.network = network; this.security = security; @@ -728,14 +732,15 @@ class Inbound extends XrayCommonClass { get protocol() { return this._protocol; } - + set protocol(protocol) { this._protocol = protocol; this.settings = Inbound.Settings.getSettings(protocol); if (protocol === Protocols.TROJAN) { - this.tls = false; + this.tls = true; } } + get tls() { return this.stream.security === 'tls'; } @@ -918,16 +923,16 @@ class Inbound extends XrayCommonClass { isExpiry(index) { switch (this.protocol) { case Protocols.VMESS: - if(this.settings.vmesses[index]._expiryTime != null) - return this.settings.vmesses[index]._expiryTime < new Date().getTime(); + if(this.settings.vmesses[index].expiryTime > 0) + return this.settings.vmesses[index].expiryTime < new Date().getTime(); return false case Protocols.VLESS: - if(this.settings.vlesses[index]._expiryTime != null) - return this.settings.vlesses[index]._expiryTime < new Date().getTime(); + if(this.settings.vlesses[index].expiryTime > 0) + return this.settings.vlesses[index].expiryTime < new Date().getTime(); return false case Protocols.TROJAN: - if(this.settings.trojans[index]._expiryTime != null) - return this.settings.trojans[index]._expiryTime < new Date().getTime(); + if(this.settings.trojans[index].expiryTime > 0) + return this.settings.trojans[index].expiryTime < new Date().getTime(); return false default: return false; @@ -955,7 +960,7 @@ class Inbound extends XrayCommonClass { return false; } } - + //this is used for xtls-rprx-vision canEnableTlsFlow() { if ((this.stream.security === 'tls') && (this.network === "tcp")) { @@ -968,11 +973,10 @@ class Inbound extends XrayCommonClass { } return false; } - + canSetTls() { return this.canEnableTls(); } - canEnableXTLS() { switch (this.protocol) { @@ -989,7 +993,7 @@ class Inbound extends XrayCommonClass { switch (this.protocol) { case Protocols.VMESS: case Protocols.VLESS: - case Protocols.TROJAN: + case Protocols.TROJAN: return true; default: return false; @@ -1065,7 +1069,7 @@ class Inbound extends XrayCommonClass { address = this.stream.tls.server; } } - + let obj = { v: '2', ps: remark, @@ -1078,7 +1082,7 @@ class Inbound extends XrayCommonClass { host: host, path: path, tls: this.stream.security, - sni: this.stream.tls.settings[0]['serverName'], + sni: this.stream.tls.settings[0]['serverName'], fp: this.stream.tls.settings[0]['fingerprint'], alpn: this.stream.tls.alpn.join(','), allowInsecure: this.stream.tls.settings[0].allowInsecure, @@ -1148,25 +1152,25 @@ class Inbound extends XrayCommonClass { if (!ObjectUtil.isEmpty(this.stream.tls.server)) { address = this.stream.tls.server; } - if (this.stream.tls.settings[0]['serverName'] !== ''){ + if (this.stream.tls.settings[0]['serverName'] !== ''){ params.set("sni", this.stream.tls.settings[0]['serverName']); } if (type === "tcp" && this.settings.vlesses[clientIndex].flow.length > 0) { params.set("flow", this.settings.vlesses[clientIndex].flow); } } - - if (this.XTLS) { + + if (this.XTLS) { params.set("security", "xtls"); params.set("alpn", this.stream.tls.alpn); if(this.stream.tls.settings[0].allowInsecure){ params.set("allowInsecure", "1"); } - if (!ObjectUtil.isEmpty(this.stream.tls.server)) { - address = this.stream.tls.server; - } - params.set("flow", this.settings.vlesses[clientIndex].flow); - } + if (!ObjectUtil.isEmpty(this.stream.tls.server)) { + address = this.stream.tls.server; + } + params.set("flow", this.settings.vlesses[clientIndex].flow); + } const link = `vless://${uuid}@${address}:${port}`; const url = new URL(link); @@ -1177,13 +1181,13 @@ class Inbound extends XrayCommonClass { return url.toString(); } - genSSLink(address = '', remark = '') { + genSSLink(address='', remark='') { let settings = this.settings; const server = this.stream.tls.server; if (!ObjectUtil.isEmpty(server)) { address = server; } - return 'ss://' + safeBase64(settings.method + ':' + settings.password) + `@${address}:${this.port}#${encodeURIComponent(remark)}`; + return 'ss://' + safeBase64(settings.method + ':' + settings.password) + `@${address}:${this.port}#${encodeURIComponent(remark)}`; } genTrojanLink(address = '', remark = '', clientIndex = 0) { @@ -1191,7 +1195,7 @@ class Inbound extends XrayCommonClass { const port = this.port; const type = this.stream.network; const params = new Map(); - params.set("type", this.stream.network); + params.set("type", this.stream.network); switch (type) { case "tcp": const tcp = this.stream.tcp; @@ -1246,12 +1250,12 @@ class Inbound extends XrayCommonClass { } if (!ObjectUtil.isEmpty(this.stream.tls.server)) { address = this.stream.tls.server; - } - if (this.stream.tls.settings[0]['serverName'] !== ''){ - params.set("sni", this.stream.tls.settings[0]['serverName']); } + if (this.stream.tls.settings[0]['serverName'] !== ''){ + params.set("sni", this.stream.tls.settings[0]['serverName']); + } } - + if (this.XTLS) { params.set("security", "xtls"); params.set("alpn", this.stream.tls.alpn); @@ -1259,11 +1263,11 @@ class Inbound extends XrayCommonClass { params.set("allowInsecure", "1"); } if (!ObjectUtil.isEmpty(this.stream.tls.server)) { - address = this.stream.tls.server; - } - params.set("flow", this.settings.trojans[clientIndex].flow); - } - + address = this.stream.tls.server; + } + params.set("flow", this.settings.trojans[clientIndex].flow); + } + const link = `trojan://${settings.trojans[clientIndex].password}@${address}:${this.port}#${encodeURIComponent(remark)}`; const url = new URL(link); for (const [key, value] of params) { @@ -1294,8 +1298,9 @@ class Inbound extends XrayCommonClass { default: return ''; } } + genInboundLinks(address = '', remark = '') { - let link = ''; + let link = ''; switch (this.protocol) { case Protocols.VMESS: case Protocols.VLESS: @@ -1308,7 +1313,7 @@ class Inbound extends XrayCommonClass { return (this.genSSLink(address, remark) + '\r\n'); default: return ''; } -} + } static fromJson(json={}) { return new Inbound( @@ -1423,7 +1428,7 @@ Inbound.VmessSettings = class extends Inbound.Settings { } }; Inbound.VmessSettings.Vmess = class extends XrayCommonClass { - constructor(id=RandomUtil.randomUUID(), alterId=0, email=RandomUtil.randomText(),limitIp=0, totalGB=0, expiryTime='') { + constructor(id=RandomUtil.randomUUID(), alterId=0, email=RandomUtil.randomText(),limitIp=0, totalGB=0, expiryTime=0, enable=true, tgId='', subId='') { super(); this.id = id; this.alterId = alterId; @@ -1431,6 +1436,9 @@ Inbound.VmessSettings.Vmess = class extends XrayCommonClass { this.limitIp = limitIp; this.totalGB = totalGB; this.expiryTime = expiryTime; + this.enable = enable; + this.tgId = tgId; + this.subId = subId; } static fromJson(json={}) { @@ -1441,13 +1449,18 @@ Inbound.VmessSettings.Vmess = class extends XrayCommonClass { json.limitIp, json.totalGB, json.expiryTime, - + json.enable, + json.tgId, + json.subId, ); } get _expiryTime() { if (this.expiryTime === 0 || this.expiryTime === "") { return null; } + if (this.expiryTime < 0){ + return this.expiryTime / -86400000; + } return moment(this.expiryTime); } @@ -1475,7 +1488,7 @@ Inbound.VLESSSettings = class extends Inbound.Settings { fallbacks=[],) { super(protocol); this.vlesses = vlesses; - this.decryption = 'none'; + this.decryption = 'none'; // Using decryption is not implemented here this.fallbacks = fallbacks; } @@ -1487,6 +1500,7 @@ Inbound.VLESSSettings = class extends Inbound.Settings { this.fallbacks.splice(index, 1); } + // decryption should be set to static value static fromJson(json={}) { return new Inbound.VLESSSettings( Protocols.VLESS, @@ -1506,8 +1520,7 @@ Inbound.VLESSSettings = class extends Inbound.Settings { }; Inbound.VLESSSettings.VLESS = class extends XrayCommonClass { - - constructor(id=RandomUtil.randomUUID(), flow='', email=RandomUtil.randomText(),limitIp=0, totalGB=0, expiryTime='') { + constructor(id=RandomUtil.randomUUID(), flow='', email=RandomUtil.randomText(),limitIp=0, totalGB=0, expiryTime=0, enable=true, tgId='', subId='') { super(); this.id = id; this.flow = flow; @@ -1515,7 +1528,9 @@ Inbound.VLESSSettings.VLESS = class extends XrayCommonClass { this.limitIp = limitIp; this.totalGB = totalGB; this.expiryTime = expiryTime; - + this.enable = enable; + this.tgId = tgId; + this.subId = subId; } static fromJson(json={}) { @@ -1526,14 +1541,19 @@ Inbound.VLESSSettings.VLESS = class extends XrayCommonClass { json.limitIp, json.totalGB, json.expiryTime, - + json.enable, + json.tgId, + json.subId, ); - } + } get _expiryTime() { if (this.expiryTime === 0 || this.expiryTime === "") { return null; } + if (this.expiryTime < 0){ + return this.expiryTime / -86400000; + } return moment(this.expiryTime); } @@ -1553,7 +1573,7 @@ Inbound.VLESSSettings.VLESS = class extends XrayCommonClass { } }; Inbound.VLESSSettings.Fallback = class extends XrayCommonClass { - constructor(name="", alpn='', path='', dest='', xver=0) { + constructor(name="", alpn=[], path='', dest='', xver=0) { super(); this.name = name; this.alpn = alpn; @@ -1593,8 +1613,8 @@ Inbound.VLESSSettings.Fallback = class extends XrayCommonClass { Inbound.TrojanSettings = class extends Inbound.Settings { constructor(protocol, - trojans=[new Inbound.TrojanSettings.Trojan()], - fallbacks=[],) { + trojans=[new Inbound.TrojanSettings.Trojan()], + fallbacks=[],) { super(protocol); this.trojans = trojans; this.fallbacks = fallbacks; @@ -1623,7 +1643,7 @@ Inbound.TrojanSettings = class extends Inbound.Settings { } }; Inbound.TrojanSettings.Trojan = class extends XrayCommonClass { - constructor(password=RandomUtil.randomSeq(10), flow='', email=RandomUtil.randomText(),limitIp=0, totalGB=0, expiryTime='') { + constructor(password=RandomUtil.randomSeq(10), flow='', email=RandomUtil.randomText(),limitIp=0, totalGB=0, expiryTime=0, enable=true, tgId='', subId='') { super(); this.password = password; this.flow = flow; @@ -1631,6 +1651,9 @@ Inbound.TrojanSettings.Trojan = class extends XrayCommonClass { this.limitIp = limitIp; this.totalGB = totalGB; this.expiryTime = expiryTime; + this.enable = enable; + this.tgId = tgId; + this.subId = subId; } toJson() { @@ -1641,10 +1664,13 @@ Inbound.TrojanSettings.Trojan = class extends XrayCommonClass { limitIp: this.limitIp, totalGB: this.totalGB, expiryTime: this.expiryTime, + enable: this.enable, + tgId: this.tgId, + subId: this.subId, }; } - static fromJson(json={}) { + static fromJson(json = {}) { return new Inbound.TrojanSettings.Trojan( json.password, json.flow, @@ -1652,7 +1678,9 @@ Inbound.TrojanSettings.Trojan = class extends XrayCommonClass { json.limitIp, json.totalGB, json.expiryTime, - + json.enable, + json.tgId, + json.subId, ); } @@ -1660,6 +1688,9 @@ Inbound.TrojanSettings.Trojan = class extends XrayCommonClass { if (this.expiryTime === 0 || this.expiryTime === "") { return null; } + if (this.expiryTime < 0){ + return this.expiryTime / -86400000; + } return moment(this.expiryTime); } @@ -1681,7 +1712,7 @@ Inbound.TrojanSettings.Trojan = class extends XrayCommonClass { }; Inbound.TrojanSettings.Fallback = class extends XrayCommonClass { - constructor(name="", alpn='', path='', dest='', xver=0) { + constructor(name="", alpn=[], path='', dest='', xver=0) { super(); this.name = name; this.alpn = alpn; @@ -1721,9 +1752,9 @@ Inbound.TrojanSettings.Fallback = class extends XrayCommonClass { Inbound.ShadowsocksSettings = class extends Inbound.Settings { constructor(protocol, - method = SSMethods.BLAKE3_AES_256_GCM, - password = RandomUtil.randomSeq(44), - network = 'tcp,udp' + method=SSMethods.BLAKE3_AES_256_GCM, + password=RandomUtil.randomSeq(44), + network='tcp,udp' ) { super(protocol); this.method = method; @@ -1731,7 +1762,7 @@ Inbound.ShadowsocksSettings = class extends Inbound.Settings { this.network = network; } - static fromJson(json = {}) { + static fromJson(json={}) { return new Inbound.ShadowsocksSettings( Protocols.SHADOWSOCKS, json.method, @@ -1755,7 +1786,7 @@ Inbound.DokodemoSettings = class extends Inbound.Settings { this.address = address; this.port = port; this.network = network; - this.followRedirect = followRedirect; + this.followRedirect = followRedirect; } static fromJson(json={}) { @@ -1764,7 +1795,7 @@ Inbound.DokodemoSettings = class extends Inbound.Settings { json.address, json.port, json.network, - json.followRedirect, + json.followRedirect, ); } @@ -1773,7 +1804,7 @@ Inbound.DokodemoSettings = class extends Inbound.Settings { address: this.address, port: this.port, network: this.network, - followRedirect: this.followRedirect, + followRedirect: this.followRedirect, }; } }; -- cgit v1.2.3 From 26a0481d8275c6d7953aaeb72a316db69c150354 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Mon, 10 Apr 2023 14:33:50 +0330 Subject: http header bug fixed --- web/assets/js/model/xray.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'web/assets') diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index 65f4bfd9..a7b43e3f 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -106,7 +106,6 @@ Object.freeze(XTLS_FLOW_CONTROL); Object.freeze(TLS_FLOW_CONTROL); Object.freeze(TLS_VERSION_OPTION); Object.freeze(TLS_CIPHER_OPTION); -Object.freeze(UTLS_FINGERPRINT); Object.freeze(ALPN_OPTION); class XrayCommonClass { @@ -177,7 +176,6 @@ class TcpStreamSettings extends XrayCommonClass { this.type = type; this.request = request; this.response = response; - this.acceptProxyProtocol = acceptProxyProtocol; } static fromJson(json={}) { @@ -185,9 +183,8 @@ class TcpStreamSettings extends XrayCommonClass { if (!header) { header = {}; } - return new TcpStreamSettings( + return new TcpStreamSettings(json.acceptProxyProtocol, header.type, - json.acceptProxyProtocol, TcpStreamSettings.TcpRequest.fromJson(header.request), TcpStreamSettings.TcpResponse.fromJson(header.response), ); @@ -201,7 +198,6 @@ class TcpStreamSettings extends XrayCommonClass { request: this.type === 'http' ? this.request.toJson() : undefined, response: this.type === 'http' ? this.response.toJson() : undefined, }, - acceptProxyProtocol: this.acceptProxyProtocol, }; } } @@ -994,6 +990,7 @@ class Inbound extends XrayCommonClass { case Protocols.VMESS: case Protocols.VLESS: case Protocols.TROJAN: + case Protocols.SHADOWSOCKS: return true; default: return false; -- cgit v1.2.3 From abb79bd97889e6e75fcd5a3a23e737c993906ffb Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Mon, 10 Apr 2023 19:58:52 +0330 Subject: Reality --- web/assets/js/model/xray.js | 136 ++++++++++++++++++++++++++++++++++++++++++-- web/assets/js/util/utils.js | 53 +++++++++++++++++ 2 files changed, 184 insertions(+), 5 deletions(-) (limited to 'web/assets') diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index a7b43e3f..c757f47f 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -91,6 +91,9 @@ const UTLS_FINGERPRINT = { UTLS_RANDOMIZED: "randomized", }; +const bytesToHex = e => Array.from(e).map(e => e.toString(16).padStart(2, 0)).join(''); +const hexToBytes = e => new Uint8Array(e.match(/[0-9a-f]{2}/gi).map(e => parseInt(e, 16))); + const ALPN_OPTION = { H3: "h3", H2: "h2", @@ -596,10 +599,62 @@ TlsStreamSettings.Settings = class extends XrayCommonClass { } }; +class RealityStreamSettings extends XrayCommonClass { + constructor(show = false,xver = 0, fingerprint = UTLS_FINGERPRINT.UTLS_FIREFOX, dest = 'github.io:443', serverNames = 'github.io,www.github.io,', privateKey = RandomUtil.randomX25519PrivateKey(), publicKey = '', minClient = '', + maxClient = '', maxTimediff = 0, shortIds = RandomUtil.randowShortId()) { + super(); + this.show = show; + this.xver = xver; + this.fingerprint = fingerprint; + this.dest = dest; + this.serverNames = serverNames instanceof Array ? serverNames.join(",") : serverNames; + this.privateKey = privateKey; + this.publicKey = RandomUtil.randomX25519PublicKey(this.privateKey); + this.minClient = minClient; + this.maxClient = maxClient; + this.maxTimediff = maxTimediff; + this.shortIds = shortIds instanceof Array ? shortIds.join(",") : shortIds; + + } + + static fromJson(json = {}) { + return new RealityStreamSettings( + json.show, + json.xver, + json.fingerprint, + json.dest, + json.serverNames, + json.privateKey, + json.publicKey, + json.minClient, + json.maxClient, + json.maxTimediff, + json.shortIds + ); + + } + toJson() { + return { + show: this.show, + xver: this.xver, + fingerprint: this.fingerprint, + dest: this.dest, + serverNames: this.serverNames.split(/,|,|\s+/), + privateKey: this.privateKey, + publicKey: this.publicKey, + minClient: this.minClient, + maxClient: this.maxClient, + maxTimediff: this.maxTimediff, + shortIds: this.shortIds.split(/,|,|\s+/) + }; + } +} + class StreamSettings extends XrayCommonClass { constructor(network='tcp', security='none', tlsSettings=new TlsStreamSettings(), + realitySettings = new RealityStreamSettings(), tcpSettings=new TcpStreamSettings(), kcpSettings=new KcpStreamSettings(), wsSettings=new WsStreamSettings(), @@ -611,6 +666,7 @@ class StreamSettings extends XrayCommonClass { this.network = network; this.security = security; this.tls = tlsSettings; + this.reality = realitySettings; this.tcp = tcpSettings; this.kcp = kcpSettings; this.ws = wsSettings; @@ -643,17 +699,34 @@ class StreamSettings extends XrayCommonClass { } } - static fromJson(json={}) { - let tls; - if (json.security === "xtls") { - tls = TlsStreamSettings.fromJson(json.XTLSSettings); + //for Reality + get isReality() { + return this.security === "reality"; + } + + set isReality(isReality) { + if (isReality) { + this.security = "reality"; } else { + this.security = "none"; + } + } + + static fromJson(json = {}) { + let tls, reality; + if (json.security === "xtls") { + tls = TlsStreamSettings.fromJson(json.xtlsSettings); + } else if (json.security === "tls") { tls = TlsStreamSettings.fromJson(json.tlsSettings); } + if (json.security === "reality") { + reality = RealityStreamSettings.fromJson(json.realitySettings) + } return new StreamSettings( json.network, json.security, tls, + reality, TcpStreamSettings.fromJson(json.tcpSettings), KcpStreamSettings.fromJson(json.kcpSettings), WsStreamSettings.fromJson(json.wsSettings), @@ -671,6 +744,7 @@ class StreamSettings extends XrayCommonClass { tlsSettings: this.isTls ? this.tls.toJson() : undefined, XTLSSettings: this.isXTLS ? this.tls.toJson() : undefined, tcpSettings: network === 'tcp' ? this.tcp.toJson() : undefined, + realitySettings: this.isReality ? this.reality.toJson() : undefined, kcpSettings: network === 'kcp' ? this.kcp.toJson() : undefined, wsSettings: network === 'ws' ? this.ws.toJson() : undefined, httpSettings: network === 'http' ? this.http.toJson() : undefined, @@ -743,6 +817,8 @@ class Inbound extends XrayCommonClass { set tls(isTls) { if (isTls) { + this.xtls = false; + this.reality = false; this.stream.security = 'tls'; } else { this.stream.security = 'none'; @@ -755,12 +831,32 @@ class Inbound extends XrayCommonClass { set XTLS(isXTLS) { if (isXTLS) { + this.xtls = false; + this.reality = false; this.stream.security = 'xtls'; } else { this.stream.security = 'none'; } } + //for Reality + get reality() { + if (this.stream.security === "reality") { + return this.network === "tcp" || this.network === "grpc" || this.network === "http"; + } + return false; + } + + set reality(isReality) { + if (isReality) { + this.tls = false; + this.xtls = false; + this.stream.security = "reality"; + } else { + this.stream.security = "none"; + } + } + get network() { return this.stream.network; } @@ -957,9 +1053,19 @@ class Inbound extends XrayCommonClass { } } + canEnableReality() { + switch (this.protocol) { + case Protocols.VLESS: + break; + default: + return false; + } + return this.network === "tcp" || this.network === "grpc" || this.network === "http"; + } + //this is used for xtls-rprx-vision canEnableTlsFlow() { - if ((this.stream.security === 'tls') && (this.network === "tcp")) { + if (((this.stream.security === 'tls') || (this.stream.security === 'reality')) && (this.network === "tcp")) { switch (this.protocol) { case Protocols.VLESS: return true; @@ -1169,6 +1275,26 @@ class Inbound extends XrayCommonClass { params.set("flow", this.settings.vlesses[clientIndex].flow); } + if (this.reality) { + params.set("security", "reality"); + if (!ObjectUtil.isArrEmpty(this.stream.reality.serverNames)) { + params.set("sni", this.stream.reality.serverNames.split(/,|,|\s+/)[0]); + } + if (this.stream.reality.publicKey != "") { + //params.set("pbk", Ed25519.getPublicKey(this.stream.reality.privateKey)); + params.set("pbk", this.stream.reality.publicKey); + } + if (this.stream.network === 'tcp') { + params.set("flow", this.settings.vlesses[clientIndex].flow); + } + if (this.stream.reality.shortIds != "") { + params.set("sid", this.stream.reality.shortIds); + } + if (this.stream.reality.fingerprint != "") { + params.set("fp", this.stream.reality.fingerprint); + } + } + const link = `vless://${uuid}@${address}:${port}`; const url = new URL(link); for (const [key, value] of params) { diff --git a/web/assets/js/util/utils.js b/web/assets/js/util/utils.js index ec6df22a..405985da 100644 --- a/web/assets/js/util/utils.js +++ b/web/assets/js/util/utils.js @@ -89,6 +89,31 @@ const seq = [ 'U', 'V', 'W', 'X', 'Y', 'Z' ]; +const shortIdSeq = [ + 'a', 'b', 'c', 'd', 'e', 'f', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', +]; + +const x25519Map = new Map( + [ + ['EH2FWe-Ij_FFAa2u9__-aiErLvVIneP601GOCdlyPWw', "goY3OtfaA4UYbiz7Hn0NysI5QJrK0VT_Chg6RLgUPQU"], + ['cKI_6DoMSP1IepeWWXrG3G9nkehl94KYBhagU50g2U0', "VigpKFbSLnHLzBWobZaS1IBmw--giJ51w92y723ajnU"], + ['qM2SNyK3NyHB6deWpEP3ITyCGKQFRTna_mlKP0w1QH0', "HYyIGuyNFslmcnNT7mrDdmuXwn4cm7smE_FZbYguKHQ"], + ['qCWg5GMEDFd3n1nxDswlIpOHoPUXMLuMOIiLUVzubkI', "rJFC3dUjJxMnVZiUGzmf_LFsJUwFWY-CU5RQgFOHCWM"], + ['4NOBxDrEsOhNI3Y3EnVIy_TN-uyBoAjQw6QM0YsOi0s', "CbcY9qc4YuMDJDyyL0OITlU824TBg1O84ClPy27e2RM"], + ['eBvFb0M4HpSOwWjtXV8zliiEs_hg56zX4a2LpuuqpEI', "CjulQ2qVIky7ImIfysgQhNX7s_drGLheCGSkVHcLZhc"], + ['yEpOzQV04NNcycWVeWtRNTzv5TS-ynTuKRacZCH-6U8', "O9RSr5gSdok2K_tobQnf_scyKVqnCx6C4Jrl7_rCZEQ"], + ['CNt6TAUVCwqM6xIBHyni0K3Zqbn2htKQLvLb6XDgh0s', "d9cGLVBrDFS02L2OvkqyqwFZ1Ux3AHs28ehl4Rwiyl0"], + ['EInKw-6Wr0rAHXlxxDuZU5mByIzcD3Z-_iWPzXlUL1k', "LlYD2nNVAvyjNvjZGZh4R8PkMIwkc6EycPTvR2LE0nQ"], + ['GKIKo7rcXVyle-EUHtGIDtYnDsI6osQmOUl3DTJRAGc', "VcqHivYGGoBkcxOI6cSSjQmneltstkb2OhvO53dyhEM"], + ['-FVDzv68IC17fJVlNDlhrrgX44WeBfbhwjWpCQVXGHE', "PGG2EYOvsFt2lAQTD7lqHeRxz2KxvllEDKcUrtizPBU"], + ['0H3OJEYEu6XW7woqy7cKh2vzg6YHkbF_xSDTHKyrsn4', "mzevpYbS8kXengBY5p7tt56QE4tS3lwlwRemmkcQeyc"], + ['8F8XywN6ci44ES6em2Z0fYYxyptB9uaXY9Hc1WSSPE4', "qCZUdWQZ2H33vWXnOkG8NpxBeq3qn5QWXlfCOWBNkkc"], + ['IN0dqfkC10dj-ifRHrg2PmmOrzYs697ajGMwcLbu-1g', "2UW_EO3r7uczPGUUlpJBnMDpDmWUHE2yDzCmXS4sckE"], + ['uIcmks5rAhvBe4dRaJOdeSqgxLGGMZhsGk4J4PEKL2s', "F9WJV_74IZp0Ide4hWjiJXk9FRtBUBkUr3mzU-q1lzk"], + ] +); + class RandomUtil { static randomIntRange(min, max) { @@ -107,6 +132,14 @@ class RandomUtil { return str; } + static randomShortIdSeq(count) { + let str = ''; + for (let i = 0; i < count; ++i) { + str += shortIdSeq[this.randomInt(16)]; + } + return str; + } + static randomLowerAndNum(count) { let str = ''; for (let i = 0; i < count; ++i) { @@ -137,6 +170,26 @@ class RandomUtil { }); } + static randowShortId() { + let str = ''; + str += this.randomShortIdSeq(8) + return str; + } + + static randomX25519PrivateKey() { + let num = x25519Map.size; + let index = this.randomInt(num); + let cntr = 0; + for (let key of x25519Map.keys()) { + if (cntr++ === index) { + return key; + } + } + } + + static randomX25519PublicKey(key) { + return x25519Map.get(key) + } static randomText() { var chars = 'abcdefghijklmnopqrstuvwxyz1234567890'; var string = ''; -- cgit v1.2.3 From 7412bf17a927df4715b65962de5f683dade83395 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Tue, 11 Apr 2023 15:41:04 +0330 Subject: bug fix Co-Authored-By: Alireza Ahmadi --- web/assets/js/model/xray.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'web/assets') diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index c757f47f..f0ea1efd 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -1636,7 +1636,7 @@ Inbound.VLESSSettings = class extends Inbound.Settings { toJson() { return { clients: Inbound.VLESSSettings.toJsonArray(this.vlesses), - decryption: this.decryption, + decryption: 'none', fallbacks: Inbound.VLESSSettings.toJsonArray(this.fallbacks), }; } @@ -1696,7 +1696,7 @@ Inbound.VLESSSettings.VLESS = class extends XrayCommonClass { } }; Inbound.VLESSSettings.Fallback = class extends XrayCommonClass { - constructor(name="", alpn=[], path='', dest='', xver=0) { + constructor(name="", alpn='', path='', dest='', xver=0) { super(); this.name = name; this.alpn = alpn; @@ -1835,7 +1835,7 @@ Inbound.TrojanSettings.Trojan = class extends XrayCommonClass { }; Inbound.TrojanSettings.Fallback = class extends XrayCommonClass { - constructor(name="", alpn=[], path='', dest='', xver=0) { + constructor(name="", alpn='', path='', dest='', xver=0) { super(); this.name = name; this.alpn = alpn; -- cgit v1.2.3 From 54946e725e835a291f9c8e226788cd8a166e190b Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Tue, 11 Apr 2023 18:18:37 +0330 Subject: xtls bug fix --- web/assets/js/model/xray.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/assets') diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index f0ea1efd..d3668519 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -715,7 +715,7 @@ class StreamSettings extends XrayCommonClass { static fromJson(json = {}) { let tls, reality; if (json.security === "xtls") { - tls = TlsStreamSettings.fromJson(json.xtlsSettings); + tls = TlsStreamSettings.fromJson(json.XTLSSettings); } else if (json.security === "tls") { tls = TlsStreamSettings.fromJson(json.tlsSettings); } -- cgit v1.2.3 From c38d75f3d901e7a3f550ab05aef711f95421cae6 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Tue, 11 Apr 2023 22:30:24 +0330 Subject: reality for trojan --- web/assets/js/model/xray.js | 74 +++++++++++++++++++++++++++++++-------------- 1 file changed, 52 insertions(+), 22 deletions(-) (limited to 'web/assets') diff --git a/web/assets/js/model/xray.js b/web/assets/js/model/xray.js index d3668519..31a192af 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -600,8 +600,20 @@ TlsStreamSettings.Settings = class extends XrayCommonClass { }; class RealityStreamSettings extends XrayCommonClass { - constructor(show = false,xver = 0, fingerprint = UTLS_FINGERPRINT.UTLS_FIREFOX, dest = 'github.io:443', serverNames = 'github.io,www.github.io,', privateKey = RandomUtil.randomX25519PrivateKey(), publicKey = '', minClient = '', - maxClient = '', maxTimediff = 0, shortIds = RandomUtil.randowShortId()) { + + constructor( + show = false,xver = 0, + fingerprint = UTLS_FINGERPRINT.UTLS_FIREFOX, + dest = 'yahoo.com:443', + serverNames = 'yahoo.com,www.yahoo.com', + privateKey = RandomUtil.randomX25519PrivateKey(), + publicKey = '', + minClient = '', + maxClient = '', + maxTimediff = 0, + shortIds = RandomUtil.randowShortId() + ) + { super(); this.show = show; this.xver = xver; @@ -613,11 +625,9 @@ class RealityStreamSettings extends XrayCommonClass { this.minClient = minClient; this.maxClient = maxClient; this.maxTimediff = maxTimediff; - this.shortIds = shortIds instanceof Array ? shortIds.join(",") : shortIds; - - } - - static fromJson(json = {}) { + this.shortIds = shortIds instanceof Array ? shortIds.join(",") : shortIds; + } + static fromJson(json = {}) { return new RealityStreamSettings( json.show, json.xver, @@ -631,9 +641,8 @@ class RealityStreamSettings extends XrayCommonClass { json.maxTimediff, json.shortIds ); - - } - toJson() { + } + toJson() { return { show: this.show, xver: this.xver, @@ -646,22 +655,22 @@ class RealityStreamSettings extends XrayCommonClass { maxClient: this.maxClient, maxTimediff: this.maxTimediff, shortIds: this.shortIds.split(/,|,|\s+/) - }; + }; + } } -} class StreamSettings extends XrayCommonClass { constructor(network='tcp', - security='none', - tlsSettings=new TlsStreamSettings(), - realitySettings = new RealityStreamSettings(), - tcpSettings=new TcpStreamSettings(), - kcpSettings=new KcpStreamSettings(), - wsSettings=new WsStreamSettings(), - httpSettings=new HttpStreamSettings(), - quicSettings=new QuicStreamSettings(), - grpcSettings=new GrpcStreamSettings(), - ) { + security='none', + tlsSettings=new TlsStreamSettings(), + realitySettings = new RealityStreamSettings(), + tcpSettings=new TcpStreamSettings(), + kcpSettings=new KcpStreamSettings(), + wsSettings=new WsStreamSettings(), + httpSettings=new HttpStreamSettings(), + quicSettings=new QuicStreamSettings(), + grpcSettings=new GrpcStreamSettings(), + ) { super(); this.network = network; this.security = security; @@ -1056,6 +1065,7 @@ class Inbound extends XrayCommonClass { canEnableReality() { switch (this.protocol) { case Protocols.VLESS: + case Protocols.TROJAN: break; default: return false; @@ -1379,6 +1389,26 @@ class Inbound extends XrayCommonClass { } } + if (this.reality) { + params.set("security", "reality"); + if (!ObjectUtil.isArrEmpty(this.stream.reality.serverNames)) { + params.set("sni", this.stream.reality.serverNames.split(/,|,|\s+/)[0]); + } + if (this.stream.reality.publicKey != "") { + //params.set("pbk", Ed25519.getPublicKey(this.stream.reality.privateKey)); + params.set("pbk", this.stream.reality.publicKey); + } + if (this.stream.network === 'tcp') { + params.set("flow", this.settings.trojans[clientIndex].flow); + } + if (this.stream.reality.shortIds != "") { + params.set("sid", this.stream.reality.shortIds); + } + if (this.stream.reality.fingerprint != "") { + params.set("fp", this.stream.reality.fingerprint); + } + } + if (this.XTLS) { params.set("security", "xtls"); params.set("alpn", this.stream.tls.alpn); -- cgit v1.2.3