diff --git a/pkg/yurttunnel/constants/constants.go b/pkg/yurttunnel/constants/constants.go index 280c4246172..93d46a11706 100644 --- a/pkg/yurttunnel/constants/constants.go +++ b/pkg/yurttunnel/constants/constants.go @@ -62,6 +62,7 @@ const ( YurttunnelANPGrpcKeepAliveTimeSec = 10 // wait 5 seconds for the probe ack before cutting the connection YurttunnelANPGrpcKeepAliveTimeoutSec = 5 + UnixListenerNetwork = "unix" ) const ( HttpsPrfix = "https://" diff --git a/pkg/yurttunnel/server/anpserver.go b/pkg/yurttunnel/server/anpserver.go index a17a18af2e5..c46ad4a322a 100644 --- a/pkg/yurttunnel/server/anpserver.go +++ b/pkg/yurttunnel/server/anpserver.go @@ -117,7 +117,7 @@ func runProxier(handler http.Handler, Handler: handler, ReadTimeout: constants.YurttunnelANPProxierReadTimeoutSec * time.Second, } - unixListener, err := net.Listen("unix", udsSockFile) + unixListener, err := net.Listen(constants.UnixListenerNetwork, udsSockFile) if err != nil { klog.Errorf("proxier could not serving request through uds: %s", err) } diff --git a/pkg/yurttunnel/server/interceptor.go b/pkg/yurttunnel/server/interceptor.go index cc0a5a529af..ddabb468ad3 100644 --- a/pkg/yurttunnel/server/interceptor.go +++ b/pkg/yurttunnel/server/interceptor.go @@ -76,7 +76,7 @@ func NewRequestInterceptor(udsSockFile string, cfg *tls.Config) *RequestIntercep cfg.InsecureSkipVerify = true contextDialer := func(addr string, header http.Header, isTLS bool) (net.Conn, error) { klog.V(4).Infof("Sending request to %q.", addr) - proxyConn, err := net.Dial("unix", udsSockFile) + proxyConn, err := net.Dial(constants.UnixListenerNetwork, udsSockFile) if err != nil { return nil, fmt.Errorf("dialing proxy %q failed: %w", udsSockFile, err) }