Skip to content

Commit

Permalink
WebSocket-specific INFO (#4255)
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
derekcollison committed Jun 20, 2023
2 parents f7896b4 + afdc247 commit 04a79b9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions server/client.go
Expand Up @@ -2167,6 +2167,25 @@ func (c *client) generateClientInfoJSON(info Info) []byte {
info.MaxPayload = c.mpay
if c.isWebsocket() {
info.ClientConnectURLs = info.WSConnectURLs
if c.srv != nil { // Otherwise lame duck info can panic
c.srv.websocket.mu.RLock()
info.TLSAvailable = c.srv.websocket.tls
if c.srv.websocket.server != nil {
if tc := c.srv.websocket.server.TLSConfig; tc != nil {
info.TLSRequired = !tc.InsecureSkipVerify
}
}
if c.srv.websocket.listener != nil {
laddr := c.srv.websocket.listener.Addr().String()
if h, p, err := net.SplitHostPort(laddr); err == nil {
if p, err := strconv.Atoi(p); err == nil {
info.Host = h
info.Port = p
}
}
}
c.srv.websocket.mu.RUnlock()
}
}
info.WSConnectURLs = nil
// Generate the info json
Expand Down

0 comments on commit 04a79b9

Please sign in to comment.