mirror of
https://github.com/oneclickvirt/gostun.git
synced 2025-10-06 23:52:48 +08:00
增加stun服务器列表,轮询检测避免检测失败
This commit is contained in:
@@ -39,7 +39,7 @@ address and port dependent
|
|||||||
|
|
||||||
## 使用说明[Usage]
|
## 使用说明[Usage]
|
||||||
|
|
||||||
更新时间[Version]: 2024.05.05
|
更新时间[Version]: 2024.06.08
|
||||||
|
|
||||||
```
|
```
|
||||||
curl https://raw.githubusercontent.com/oneclickvirt/gostun/main/gostun_install.sh -sSf | sh
|
curl https://raw.githubusercontent.com/oneclickvirt/gostun/main/gostun_install.sh -sSf | sh
|
||||||
|
31
cmd/main.go
31
cmd/main.go
@@ -74,6 +74,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
log = logging.NewDefaultLeveledLoggerForScope("", logLevel, os.Stdout)
|
log = logging.NewDefaultLeveledLoggerForScope("", logLevel, os.Stdout)
|
||||||
|
|
||||||
|
if *addrStrPtr == "stun.voipgate.com:3478" {
|
||||||
if err := mappingTests(*addrStrPtr); err != nil {
|
if err := mappingTests(*addrStrPtr); err != nil {
|
||||||
NatMappingBehavior = "inconclusive" // my changes
|
NatMappingBehavior = "inconclusive" // my changes
|
||||||
log.Warn("NAT mapping behavior: inconclusive")
|
log.Warn("NAT mapping behavior: inconclusive")
|
||||||
@@ -82,6 +83,36 @@ func main() {
|
|||||||
NatFilteringBehavior = "inconclusive" // my changes
|
NatFilteringBehavior = "inconclusive" // my changes
|
||||||
log.Warn("NAT filtering behavior: inconclusive")
|
log.Warn("NAT filtering behavior: inconclusive")
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
addrStrPtrList := []string{
|
||||||
|
"stun.voipgate.com:3478",
|
||||||
|
"stun.miwifi.com:3478",
|
||||||
|
"stunserver.stunprotocol.org:3478",
|
||||||
|
}
|
||||||
|
checkStatus := true
|
||||||
|
for _, addrStr := range addrStrPtrList {
|
||||||
|
err1 := mappingTests(addrStr)
|
||||||
|
if err1 != nil {
|
||||||
|
NatMappingBehavior = "inconclusive"
|
||||||
|
log.Warn("NAT mapping behavior: inconclusive")
|
||||||
|
checkStatus = false
|
||||||
|
}
|
||||||
|
err2 := filteringTests(addrStr)
|
||||||
|
if err2 != nil {
|
||||||
|
NatFilteringBehavior = "inconclusive"
|
||||||
|
log.Warn("NAT filtering behavior: inconclusive")
|
||||||
|
checkStatus = false
|
||||||
|
}
|
||||||
|
if NatMappingBehavior == "inconclusive" || NatFilteringBehavior == "inconclusive" {
|
||||||
|
checkStatus = false
|
||||||
|
} else if NatMappingBehavior != "inconclusive" && NatFilteringBehavior != "inconclusive" {
|
||||||
|
checkStatus = true
|
||||||
|
}
|
||||||
|
if checkStatus {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// my changes start
|
// my changes start
|
||||||
if NatMappingBehavior != "" && NatFilteringBehavior != "" {
|
if NatMappingBehavior != "" && NatFilteringBehavior != "" {
|
||||||
if NatMappingBehavior == "inconclusive" || NatFilteringBehavior == "inconclusive" {
|
if NatMappingBehavior == "inconclusive" || NatFilteringBehavior == "inconclusive" {
|
||||||
|
Reference in New Issue
Block a user