frp/web/frps/src/utils/proxy.js

98 lines
2.9 KiB
JavaScript
Raw Normal View History

2017-03-27 02:15:31 +08:00
class BaseProxy {
2021-01-25 16:04:33 +08:00
constructor(proxyStats) {
this.name = proxyStats.name
if (proxyStats.conf != null) {
this.encryption = proxyStats.conf.use_encryption
this.compression = proxyStats.conf.use_compression
} else {
this.encryption = ""
this.compression = ""
}
this.conns = proxyStats.cur_conns
this.traffic_in = proxyStats.today_traffic_in
this.traffic_out = proxyStats.today_traffic_out
this.last_start_time = proxyStats.last_start_time
this.last_close_time = proxyStats.last_close_time
this.status = proxyStats.status
2017-03-27 02:15:31 +08:00
}
}
class TcpProxy extends BaseProxy {
2021-01-25 16:04:33 +08:00
constructor(proxyStats) {
super(proxyStats)
this.type = "tcp"
if (proxyStats.conf != null) {
this.addr = ":" + proxyStats.conf.remote_port
this.port = proxyStats.conf.remote_port
} else {
this.addr = ""
this.port = ""
}
2017-03-27 02:15:31 +08:00
}
}
class UdpProxy extends BaseProxy {
2021-01-25 16:04:33 +08:00
constructor(proxyStats) {
super(proxyStats)
this.type = "udp"
if (proxyStats.conf != null) {
this.addr = ":" + proxyStats.conf.remote_port
this.port = proxyStats.conf.remote_port
} else {
this.addr = ""
this.port = ""
}
2017-03-27 02:15:31 +08:00
}
}
class HttpProxy extends BaseProxy {
2021-01-25 16:04:33 +08:00
constructor(proxyStats, port, subdomain_host) {
super(proxyStats)
this.type = "http"
this.port = port
if (proxyStats.conf != null) {
this.custom_domains = proxyStats.conf.custom_domains
this.host_header_rewrite = proxyStats.conf.host_header_rewrite
this.locations = proxyStats.conf.locations
2021-03-22 14:53:30 +08:00
if (proxyStats.conf.subdomain != "") {
this.subdomain = proxyStats.conf.subdomain + "." + subdomain_host
2021-01-25 16:04:33 +08:00
} else {
this.subdomain = ""
}
} else {
this.custom_domains = ""
this.host_header_rewrite = ""
this.subdomain = ""
this.locations = ""
}
2017-03-27 02:15:31 +08:00
}
}
class HttpsProxy extends BaseProxy {
2021-01-25 16:04:33 +08:00
constructor(proxyStats, port, subdomain_host) {
super(proxyStats)
this.type = "https"
this.port = port
if (proxyStats.conf != null) {
this.custom_domains = proxyStats.conf.custom_domains
2021-03-22 14:53:30 +08:00
if (proxyStats.conf.subdomain != "") {
this.subdomain = proxyStats.conf.subdomain + "." + subdomain_host
2021-01-25 16:04:33 +08:00
} else {
this.subdomain = ""
}
} else {
this.custom_domains = ""
this.subdomain = ""
}
2017-03-27 02:15:31 +08:00
}
}
2018-05-20 19:06:05 +08:00
class StcpProxy extends BaseProxy {
2021-01-25 16:04:33 +08:00
constructor(proxyStats) {
super(proxyStats)
this.type = "stcp"
}
2018-05-20 19:06:05 +08:00
}
2021-01-25 16:04:33 +08:00
export {BaseProxy, TcpProxy, UdpProxy, HttpProxy, HttpsProxy, StcpProxy}