Skip to content

Commit

Permalink
replace string var by const (openyurtio#1839)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsy3502 authored and zyjhtangtang committed Apr 16, 2024
1 parent 92657ad commit 60087ba
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/yurttunnel/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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://"
Expand Down
2 changes: 1 addition & 1 deletion pkg/yurttunnel/server/anpserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/yurttunnel/server/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 60087ba

Please sign in to comment.