Explorar el Código

UDP listener: Allow listening on "localhost" (#4940)

Fixes https://github.com/XTLS/Xray-core/issues/4939
风扇滑翔翼 hace 6 meses
padre
commit
1ea00fad81
Se han modificado 1 ficheros con 8 adiciones y 0 borrados
  1. 8 0
      transport/internet/udp/hub.go

+ 8 - 0
transport/internet/udp/hub.go

@@ -40,6 +40,14 @@ func ListenUDP(ctx context.Context, address net.Address, port net.Port, streamSe
 		opt(hub)
 	}
 
+	if address.Family().IsDomain() && address.Domain() == "localhost" {
+		address = net.LocalHostIP
+	}
+
+	if address.Family().IsDomain() {
+		return nil, errors.New("domain address is not allowed for listening: ", address.Domain())
+	}
+
 	var sockopt *internet.SocketConfig
 	if streamSettings != nil {
 		sockopt = streamSettings.SocketSettings