Skip to content

Commit

Permalink
Merge pull request #73 from MHSanaei/TLS-enhancements
Browse files Browse the repository at this point in the history
Tls enhancements
  • Loading branch information
MHSanaei authored Mar 24, 2023
2 parents 466ad16 + bbec13c commit 17f6446
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 40 deletions.
84 changes: 77 additions & 7 deletions web/assets/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,16 @@
padding:16px;
}

.ant-menu-dark,
.ant-menu-dark .ant-menu-sub,
.ant-layout-header,
.ant-layout-sider-dark,
.ant-layout-sider-zero-width-trigger,
.ant-dropdown-menu-dark,.ant-dropdown-menu-dark .ant-dropdown-menu,
.ant-menu-dark.ant-menu-horizontal>.ant-menu-item,.ant-menu-dark.ant-menu-horizontal>.ant-menu-submenu {
background:#161b22
}

.ant-card-dark {
color: hsla(0,0%,100%,.65);
background-color: #1a212a;
Expand All @@ -178,9 +188,10 @@

.ant-card-dark .ant-collapse-content,
.ant-card-dark .ant-calendar,
.ant-card-dark .ant-table-placeholder {
.ant-card-dark .ant-table-placeholder,
.ant-card-dark .ant-input-group-addon {
color: hsla(0,0%,100%,.65);
background-color: #1a212a;
background-color: #262f3d;
}

.ant-card-dark .ant-list-item-meta-title,
Expand All @@ -198,7 +209,8 @@
.ant-card-dark .ant-calendar-year-select,
.ant-card-dark .ant-calendar-date,
.ant-card-dark .ant-collapse>.ant-collapse-item>.ant-collapse-header,
.ant-card-dark .ant-empty-normal {
.ant-card-dark .ant-empty-normal,
.ant-card-dark .ant-checkbox+span {
color: hsla(0,0%,100%,.65);
}

Expand All @@ -210,7 +222,7 @@

.ant-card-dark tbody .ant-table-expanded-row {
color: hsla(0,0%,100%,.65);
background-color: #023366;
background-color: #1a212a;
}

.ant-card-dark .ant-input,
Expand All @@ -219,7 +231,7 @@
.ant-card-dark .ant-select-dropdown-menu-item-selected,
.ant-card-dark .ant-select-selection {
color: hsla(0,0%,100%,.65);
background-color: #023366;
background-color: #2e3b52;
}

.ant-card-dark .ant-collapse-item {
Expand All @@ -232,7 +244,7 @@
.ant-card-dark .ant-modal-header,
.ant-card-dark .ant-calendar-selected-day .ant-calendar-date {
color: hsla(0,0%,100%,.65);
background-color: #242c3a;
background-color: #222a37;
}

.client-table-header {
Expand All @@ -244,7 +256,7 @@
}

.ant-card-dark .client-table-header {
background-color: #023366;
background-color: #1a212a;
color: hsla(0,0%,100%,.65);
}

Expand All @@ -266,4 +278,62 @@
.ant-drawer-dark .drawer-handle {
background-color: #1a212a;
border: 1px solid hsla(0,0%,100%,.30);
}

.ant-card-dark .ant-tag-blue {
color: #3c9ae8;
background: #111d2c;
border-color: #15395b;
}

.ant-card-dark .ant-tag-green {
color: #6abe39;
background: #162312;
border-color: #274916;
}

.ant-card-dark .ant-tag-cyan {
color: #33bcb7;
background: #112123;
border-color: #144848;
}

.ant-card-dark .ant-tag-red {
color: #e84749;
background: #2a1215;
border-color: #58181c;
}

.ant-card-dark .ant-tag-orange {
color: #e89a3c;
background: #2b1d11;
border-color: #593815;
}

.ant-card-dark .ant-table-row-expand-icon,
.ant-card-dark .ant-checkbox-inner {
background: none;
}

.ant-card-dark .ant-switch-checked {
background-color: #0c61b0;
}

.ant-card-dark .ant-btn,
.ant-card-dark .ant-radio-button-wrapper {
color: hsla(0,0%,100%,.65);
background: none;
border: 1px solid hsla(0,0%,100%,.65);
}

.ant-card-dark .ant-radio-button-wrapper:hover {
color: #177ddc;
}

.ant-card-dark .ant-btn-primary {
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);
}
54 changes: 35 additions & 19 deletions web/assets/js/model/xray.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ const UTLS_FINGERPRINT = {
const ALPN_OPTION = {
H2: "h2",
HTTP1: "http/1.1",
BOTH: "h2,http/1.1",
};

Object.freeze(Protocols);
Expand Down Expand Up @@ -476,7 +475,7 @@ class GrpcStreamSettings extends XrayCommonClass {
}

class TlsStreamSettings extends XrayCommonClass {
constructor(serverName = '', minVersion = TLS_VERSION_OPTION.TLS12, maxVersion = TLS_VERSION_OPTION.TLS13,
constructor(serverName = '', minVersion = TLS_VERSION_OPTION.TLS10, maxVersion = TLS_VERSION_OPTION.TLS12,
cipherSuites = '',
certificates = [new TlsStreamSettings.Cert()], alpn=[''] ,settings=[new TlsStreamSettings.Settings()]) {
super();
Expand Down Expand Up @@ -575,9 +574,9 @@ TlsStreamSettings.Cert = class extends XrayCommonClass {
};

TlsStreamSettings.Settings = class extends XrayCommonClass {
constructor(insecure = false, fingerprint = '', serverName = '') {
constructor(allowInsecure = false, fingerprint = '', serverName = '') {
super();
this.inSecure = insecure;
this.allowInsecure = allowInsecure;
this.fingerprint = fingerprint;
this.serverName = serverName;
}
Expand All @@ -590,7 +589,7 @@ TlsStreamSettings.Settings = class extends XrayCommonClass {
}
toJson() {
return {
allowInsecure: this.inSecure,
allowInsecure: this.allowInsecure,
fingerprint: this.fingerprint,
serverName: this.serverName,
};
Expand Down Expand Up @@ -1084,7 +1083,8 @@ class Inbound extends XrayCommonClass {
tls: this.stream.security,
sni: this.stream.tls.settings[0]['serverName'],
fp: this.stream.tls.settings[0]['fingerprint'],
alpn: this.stream.tls.alpn[0],
alpn: this.stream.tls.alpn.join(','),
allowInsecure: this.stream.tls.settings[0].allowInsecure,
};
return 'vmess://' + base64(JSON.stringify(obj, null, 2));
}
Expand All @@ -1096,7 +1096,6 @@ class Inbound extends XrayCommonClass {
const type = this.stream.network;
const params = new Map();
params.set("type", this.stream.network);
params.set("security", this.stream.security);
switch (type) {
case "tcp":
const tcp = this.stream.tcp;
Expand Down Expand Up @@ -1143,8 +1142,12 @@ class Inbound extends XrayCommonClass {
}

if (this.tls) {
params.set("security", "tls");
params.set("fp" , this.stream.tls.settings[0]['fingerprint']);
params.set("alpn", this.stream.tls.alpn[0]);
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;
}
Expand All @@ -1156,12 +1159,17 @@ class Inbound extends XrayCommonClass {
}
}

if (this.XTLS) {
if (!ObjectUtil.isEmpty(this.stream.tls.server)) {
if (this.XTLS) {
params.set("security", "tls");
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);
}
params.set("flow", this.settings.vlesses[clientIndex].flow);
}

const link = `vless://${uuid}@${address}:${port}`;
const url = new URL(link);
Expand Down Expand Up @@ -1192,7 +1200,6 @@ class Inbound extends XrayCommonClass {
const type = this.stream.network;
const params = new Map();
params.set("type", this.stream.network);
params.set("security", this.stream.security);
switch (type) {
case "tcp":
const tcp = this.stream.tcp;
Expand Down Expand Up @@ -1239,8 +1246,12 @@ class Inbound extends XrayCommonClass {
}

if (this.tls) {
params.set("security", "tls");
params.set("fp" , this.stream.tls.settings[0]['fingerprint']);
params.set("alpn", this.stream.tls.alpn[0]);
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;
}
Expand All @@ -1249,12 +1260,17 @@ class Inbound extends XrayCommonClass {
}
}

if (this.XTLS) {
if (!ObjectUtil.isEmpty(this.stream.tls.server)) {
address = this.stream.tls.server;
}
if (this.XTLS) {
params.set("security", "tls");
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.trojans[clientIndex].flow);
}
}

const link = `trojan://${settings.trojans[clientIndex].password}@${address}:${this.port}#${encodeURIComponent(remark)}`;
const url = new URL(link);
Expand Down
2 changes: 1 addition & 1 deletion web/html/xui/form/protocol/trojan.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
</table>
</a-collapse-panel>
</a-collapse>
<template v-if="inbound.isTcp && inbound.tls">
<template v-if="inbound.isTcp && (inbound.tls || inbound.xtls)">
<a-form layout="inline">
<a-form-item label="Fallbacks">
<a-row>
Expand Down
2 changes: 1 addition & 1 deletion web/html/xui/form/protocol/vless.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
</table>
</a-collapse-panel>
</a-collapse>
<template v-if="inbound.isTcp && inbound.tls">
<template v-if="inbound.isTcp && (inbound.tls || inbound.xtls)">
<a-form layout="inline">
<a-form-item label="Fallbacks">
<a-row>
Expand Down
12 changes: 7 additions & 5 deletions web/html/xui/form/tls_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,13 @@
<a-form-item label='{{ i18n "domainName" }}'>
<a-input v-model.trim="inbound.stream.tls.server"></a-input>
</a-form-item>
<a-form-item label="Alpn" v-if="inbound.tls">
<a-select v-model="inbound.stream.tls.alpn[0]" style="width:200px">
<a-select-option value=''>auto</a-select-option>
<a-select-option v-for="key in ALPN_OPTION" :value="key">[[ key ]]</a-select-option>
</a-select>
<a-form-item label="Alpn">
<a-checkbox-group v-model="inbound.stream.tls.alpn" style="width:200px">
<a-checkbox v-for="key in ALPN_OPTION" :value="key">[[ key ]]</a-checkbox>
</a-checkbox-group>
</a-form-item>
<a-form-item label="Allow insecure">
<a-switch v-model="inbound.stream.tls.settings[0].allowInsecure"></a-switch>
</a-form-item>
<a-form-item label='{{ i18n "certificate" }}'>
<a-radio-group v-model="inbound.stream.tls.certs[0].useFile" button-style="solid">
Expand Down
4 changes: 0 additions & 4 deletions web/html/xui/inbounds.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
.ant-col-sm-24 {
margin-top: 10px;
}

.ant-table-row-expand-icon {
color: rgba(0,0,0,.65);
}
</style>
<body>
<a-layout id="app" v-cloak>
Expand Down
10 changes: 7 additions & 3 deletions web/service/tgbot.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,14 @@ func (t *Tgbot) answerCommand(message *tgbotapi.Message, chatId int64, isAdmin b
case "status":
msg = "bot is ok ✅"
case "usage":
if isAdmin {
t.searchClient(chatId, message.CommandArguments())
if len(message.CommandArguments()) > 1 {
if isAdmin {
t.searchClient(chatId, message.CommandArguments())
} else {
t.searchForClient(chatId, message.CommandArguments())
}
} else {
t.searchForClient(chatId, message.CommandArguments())
msg = "❗Please provide a text for search!"
}
default:
msg = "❗ Unknown command"
Expand Down

0 comments on commit 17f6446

Please sign in to comment.