0
0
Fork 0
mirror of https://github.com/strukturag/nextcloud-spreed-signaling.git synced 2025-04-11 06:11:18 +00:00

nats: do not log url credentials

Signed-off-by: Adphi <philippe.adrien.nousse@gmail.com>
This commit is contained in:
Adphi 2025-01-28 13:31:55 +01:00
parent 76fa9abd33
commit 471469f1c8
No known key found for this signature in database
GPG key ID: 46BE4062DB2397FF

View file

@ -27,6 +27,7 @@ import (
"encoding/json"
"fmt"
"log"
"net/url"
"os"
"os/signal"
"strings"
@ -101,7 +102,7 @@ func NewNatsClient(url string) (NatsClient, error) {
client.conn, err = nats.Connect(url)
}
log.Printf("Connection established to %s (%s)", client.conn.ConnectedUrl(), client.conn.ConnectedServerId())
log.Printf("Connection established to %s (%s)", removeURLCredentials(client.conn.ConnectedUrl()), client.conn.ConnectedServerId())
return client, nil
}
@ -153,3 +154,11 @@ func (c *natsClient) Decode(msg *nats.Msg, vPtr interface{}) (err error) {
}
return
}
func removeURLCredentials(u string) string {
if u, err := url.Parse(u); err == nil && u.User != nil {
u.User = url.User("***")
return u.String()
}
return u
}