Skip to content

Commit

Permalink
adds a redacted version of ConnectedUrl()
Browse files Browse the repository at this point in the history
Signed-off-by: R.I.Pienaar <rip@devco.net>
  • Loading branch information
ripienaar committed Mar 9, 2022
1 parent 2f2f696 commit c024098
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -1803,6 +1803,21 @@ func (nc *Conn) ConnectedUrl() string {
return nc.current.url.String()
}

// ConnectedUrlRedacted reports the connected server's URL with passwords redacted
func (nc *Conn) ConnectedUrlRedacted() string {
if nc == nil {
return _EMPTY_
}

nc.mu.RLock()
defer nc.mu.RUnlock()

if nc.status != CONNECTED {
return _EMPTY_
}
return nc.current.url.Redacted()
}

// ConnectedAddr returns the connected server's IP
func (nc *Conn) ConnectedAddr() string {
if nc == nil {
Expand Down

0 comments on commit c024098

Please sign in to comment.