| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  | class User { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     constructor() { | 
					
						
							|  |  |  |         this.username = ""; | 
					
						
							|  |  |  |         this.password = ""; | 
					
						
							| 
									
										
										
										
											2023-04-21 15:30:14 +00:00
										 |  |  |         this.LoginSecret = ""; | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class Msg { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     constructor(success, msg, obj) { | 
					
						
							|  |  |  |         this.success = false; | 
					
						
							|  |  |  |         this.msg = ""; | 
					
						
							|  |  |  |         this.obj = null; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         if (success != null) { | 
					
						
							|  |  |  |             this.success = success; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (msg != null) { | 
					
						
							|  |  |  |             this.msg = msg; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (obj != null) { | 
					
						
							|  |  |  |             this.obj = obj; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class DBInbound { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     constructor(data) { | 
					
						
							|  |  |  |         this.id = 0; | 
					
						
							|  |  |  |         this.userId = 0; | 
					
						
							|  |  |  |         this.up = 0; | 
					
						
							|  |  |  |         this.down = 0; | 
					
						
							|  |  |  |         this.total = 0; | 
					
						
							|  |  |  |         this.remark = ""; | 
					
						
							|  |  |  |         this.enable = true; | 
					
						
							|  |  |  |         this.expiryTime = 0; | 
					
						
							| 
									
										
										
										
											2023-03-17 16:07:49 +00:00
										 |  |  |         this.limitIp = 0; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |         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 toFixed(this.total / ONE_GB, 2); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     set totalGB(gb) { | 
					
						
							|  |  |  |         this.total = toFixed(gb * 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 isSocks() { | 
					
						
							|  |  |  |         return this.protocol === Protocols.SOCKS; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     get isHTTP() { | 
					
						
							|  |  |  |         return this.protocol === Protocols.HTTP; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     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); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     hasLink() { | 
					
						
							|  |  |  |         switch (this.protocol) { | 
					
						
							|  |  |  |             case Protocols.VMESS: | 
					
						
							|  |  |  |             case Protocols.VLESS: | 
					
						
							|  |  |  |             case Protocols.TROJAN: | 
					
						
							|  |  |  |             case Protocols.SHADOWSOCKS: | 
					
						
							|  |  |  |                 return true; | 
					
						
							|  |  |  |             default: | 
					
						
							|  |  |  |                 return false; | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-22 14:01:41 +00:00
										 |  |  |     genLink(address=this.address, remark=this.remark, clientIndex=0) { | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |         const inbound = this.toInbound(); | 
					
						
							| 
									
										
										
										
											2023-05-22 14:01:41 +00:00
										 |  |  |         return inbound.genLink(address, remark, clientIndex); | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-03-17 16:07:49 +00:00
										 |  |  |      | 
					
						
							| 
									
										
										
										
											2023-02-28 19:54:29 +00:00
										 |  |  | 	get genInboundLinks() { | 
					
						
							|  |  |  |         const inbound = this.toInbound(); | 
					
						
							|  |  |  |         return inbound.genInboundLinks(this.address, this.remark); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class AllSetting { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     constructor(data) { | 
					
						
							|  |  |  |         this.webListen = ""; | 
					
						
							| 
									
										
										
										
											2023-05-30 20:51:14 +00:00
										 |  |  |         this.webDomain = ""; | 
					
						
							| 
									
										
										
										
											2023-02-09 19:47:12 +00:00
										 |  |  |         this.webPort = 2053; | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |         this.webCertFile = ""; | 
					
						
							|  |  |  |         this.webKeyFile = ""; | 
					
						
							|  |  |  |         this.webBasePath = "/"; | 
					
						
							| 
									
										
										
										
											2023-04-25 11:30:21 +00:00
										 |  |  |         this.sessionMaxAge = ""; | 
					
						
							| 
									
										
										
										
											2023-04-09 19:43:18 +00:00
										 |  |  |         this.expireDiff = ""; | 
					
						
							|  |  |  |         this.trafficDiff = ""; | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |         this.tgBotEnable = false; | 
					
						
							|  |  |  |         this.tgBotToken = ""; | 
					
						
							| 
									
										
										
										
											2023-03-17 16:07:49 +00:00
										 |  |  |         this.tgBotChatId = ""; | 
					
						
							|  |  |  |         this.tgRunTime = "@daily"; | 
					
						
							|  |  |  |         this.tgBotBackup = false; | 
					
						
							| 
									
										
										
										
											2023-08-26 12:31:02 +00:00
										 |  |  |         this.tgBotLoginNotify = true; | 
					
						
							| 
									
										
										
										
											2023-03-17 16:07:49 +00:00
										 |  |  |         this.tgCpu = ""; | 
					
						
							| 
									
										
										
										
											2023-05-22 08:09:21 +00:00
										 |  |  |         this.tgLang = "en-US"; | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  |         this.xrayTemplateConfig = ""; | 
					
						
							| 
									
										
										
										
											2023-04-21 15:30:14 +00:00
										 |  |  |         this.secretEnable = false; | 
					
						
							| 
									
										
										
										
											2023-05-22 14:36:34 +00:00
										 |  |  |         this.subEnable = false; | 
					
						
							|  |  |  |         this.subListen = ""; | 
					
						
							|  |  |  |         this.subPort = "2096"; | 
					
						
							| 
									
										
										
										
											2023-05-30 20:51:14 +00:00
										 |  |  |         this.subPath = "/sub/"; | 
					
						
							| 
									
										
										
										
											2023-05-22 14:36:34 +00:00
										 |  |  |         this.subDomain = ""; | 
					
						
							|  |  |  |         this.subCertFile = ""; | 
					
						
							|  |  |  |         this.subKeyFile = ""; | 
					
						
							|  |  |  |         this.subUpdates = 0; | 
					
						
							| 
									
										
										
										
											2023-08-26 13:24:01 +00:00
										 |  |  |         this.subEncrypt = true; | 
					
						
							| 
									
										
										
										
											2023-08-26 12:31:02 +00:00
										 |  |  |         this.subShowInfo = true; | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-25 10:19:45 +00:00
										 |  |  |         this.timeLocation = "Asia/Ho_Chi_Minh"; | 
					
						
							| 
									
										
										
										
											2023-02-09 19:18:06 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |         if (data == null) { | 
					
						
							|  |  |  |             return | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         ObjectUtil.cloneProps(this, data); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     equals(other) { | 
					
						
							|  |  |  |         return ObjectUtil.equals(this, other); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-09-25 10:19:45 +00:00
										 |  |  | } |