2021-06-07 16:23:37 +08:00
|
|
|
|
Tea.context(function () {
|
|
|
|
|
|
this.addr = ""
|
|
|
|
|
|
this.protocol = ""
|
|
|
|
|
|
|
|
|
|
|
|
this.addrError = ""
|
|
|
|
|
|
|
2022-06-29 21:56:44 +08:00
|
|
|
|
// 当前服务协议
|
|
|
|
|
|
this.isHTTP = (this.serverType == "httpProxy" || this.serverType == "httpWeb")
|
2021-06-07 16:23:37 +08:00
|
|
|
|
if (this.serverType == "httpProxy") {
|
|
|
|
|
|
this.protocol = "http"
|
2022-06-29 21:56:44 +08:00
|
|
|
|
} else if (this.serverType == "tcpProxy") {
|
|
|
|
|
|
this.protocol = "tcp"
|
|
|
|
|
|
} else if (this.serverType == "udpProxy") {
|
|
|
|
|
|
this.protocol = "udp"
|
2021-06-07 16:23:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.changeProtocol = function () {
|
|
|
|
|
|
this.checkPort()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.changeAddr = function () {
|
|
|
|
|
|
if (this.serverType == "httpProxy") {
|
|
|
|
|
|
if (this.addr.startsWith("http://")) {
|
|
|
|
|
|
this.protocol = "http"
|
|
|
|
|
|
} else if (this.addr.startsWith("https://")) {
|
|
|
|
|
|
this.protocol = "https"
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.checkPort()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.checkPort = function () {
|
|
|
|
|
|
this.addrError = ""
|
|
|
|
|
|
|
|
|
|
|
|
// HTTP
|
|
|
|
|
|
if (this.protocol == "http") {
|
|
|
|
|
|
if (this.addr.endsWith(":443")) {
|
|
|
|
|
|
this.addrError = "443通常是HTTPS协议端口,请确认源站协议选择是否正确。"
|
2022-10-07 09:01:22 +08:00
|
|
|
|
} else if (this.addr.endsWith(":8443")) {
|
|
|
|
|
|
this.addrError = "8443通常是HTTPS协议端口,请确认源站协议选择是否正确。"
|
2021-06-07 16:23:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// HTTPS
|
|
|
|
|
|
if (this.protocol == "https") {
|
|
|
|
|
|
if (this.addr.endsWith(":80")) {
|
|
|
|
|
|
this.addrError = "80通常是HTTP协议端口,请确认源站协议选择是否正确。"
|
2022-10-07 09:01:22 +08:00
|
|
|
|
} else if (this.addr.endsWith(":8080")) {
|
|
|
|
|
|
this.addrError = "8080通常是HTTP协议端口,请确认源站协议选择是否正确。"
|
2021-06-07 16:23:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|