mirror of
https://github.com/oneclickvirt/gostun.git
synced 2025-10-28 09:31:38 +08:00
v0.0.2 - 进一步解耦
This commit is contained in:
31
stuncheck/checktype.go
Normal file
31
stuncheck/checktype.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package stuncheck
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/oneclickvirt/gostun/model"
|
||||
)
|
||||
|
||||
// CheckType
|
||||
// Summarize the NAT type
|
||||
func CheckType() string {
|
||||
var result string
|
||||
if model.NatMappingBehavior != "" && model.NatFilteringBehavior != "" {
|
||||
if model.NatMappingBehavior == "inconclusive" || model.NatFilteringBehavior == "inconclusive" {
|
||||
result = "Inconclusive"
|
||||
} else if model.NatMappingBehavior == "endpoint independent" && model.NatFilteringBehavior == "endpoint independent" {
|
||||
result = "Full Cone"
|
||||
} else if model.NatMappingBehavior == "endpoint independent" && model.NatFilteringBehavior == "address dependent" {
|
||||
result = "Restricted Cone"
|
||||
} else if model.NatMappingBehavior == "endpoint independent" && model.NatFilteringBehavior == "address and port dependent" {
|
||||
result = "Port Restricted Cone"
|
||||
} else if model.NatMappingBehavior == "address and port dependent" && model.NatFilteringBehavior == "address and port dependent" {
|
||||
result = "Symmetric"
|
||||
} else {
|
||||
result = fmt.Sprintf("%v[NatMappingBehavior] %v[NatFilteringBehavior]\n", model.NatMappingBehavior, model.NatFilteringBehavior)
|
||||
}
|
||||
} else {
|
||||
result = "Inconclusive"
|
||||
}
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user