Skip to content

Commit e0c965f

Browse files
committed
refactor: pull listener addresses from listener and remove redundant struct field for tls address
1 parent 85c6702 commit e0c965f

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

common/listener.go

+10-12
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ import (
1717

1818
// Listener represents an HTTP listener.
1919
type Listener struct {
20-
URL *url.URL
21-
protocol string
22-
localAddress string
23-
tlsLocalAddress string
24-
endpoints []string
25-
active bool
26-
listener net.Listener
27-
tlsListener net.Listener
28-
mux *http.ServeMux
20+
URL *url.URL
21+
protocol string
22+
localAddress string
23+
endpoints []string
24+
active bool
25+
listener net.Listener
26+
tlsListener net.Listener
27+
mux *http.ServeMux
2928
}
3029

3130
// NewListener creates a new Listener.
@@ -56,7 +55,6 @@ func (l *Listener) StartTLS(errChan chan<- error, tlsConfig *tls.Config, address
5655
}
5756

5857
l.tlsListener = list
59-
l.tlsLocalAddress = address
6058
log.Printf("[Listener] Started listening on tls endpoint %s.", address)
6159

6260
// Launch goroutine for servicing https requests
@@ -102,15 +100,15 @@ func (l *Listener) Stop() {
102100
if l.tlsListener != nil {
103101
// Stop servicing requests on secure listener
104102
_ = l.tlsListener.Close()
105-
log.Printf("[Listener] Stopped listening on tls endpoint %s", l.tlsLocalAddress)
103+
log.Printf("[Listener] Stopped listening on tls endpoint %s", l.tlsListener.Addr())
106104
}
107105

108106
// Delete the unix socket.
109107
if l.protocol == "unix" {
110108
_ = os.Remove(l.localAddress)
111109
}
112110

113-
log.Printf("[Listener] Stopped listening on %s", l.localAddress)
111+
log.Printf("[Listener] Stopped listening on %s", l.listener.Addr())
114112
}
115113

116114
// GetMux returns the HTTP mux for the listener.

0 commit comments

Comments
 (0)