diff options
| author | Mohammad Movaghari <52345697+mohammadmovaghari@users.noreply.github.com> | 2023-04-12 16:29:17 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-12 16:29:17 +0300 |
| commit | c575425292e2c4c690728174e42a6f34963394c2 (patch) | |
| tree | c9b033457baa55a98cea23a8769645f8f3dbd476 /web | |
| parent | 63f71e527ceddc724e0bd2893c4946b01f3a5f6c (diff) | |
| parent | 82b2809fccb6a131b4f84e2ca236f8bea567beae (diff) | |
Merge branch 'MHSanaei:main' into main
Diffstat (limited to 'web')
35 files changed, 1865 insertions, 415 deletions
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..31a192af 100644 --- a/web/assets/js/model/xray.js +++ b/web/assets/js/model/xray.js @@ -91,7 +91,11 @@ 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", HTTP1: "http/1.1", }; @@ -105,7 +109,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 { @@ -166,27 +169,25 @@ 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 = {}; } - return new TcpStreamSettings( + return new TcpStreamSettings(json.acceptProxyProtocol, header.type, - json.acceptProxyProtocol, TcpStreamSettings.TcpRequest.fromJson(header.request), TcpStreamSettings.TcpResponse.fromJson(header.response), ); @@ -194,21 +195,21 @@ class TcpStreamSettings extends XrayCommonClass { toJson() { return { + acceptProxyProtocol: this.acceptProxyProtocol, header: { type: this.type, request: this.type === 'http' ? this.request.toJson() : undefined, response: this.type === 'http' ? this.response.toJson() : undefined, }, - acceptProxyProtocol: this.acceptProxyProtocol, }; } } 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 +243,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 +262,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 +282,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 +475,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 +489,7 @@ class TlsStreamSettings extends XrayCommonClass { this.cipherSuites = cipherSuites; this.certs = certificates; this.alpn = alpn; - this.settings = settings; + this.settings = settings; } addCert(cert) { @@ -497,15 +502,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 +518,7 @@ class TlsStreamSettings extends XrayCommonClass { json.cipherSuites, certs, json.alpn, - settings, + settings, ); } @@ -526,7 +531,6 @@ class TlsStreamSettings extends XrayCommonClass { certificates: TlsStreamSettings.toJsonArray(this.certs), alpn: this.alpn, settings: TlsStreamSettings.toJsonArray(this.settings), - }; } } @@ -573,44 +577,105 @@ 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 RealityStreamSettings extends XrayCommonClass { + + 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; + 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(), - 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; this.tls = tlsSettings; + this.reality = realitySettings; this.tcp = tcpSettings; this.kcp = kcpSettings; this.ws = wsSettings; @@ -643,17 +708,34 @@ class StreamSettings extends XrayCommonClass { } } - static fromJson(json={}) { - let tls; + //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 { + } 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 +753,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, @@ -728,20 +811,23 @@ 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'; } set tls(isTls) { if (isTls) { + this.xtls = false; + this.reality = false; this.stream.security = 'tls'; } else { this.stream.security = 'none'; @@ -754,12 +840,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; } @@ -918,16 +1024,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,10 +1061,21 @@ class Inbound extends XrayCommonClass { return false; } } - + + canEnableReality() { + switch (this.protocol) { + case Protocols.VLESS: + case Protocols.TROJAN: + 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; @@ -968,11 +1085,10 @@ class Inbound extends XrayCommonClass { } return false; } - + canSetTls() { return this.canEnableTls(); } - canEnableXTLS() { switch (this.protocol) { @@ -989,7 +1105,8 @@ class Inbound extends XrayCommonClass { switch (this.protocol) { case Protocols.VMESS: case Protocols.VLESS: - case Protocols.TROJAN: + case Protocols.TROJAN: + case Protocols.SHADOWSOCKS: return true; default: return false; @@ -1065,7 +1182,7 @@ class Inbound extends XrayCommonClass { address = this.stream.tls.server; } } - + let obj = { v: '2', ps: remark, @@ -1078,7 +1195,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,26 +1265,46 @@ 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); + } + 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) { @@ -1177,13 +1314,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 +1328,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 +1383,32 @@ 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 (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); @@ -1259,11 +1416,11 @@ class Inbound extends XrayCommonClass { params.set("allowInsecure", "1"); } |
