feat: version 1.0.0 avec corrections critiques et nommage de packages
Ajout du point d'entrée principal : - cmd/ja4sentinel/main.go : pipeline complet avec gestion des signaux - Intégration des modules (capture, tlsparse, fingerprint, output) - Shutdown propre avec context.Context Corrections du parsing TLS : - Flow key unidirectionnel (client → serveur uniquement) - Timeout de flux configurable via FlowTimeoutSec - Structure ConnectionFlow simplifiée Améliorations de l'API : - Champs TCPMSS et TCPWScale en pointeurs (omitempty correct) - NewLogRecord mis à jour pour les champs optionnels Mise à jour de l'architecture : - architecture.yml : documentation des champs optionnels - Règles de flux unidirectionnel documentées Système de packages : - Version par défaut : 1.0.0 - Nommage cohérent : ja4sentinel_1.0.0_amd64.deb - Scripts build-deb.sh et build-rpm.sh simplifiés - Extraction correcte des checksums Tests : - TestFlowKey mis à jour pour le format unidirectionnel - Tous les tests passent (go test ./...) - go vet clean Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
@ -26,14 +26,15 @@ const (
|
||||
)
|
||||
|
||||
// ConnectionFlow tracks a single TCP flow for TLS handshake extraction
|
||||
// Only tracks incoming traffic from client to the local machine
|
||||
type ConnectionFlow struct {
|
||||
State ConnectionState
|
||||
CreatedAt time.Time
|
||||
LastSeen time.Time
|
||||
SrcIP string
|
||||
SrcPort uint16
|
||||
DstIP string
|
||||
DstPort uint16
|
||||
SrcIP string // Client IP
|
||||
SrcPort uint16 // Client port
|
||||
DstIP string // Server IP (local machine)
|
||||
DstPort uint16 // Server port (local machine)
|
||||
IPMeta api.IPMeta
|
||||
TCPMeta api.TCPMeta
|
||||
HelloBuffer []byte
|
||||
@ -66,7 +67,8 @@ func NewParserWithTimeout(timeout time.Duration) *ParserImpl {
|
||||
return p
|
||||
}
|
||||
|
||||
// flowKey generates a unique key for a TCP flow
|
||||
// flowKey generates a unique key for a TCP flow (client -> server only)
|
||||
// Only tracks incoming traffic from client to the local machine
|
||||
func flowKey(srcIP string, srcPort uint16, dstIP string, dstPort uint16) string {
|
||||
return fmt.Sprintf("%s:%d->%s:%d", srcIP, srcPort, dstIP, dstPort)
|
||||
}
|
||||
@ -234,6 +236,7 @@ func (p *ParserImpl) Process(pkt api.RawPacket) (*api.TLSClientHello, error) {
|
||||
}
|
||||
|
||||
// getOrCreateFlow gets existing flow or creates a new one
|
||||
// Only tracks incoming traffic from client to the local machine
|
||||
func (p *ParserImpl) getOrCreateFlow(key string, srcIP string, srcPort uint16, dstIP string, dstPort uint16, ipMeta api.IPMeta, tcpMeta api.TCPMeta) *ConnectionFlow {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
@ -247,10 +250,10 @@ func (p *ParserImpl) getOrCreateFlow(key string, srcIP string, srcPort uint16, d
|
||||
State: NEW,
|
||||
CreatedAt: time.Now(),
|
||||
LastSeen: time.Now(),
|
||||
SrcIP: srcIP,
|
||||
SrcPort: srcPort,
|
||||
DstIP: dstIP,
|
||||
DstPort: dstPort,
|
||||
SrcIP: srcIP, // Client IP
|
||||
SrcPort: srcPort, // Client port
|
||||
DstIP: dstIP, // Server IP (local machine)
|
||||
DstPort: dstPort, // Server port (local machine)
|
||||
IPMeta: ipMeta,
|
||||
TCPMeta: tcpMeta,
|
||||
HelloBuffer: make([]byte, 0),
|
||||
|
||||
@ -223,6 +223,7 @@ func TestParserClose(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestFlowKey(t *testing.T) {
|
||||
// Test unidirectional flow key (client -> server only)
|
||||
key := flowKey("192.168.1.1", 12345, "10.0.0.1", 443)
|
||||
expected := "192.168.1.1:12345->10.0.0.1:443"
|
||||
if key != expected {
|
||||
|
||||
Reference in New Issue
Block a user