Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use utc time in logs to avoid user location getting disclosed #1192

Merged
merged 1 commit into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ examples/basic-relay/build/basic-relay
examples/filter2/build/filter2
examples/noise/build/
examples/noise/noise
examples/basic-light-client/basic2
examples/basic-relay/basic2
examples/filter2/filter2
examples/rln/rln

# Test binary, built with `go test -c`
*.test
Expand Down
4 changes: 4 additions & 0 deletions logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,7 @@ func Uint64(key string, value uint64) zap.Field {
valueStr := fmt.Sprintf("%v", value)
return zap.String(key, valueStr)
}

func UTCTime(key string, t time.Time) zap.Field {
return zap.Time(key, t.UTC())
}
6 changes: 3 additions & 3 deletions waku/v2/peermanager/peer_connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@ func (c *PeerConnectionStrategy) canDialPeer(pi peer.AddrInfo) bool {
now := time.Now()
if now.Before(tv.nextTry) {
c.logger.Debug("Skipping connecting to peer due to backoff strategy",
zap.Time("currentTime", now), zap.Time("until", tv.nextTry))
logging.UTCTime("currentTime", now), logging.UTCTime("until", tv.nextTry))
return false
}
c.logger.Debug("Proceeding with connecting to peer",
zap.Time("currentTime", now), zap.Time("nextTry", tv.nextTry))
logging.UTCTime("currentTime", now), logging.UTCTime("nextTry", tv.nextTry))
}
return true
}
Expand All @@ -228,7 +228,7 @@ func (c *PeerConnectionStrategy) addConnectionBackoff(peerID peer.ID) {
cachedPeer = &connCacheData{strat: c.backoff()}
cachedPeer.nextTry = time.Now().Add(cachedPeer.strat.Delay())
c.logger.Debug("Initializing connectionCache for peer ",
logging.HostID("peerID", peerID), zap.Time("until", cachedPeer.nextTry))
logging.HostID("peerID", peerID), logging.UTCTime("until", cachedPeer.nextTry))
c.cache.Add(peerID, cachedPeer)
}
}
Expand Down
Loading