diff --git a/app/dns/server_test.go b/app/dns/server_test.go index 3a055b47f..bf31ce544 100644 --- a/app/dns/server_test.go +++ b/app/dns/server_test.go @@ -10,7 +10,6 @@ import ( "v2ray.com/core/app/policy" "v2ray.com/core/app/proxyman" _ "v2ray.com/core/app/proxyman/outbound" - "v2ray.com/core/common" "v2ray.com/core/common/net" "v2ray.com/core/common/serial" "v2ray.com/core/proxy/freedom" @@ -43,19 +42,14 @@ func TestUDPServer(t *testing.T) { port := udp.PickPort() - listener, err := net.ListenUDP("udp4", &net.UDPAddr{ - IP: net.IP{127, 0, 0, 1}, - Port: int(port), - }) - common.Must(err) - dnsServer := dns.Server{ - PacketConn: listener, - Handler: &staticHandler{}, - UDPSize: 1200, + Addr: "127.0.0.1:" + port.String(), + Net: "udp", + Handler: &staticHandler{}, + UDPSize: 1200, } - go dnsServer.ActivateAndServe() + go dnsServer.ListenAndServe() time.Sleep(time.Second) config := &core.Config{ @@ -112,19 +106,14 @@ func TestPrioritizedDomain(t *testing.T) { port := udp.PickPort() - listener, err := net.ListenUDP("udp4", &net.UDPAddr{ - IP: net.IP{127, 0, 0, 1}, - Port: int(port), - }) - common.Must(err) - dnsServer := dns.Server{ - PacketConn: listener, - Handler: &staticHandler{}, - UDPSize: 1200, + Addr: "127.0.0.1:" + port.String(), + Net: "udp", + Handler: &staticHandler{}, + UDPSize: 1200, } - go dnsServer.ActivateAndServe() + go dnsServer.ListenAndServe() time.Sleep(time.Second) config := &core.Config{