修订代码

This commit is contained in:
hahahrfool
2022-04-10 08:52:40 +08:00
parent 651bd12e72
commit 50de20ce12
8 changed files with 59 additions and 52 deletions

View File

@@ -1,7 +1,28 @@
package netLayer
import "testing"
import (
"net"
"testing"
"time"
"github.com/hahahrfool/v2ray_simple/utils"
)
func TestIpv6(t *testing.T) {
t.Log("HasIpv6Interface()", HasIpv6Interface())
}
func TestUDP(t *testing.T) {
//测试setdeadline的情况. 实测证明 SetReadDeadline 在Read过程中也可以使用 这样就可以防止阻塞
laddr, _ := net.ResolveUDPAddr("udp", ":"+RandPortStr())
udpConn, _ := net.ListenUDP("udp", laddr)
go func() {
time.Sleep(time.Second)
udpConn.SetReadDeadline(time.Now())
}()
udpConn.ReadFrom(utils.GetPacket())
t.Log("ok")
}