Skip to content

Commit

Permalink
WebSocket-specific INFO
Browse files Browse the repository at this point in the history
This fixes #4252 by ensuring that `tls_available`, `tls_required`, `host` and `port`
are populated based on the WebSocket listener rather than standard listeners.

Signed-off-by: Neil Twigg <neil@nats.io>
  • Loading branch information
neilalexander committed Jun 20, 2023
1 parent f7896b4 commit 3947b01
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions server/client.go
Expand Up @@ -2167,6 +2167,19 @@ func (c *client) generateClientInfoJSON(info Info) []byte {
info.MaxPayload = c.mpay
if c.isWebsocket() {
info.ClientConnectURLs = info.WSConnectURLs
c.srv.websocket.mu.RLock()
info.TLSAvailable = c.srv.websocket.tls
if tc := c.srv.websocket.server.TLSConfig; tc != nil {
info.TLSRequired = !tc.InsecureSkipVerify
}
laddr := c.srv.websocket.listener.Addr().String()
c.srv.websocket.mu.RUnlock()
if h, p, err := net.SplitHostPort(laddr); err == nil {
if p, err := strconv.Atoi(p); err == nil {
info.Host = h
info.Port = p
}
}
}
info.WSConnectURLs = nil
// Generate the info json
Expand Down

0 comments on commit 3947b01

Please sign in to comment.