Skip to content

Commit

Permalink
Merge pull request #201 from stripe/jjiang/fix-logging-addrs
Browse files Browse the repository at this point in the history
Fix outbound IP logging
  • Loading branch information
jjiang-stripe authored Feb 15, 2024
2 parents 8c0fa26 + 24ee0c8 commit fbd1ea7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 10 deletions.
7 changes: 0 additions & 7 deletions pkg/smokescreen/conntrack/instrumented_conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const (
LogFieldDuration = "duration"
LogFieldError = "error"
LogFieldLastActivity = "last_activity"
LogFieldOutboundAddr = "outbound_remote_addr"
CanonicalProxyConnClose = "CANONICAL-PROXY-CN-CLOSE"
)

Expand Down Expand Up @@ -114,19 +113,13 @@ func (ic *InstrumentedConn) Close() error {
errorMessage = ic.ConnError.Error()
}

var outboundAddr string
if ic.RemoteAddr() != nil {
outboundAddr = ic.RemoteAddr().String()
}

ic.logger.WithFields(logrus.Fields{
LogFieldBytesIn: ic.BytesIn,
LogFieldBytesOut: ic.BytesOut,
LogFieldEndTime: end.UTC(),
LogFieldDuration: duration,
LogFieldError: errorMessage,
LogFieldLastActivity: time.Unix(0, atomic.LoadInt64(ic.LastActivity)).UTC(),
LogFieldOutboundAddr: outboundAddr,
}).Info(CanonicalProxyConnClose)

ic.tracker.Wg().Done()
Expand Down
3 changes: 0 additions & 3 deletions pkg/smokescreen/smokescreen.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,16 +303,13 @@ func dialContext(ctx context.Context, network, addr string) (net.Conn, error) {
sctx.cfg.ConnTracker.RecordAttempt(sctx.requestedHost, true)

if conn != nil {
fields := logrus.Fields{}

if addr := conn.LocalAddr(); addr != nil {
fields[LogFieldOutLocalAddr] = addr.String()
}

if addr := conn.RemoteAddr(); addr != nil {
fields[LogFieldOutRemoteAddr] = addr.String()
}

}
sctx.logger = sctx.logger.WithFields(fields)

Expand Down

0 comments on commit fbd1ea7

Please sign in to comment.