From 96d0c3d82932089a791ee428c77363a616d66f1b Mon Sep 17 00:00:00 2001 From: Leo Balduf Date: Sun, 16 Sep 2018 22:35:21 +0200 Subject: [PATCH] frontend/udp: debug log connection ID generation/validation --- frontend/udp/connection_id.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/frontend/udp/connection_id.go b/frontend/udp/connection_id.go index 5436c77..3753371 100644 --- a/frontend/udp/connection_id.go +++ b/frontend/udp/connection_id.go @@ -6,7 +6,9 @@ import ( "net" "time" - sha256 "github.com/minio/sha256-simd" + "github.com/minio/sha256-simd" + + "github.com/chihaya/chihaya/pkg/log" ) // ttl is the number of seconds a connection ID should be valid according to @@ -33,12 +35,14 @@ func NewConnectionID(ip net.IP, now time.Time, key string) []byte { macBytes := mac.Sum(nil)[:4] copy(buf[4:], macBytes) + log.Debug("generated connection ID", log.Fields{"ip": ip, "now": now, "key": key, "connID": buf}) return buf } // ValidConnectionID determines whether a connection identifier is legitimate. func ValidConnectionID(connectionID []byte, ip net.IP, now time.Time, maxClockSkew time.Duration, key string) bool { ts := time.Unix(int64(binary.BigEndian.Uint32(connectionID[:4])), 0) + log.Debug("validating connection ID", log.Fields{"connID": connectionID, "ip": ip, "ts": ts, "now": now, "key": key}) if now.After(ts.Add(ttl)) || ts.After(now.Add(maxClockSkew)) { return false }