[FIXED] Monitoring: tls configuration not updated on reload

When creating the http server, we need to provide a TLS configuration.
After a config reload, the new TLS config would not be reflected.

We had the same issue with Websocket and was fixed with the use
of tls.Config.GetConfigForClient API, which makes the TLS handshake
to ask for a TLS config. That fix for websocket was simply not applied
to the HTTPs monitoring case.

I have also fixed some flappers due to the use of localhost instead
of 127.0.0.1 (connections possibly would resolve to some IPv6 address
that the server would not accept, etc..)

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
Ivan Kozlovic
2021-11-30 10:12:54 -07:00
parent df581337ea
commit 40c0f03153
7 changed files with 105 additions and 31 deletions

View File

@@ -1112,7 +1112,7 @@ func (s *Server) startWebsocketServer() {
Addr: hp,
Handler: mux,
ReadTimeout: o.HandshakeTimeout,
ErrorLog: log.New(&wsCaptureHTTPServerLog{s}, _EMPTY_, 0),
ErrorLog: log.New(&captureHTTPServerLog{s, "websocket: "}, _EMPTY_, 0),
}
s.websocket.server = hs
s.websocket.listener = hl
@@ -1239,24 +1239,6 @@ func (s *Server) createWSClient(conn net.Conn, ws *websocket) *client {
return c
}
type wsCaptureHTTPServerLog struct {
s *Server
}
func (cl *wsCaptureHTTPServerLog) Write(p []byte) (int, error) {
var buf [128]byte
var b = buf[:0]
copy(b, []byte("websocket :"))
offset := 0
if bytes.HasPrefix(p, []byte("http:")) {
offset = 6
}
b = append(b, p[offset:]...)
cl.s.Errorf(string(b))
return len(p), nil
}
func (c *client) wsCollapsePtoNB() (net.Buffers, int64) {
var nb net.Buffers
var mfs int