Skip to content

Commit

Permalink
Merge pull request #923 from ripienaar/redacted_connected_url
Browse files Browse the repository at this point in the history
[ADDED] ConnectedUrlRedacted() that does not return the password
  • Loading branch information
kozlovic committed Mar 9, 2022
2 parents 2f2f696 + c024098 commit 8045a50
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions nats.go
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 8045a50

Please sign in to comment.