Update nat.go

This commit is contained in:
W192547975
2023-08-10 11:13:54 +08:00
committed by GitHub
parent c635bd7ae6
commit 6af3f2fa7b

View File

@@ -113,7 +113,6 @@ func getNATType(host string, udp1 int, udp2 int) (publicIP string, NATType int,
func publicIPTest(publicIP string, echoPort int) (hasPublicIP int, hasUPNPorNATPMP int) {
var echoConn *net.UDPConn
//This piece is in another goroutine in the old code! Please check the update diary.
gLog.Println(LvDEBUG, "echo server start")
var err error
echoConn, err = net.ListenUDP("udp", &net.UDPAddr{IP: net.IPv4zero, Port: echoPort})
@@ -125,7 +124,6 @@ func publicIPTest(publicIP string, echoPort int) (hasPublicIP int, hasUPNPorNATP
go func() {
// close outside for breaking the ReadFromUDP
// wait 5s(30s?) for echo testing
gLog.Println(LvDEBUG, "the own goroutine of echo server run")
buf := make([]byte, 1600)
echoConn.SetReadDeadline(time.Now().Add(time.Second * 30))
n, addr, err := echoConn.ReadFromUDP(buf)