mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-02-27 20:53:01 +00:00
TrustTunnel (by AdGuard) is an independent VPN protocol binary that runs alongside Xray. This integrates it into the 3x-ui panel so users can create TrustTunnel inbounds through the same UI. Architecture: - TrustTunnel runs as a separate process (not an xray inbound) - Each TrustTunnel inbound gets its own TOML config and process - TrustTunnel inbounds are skipped during xray config generation - Periodic health checks restart crashed TrustTunnel processes New files (isolated, minimal merge conflict risk): - trusttunnel/process.go: process lifecycle and TOML config generation - web/service/trusttunnel.go: service layer with start/stop/restart - web/html/form/protocol/trusttunnel.html: UI form template Modified files (minimal, targeted changes): - database/model/model.go: add TrustTunnel protocol constant - web/service/xray.go: skip trusttunnel inbounds in xray config - web/service/inbound.go: validation + TrustTunnel process triggers - web/web.go: startup/shutdown integration - web/assets/js/model/inbound.js: protocol enum + settings class - web/assets/js/model/dbinbound.js: isTrustTunnel helper - web/html/form/inbound.html: form conditional - web/html/form/client.html: password field for TrustTunnel clients https://claude.ai/code/session_01RQBndg4ZPmYAToK4KKcBzp
156 lines
No EOL
3.7 KiB
JavaScript
156 lines
No EOL
3.7 KiB
JavaScript
class DBInbound {
|
|
|
|
constructor(data) {
|
|
this.id = 0;
|
|
this.userId = 0;
|
|
this.up = 0;
|
|
this.down = 0;
|
|
this.total = 0;
|
|
this.allTime = 0;
|
|
this.remark = "";
|
|
this.enable = true;
|
|
this.expiryTime = 0;
|
|
this.trafficReset = "never";
|
|
this.lastTrafficResetTime = 0;
|
|
|
|
this.listen = "";
|
|
this.port = 0;
|
|
this.protocol = "";
|
|
this.settings = "";
|
|
this.streamSettings = "";
|
|
this.tag = "";
|
|
this.sniffing = "";
|
|
this.clientStats = ""
|
|
if (data == null) {
|
|
return;
|
|
}
|
|
ObjectUtil.cloneProps(this, data);
|
|
}
|
|
|
|
get totalGB() {
|
|
return NumberFormatter.toFixed(this.total / SizeFormatter.ONE_GB, 2);
|
|
}
|
|
|
|
set totalGB(gb) {
|
|
this.total = NumberFormatter.toFixed(gb * SizeFormatter.ONE_GB, 0);
|
|
}
|
|
|
|
get isVMess() {
|
|
return this.protocol === Protocols.VMESS;
|
|
}
|
|
|
|
get isVLess() {
|
|
return this.protocol === Protocols.VLESS;
|
|
}
|
|
|
|
get isTrojan() {
|
|
return this.protocol === Protocols.TROJAN;
|
|
}
|
|
|
|
get isSS() {
|
|
return this.protocol === Protocols.SHADOWSOCKS;
|
|
}
|
|
|
|
get isMixed() {
|
|
return this.protocol === Protocols.MIXED;
|
|
}
|
|
|
|
get isHTTP() {
|
|
return this.protocol === Protocols.HTTP;
|
|
}
|
|
|
|
get isWireguard() {
|
|
return this.protocol === Protocols.WIREGUARD;
|
|
}
|
|
|
|
get isTrustTunnel() {
|
|
return this.protocol === Protocols.TRUSTTUNNEL;
|
|
}
|
|
|
|
get address() {
|
|
let address = location.hostname;
|
|
if (!ObjectUtil.isEmpty(this.listen) && this.listen !== "0.0.0.0") {
|
|
address = this.listen;
|
|
}
|
|
return address;
|
|
}
|
|
|
|
get _expiryTime() {
|
|
if (this.expiryTime === 0) {
|
|
return null;
|
|
}
|
|
return moment(this.expiryTime);
|
|
}
|
|
|
|
set _expiryTime(t) {
|
|
if (t == null) {
|
|
this.expiryTime = 0;
|
|
} else {
|
|
this.expiryTime = t.valueOf();
|
|
}
|
|
}
|
|
|
|
get isExpiry() {
|
|
return this.expiryTime < new Date().getTime();
|
|
}
|
|
|
|
toInbound() {
|
|
let settings = {};
|
|
if (!ObjectUtil.isEmpty(this.settings)) {
|
|
settings = JSON.parse(this.settings);
|
|
}
|
|
|
|
let streamSettings = {};
|
|
if (!ObjectUtil.isEmpty(this.streamSettings)) {
|
|
streamSettings = JSON.parse(this.streamSettings);
|
|
}
|
|
|
|
let sniffing = {};
|
|
if (!ObjectUtil.isEmpty(this.sniffing)) {
|
|
sniffing = JSON.parse(this.sniffing);
|
|
}
|
|
|
|
const config = {
|
|
port: this.port,
|
|
listen: this.listen,
|
|
protocol: this.protocol,
|
|
settings: settings,
|
|
streamSettings: streamSettings,
|
|
tag: this.tag,
|
|
sniffing: sniffing,
|
|
clientStats: this.clientStats,
|
|
};
|
|
return Inbound.fromJson(config);
|
|
}
|
|
|
|
isMultiUser() {
|
|
switch (this.protocol) {
|
|
case Protocols.VMESS:
|
|
case Protocols.VLESS:
|
|
case Protocols.TROJAN:
|
|
case Protocols.TRUSTTUNNEL:
|
|
return true;
|
|
case Protocols.SHADOWSOCKS:
|
|
return this.toInbound().isSSMultiUser;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
hasLink() {
|
|
switch (this.protocol) {
|
|
case Protocols.VMESS:
|
|
case Protocols.VLESS:
|
|
case Protocols.TROJAN:
|
|
case Protocols.SHADOWSOCKS:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
genInboundLinks(remarkModel) {
|
|
const inbound = this.toInbound();
|
|
return inbound.genInboundLinks(this.remark, remarkModel);
|
|
}
|
|
} |