| trafficIn: number |
| 9 | trafficOut: number |
| 10 | lastStartTime: string |
| 11 | lastCloseTime: string |
| 12 | status: string |
| 13 | user: string |
| 14 | clientID: string |
| 15 | addr: string |
| 16 | port: number |
| 17 |
| 18 | customDomains: string |
| 19 | hostHeaderRewrite: string |
| 20 | locations: string |
| 21 | subdomain: string |
| 22 |
| 23 | // TCPMux specific |
| 24 | multiplexer: string |
| 25 | routeByHTTPUser: string |
| 26 |
| 27 | constructor(proxyStats: any) { |
| 28 | this.name = proxyStats.name |
| 29 | this.type = '' |
| 30 | this.annotations = new Map<string, string>() |
| 31 | if (proxyStats.conf?.annotations) { |
| 32 | for (const key in proxyStats.conf.annotations) { |
| 33 | this.annotations.set(key, proxyStats.conf.annotations[key]) |
| 34 | } |
| 35 | } |
| 36 |
| 37 | this.encryption = false |
| 38 | this.compression = false |
| 39 | this.encryption = |
| 40 | proxyStats.conf?.transport?.useEncryption || this.encryption |
| 41 | this.compression = |
| 42 | proxyStats.conf?.transport?.useCompression || this.compression |
| 43 | this.conns = proxyStats.curConns |
| 44 | this.trafficIn = proxyStats.todayTrafficIn |
| 45 | this.trafficOut = proxyStats.todayTrafficOut |
| 46 | this.lastStartTime = proxyStats.lastStartTime |
| 47 | this.lastCloseTime = proxyStats.lastCloseTime |
| 48 | this.status = proxyStats.status |
| 49 | this.user = proxyStats.user || '' |
| 50 | this.clientID = proxyStats.clientID || '' |
| 51 |
| 52 | this.addr = '' |
| 53 | this.port = 0 |
| 54 | this.customDomains = '' |
| 55 | this.hostHeaderRewrite = '' |
| 56 | this.locations = '' |
| 57 | this.subdomain = '' |
| 58 | this.multiplexer = '' |
| 59 | this.routeByHTTPUser = '' |
| 60 | } |
| 61 | } |
| 62 |
| 63 | class TCPProxy extends BaseProxy { |
| 64 | constructor(proxyStats: any) { |
| 65 | super(proxyStats) |
| 66 | this.type = 'tcp' |
| 67 | if (proxyStats.conf != null) { |
| 68 | this.addr = ':' + proxyStats.conf.remotePort |
| 69 | this.port = proxyStats.conf.remotePort |
| 70 | } else { |
| 71 | this.addr = '' |
| 72 | this.port = 0 |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 |
| 77 | class UDPProxy extends BaseProxy { |
| 78 | constructor(proxyStats: any) { |
| 79 | super(proxyStats) |
| 80 | this.type = 'udp' |
| 81 | if (proxyStats.conf != null) { |
| 82 | this.addr = ':' + proxyStats.conf.remotePort |
| 83 | this.port = proxyStats.conf.remotePort |
| 84 | } else { |
| 85 | this.addr = '' |
| 86 | this.port = 0 |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 |
| 91 | class HTTPProxy extends BaseProxy { |
| 92 | constructor(proxyStats: any, port: number, subdomainHost: string) { |
| 93 | super(proxyStats) |
| 94 | this.type = 'http' |
| 95 | this.port = port |
| 96 | if (proxyStats.conf) { |
| 97 | this.customDomains = proxyStats.conf.customDomains || this.customDomains |
| 98 | this.hostHeaderRewrite = proxyStats.conf.hostHeaderRewrite |
| 99 | this.locations = proxyStats.conf.locations |
| 100 | if (proxyStats.conf.subdomain) { |
| 101 | this.subdomain = `${proxyStats.conf.subdomain}.${subdomainHost}` |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 |
| 107 | class HTTPSProxy extends BaseProxy { |
| 108 | constructor(proxyStats: any, port: number, subdomainHost: string) { |
| 109 | super(proxyStats) |
| 110 | this.type = 'https' |
| 111 | this.port = port |
| 112 | if (proxyStats.conf != null) { |
| 113 | this.customDomains = proxyStats.conf.customDomains || this.customDomains |
| 114 | if (proxyStats.conf.subdomain) { |
| 115 | this.subdomain = `${proxyStats.conf.subdomain}.${subdomainHost}` |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 |
| 121 | class TCPMuxProxy extends BaseProxy { |
| 122 | constructor(proxyStats: any, port: number, subdomainHost: string) { |
| 123 | super(proxyStats) |
| 124 | this.type = 'tcpmux' |
| 125 | this.port = port |
| 126 |
| 127 | if (proxyStats.conf) { |
| 128 | this.customDomains = proxyStats.conf.customDomains || this.customDomains |
| 129 | this.multiplexer = proxyStats.conf.multiplexer || '' |
| 130 | this.routeByHTTPUser = proxyStats.conf.routeByHTTPUser || '' |
| 131 | if (proxyStats.conf.subdomain) { |
| 132 | this.subdomain = `${proxyStats.conf.subdomain}.${subdomainHost}` |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | } |
| 137 |
| 138 | class STCPProxy extends BaseProxy { |
| 139 | constructor(proxyStats: any) { |
| 140 | super(proxyStats) |
| 141 | this.type = 'stcp' |
| 142 | } |
| 143 | } |
| 144 |
| 145 | class SUDPProxy extends BaseProxy { |
| 146 | constructor(proxyStats: any) { |
| 147 | super(proxyStats) |
| 148 | this.type = 'sudp' |
| 149 | } |
| 150 | } |
| 151 |
| 152 | export { |
| 153 | BaseProxy, |
| 154 | TCPProxy, |
| 155 | UDPProxy, |
| 156 | TCPMuxProxy, |
| 157 | HTTPProxy, |
| 158 | HTTPSProxy, |
| 159 | STCPProxy, |
| 160 | SUDPProxy, |
| 161 | } |