Selaa lähdekoodia

Revert "move away from dns.Server.ListenAndServe"

This reverts commit f0a801142de0d46ddd112b9186ffeefe6b319a12.
Darien Raymond 7 vuotta sitten
vanhempi
commit
813fdb6235
1 muutettua tiedostoa jossa 10 lisäystä ja 21 poistoa
  1. 10 21
      app/dns/server_test.go

+ 10 - 21
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{