diff --git a/api/types.go b/api/types.go index 7ae85bc..d455903 100644 --- a/api/types.go +++ b/api/types.go @@ -1,5 +1,7 @@ package api +import "time" + // ServiceLog represents internal service logging for diagnostics type ServiceLog struct { Level string `json:"level"` @@ -85,6 +87,9 @@ type LogRecord struct { JA4Hash string `json:"ja4_hash"` JA3 string `json:"ja3,omitempty"` JA3Hash string `json:"ja3_hash,omitempty"` + + // Timestamp in nanoseconds since Unix epoch + Timestamp int64 `json:"timestamp"` } // OutputConfig defines configuration for a single log output @@ -212,6 +217,7 @@ func NewLogRecord(ch TLSClientHello, fp *Fingerprints) LogRecord { TCPMSS: mssPtr, TCPWScale: wScalePtr, TCPOptions: opts, + Timestamp: time.Now().UnixNano(), } if fp != nil { diff --git a/api/types_test.go b/api/types_test.go index fc3e7c3..25d4b98 100644 --- a/api/types_test.go +++ b/api/types_test.go @@ -91,6 +91,11 @@ func TestNewLogRecord(t *testing.T) { t.Run(tt.name, func(t *testing.T) { rec := NewLogRecord(tt.clientHello, tt.fingerprints) + // Verify timestamp is set + if rec.Timestamp == 0 { + t.Error("Timestamp should be set") + } + // Verify basic fields if rec.SrcIP != tt.clientHello.SrcIP { t.Errorf("SrcIP = %v, want %v", rec.SrcIP, tt.clientHello.SrcIP)