- 增加设置总流量功能,流量超出后自动禁用 - 优化部分 ui 细节 - 修复监听 ip 不为空导致无法启动 xray 的问题 - 修复二维码链接没有包含 address 的问题
123 lines
2.5 KiB
JavaScript
123 lines
2.5 KiB
JavaScript
class User {
|
|
username = "";
|
|
password = "";
|
|
}
|
|
|
|
class Msg {
|
|
success = false;
|
|
msg = "";
|
|
obj = null;
|
|
|
|
constructor(success, msg, obj) {
|
|
if (success != null) {
|
|
this.success = success;
|
|
}
|
|
if (msg != null) {
|
|
this.msg = msg;
|
|
}
|
|
if (obj != null) {
|
|
this.obj = obj;
|
|
}
|
|
}
|
|
}
|
|
|
|
class DBInbound {
|
|
id = 0;
|
|
userId = 0;
|
|
up = 0;
|
|
down = 0;
|
|
total = 0;
|
|
remark = "";
|
|
enable = true;
|
|
expiryTime = 0;
|
|
|
|
listen = "";
|
|
port = 0;
|
|
protocol = "";
|
|
settings = "";
|
|
streamSettings = "";
|
|
tag = "";
|
|
sniffing = "";
|
|
|
|
constructor(data) {
|
|
if (data == null) {
|
|
return;
|
|
}
|
|
ObjectUtil.cloneProps(this, data);
|
|
}
|
|
|
|
get totalGB() {
|
|
return toFixed(this.total / ONE_GB, 2);
|
|
}
|
|
|
|
set totalGB(gb) {
|
|
this.total = toFixed(gb * ONE_GB, 0);
|
|
}
|
|
|
|
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,
|
|
};
|
|
return Inbound.fromJson(config);
|
|
}
|
|
|
|
hasLink() {
|
|
switch (this.protocol) {
|
|
case Protocols.VMESS:
|
|
case Protocols.VLESS:
|
|
case Protocols.TROJAN:
|
|
case Protocols.SHADOWSOCKS:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
genLink(address = "") {
|
|
const inbound = this.toInbound();
|
|
return inbound.genLink(address, this.remark);
|
|
}
|
|
}
|
|
|
|
class AllSetting {
|
|
webListen = "";
|
|
webPort = 54321;
|
|
webCertFile = "";
|
|
webKeyFile = "";
|
|
webBasePath = "/";
|
|
|
|
xrayTemplateConfig = "";
|
|
|
|
timeLocation = "Asia/Shanghai";
|
|
|
|
constructor(data) {
|
|
if (data == null) {
|
|
return
|
|
}
|
|
ObjectUtil.cloneProps(this, data);
|
|
}
|
|
|
|
equals(other) {
|
|
return ObjectUtil.equals(this, other);
|
|
}
|
|
} |