Files
ja4sentinel/api/types.go
Jacquin Antoine 34f6fff125 feat: Ajouter les types API pour ja4sentinel avec structures de données complètes
Co-authored-by: aider (openrouter/qwen/qwen3-coder-plus) <aider@aider.chat>
2026-02-25 04:11:52 +01:00

102 lines
3.0 KiB
Go

package api
// ServiceLog représente un log interne du service ja4sentinel (diagnostic).
type ServiceLog struct {
Level string `json:"level"`
Component string `json:"component"`
Message string `json:"message"`
Details map[string]string `json:"details,omitempty"`
}
// Config contient la configuration réseau et TLS de base.
type Config struct {
Interface string `json:"interface"`
ListenPorts []uint16 `json:"listen_ports"`
BPFFilter string `json:"bpf_filter"`
}
// IPMeta contient les métadonnées IP pour fingerprinting de stack.
type IPMeta struct {
TTL uint8 `json:"ttl"`
TotalLength uint16 `json:"total_length"`
IPID uint16 `json:"id"`
DF bool `json:"df"`
}
// TCPMeta contient les métadonnées TCP pour fingerprinting de stack.
type TCPMeta struct {
WindowSize uint16 `json:"window_size"`
MSS uint16 `json:"mss"`
WindowScale uint8 `json:"window_scale"`
Options []string `json:"options"`
}
// RawPacket représente un paquet brut capturé sur le réseau.
type RawPacket struct {
Data []byte `json:"data"`
Timestamp int64 `json:"timestamp"`
}
// TLSClientHello représente un ClientHello TLS client, avec meta IP/TCP.
type TLSClientHello struct {
SrcIP string `json:"src_ip"`
SrcPort uint16 `json:"src_port"`
DstIP string `json:"dst_ip"`
DstPort uint16 `json:"dst_port"`
Payload []byte `json:"payload"`
IPMeta IPMeta `json:"ip_meta"`
TCPMeta TCPMeta `json:"tcp_meta"`
}
// Fingerprints contient les empreintes TLS pour un flux client.
type Fingerprints struct {
JA4 string `json:"ja4"`
JA4Hash string `json:"ja4_hash"`
JA3 string `json:"ja3,omitempty"`
JA3Hash string `json:"ja3_hash,omitempty"`
}
// LogRecord est un enregistrement de log final, sérialisé en JSON objet plat.
type LogRecord struct {
// Adresse IP source (client)
SrcIP string `json:"src_ip"`
// Port source (client)
SrcPort uint16 `json:"src_port"`
// Adresse IP destination (serveur)
DstIP string `json:"dst_ip"`
// Port destination (serveur)
DstPort uint16 `json:"dst_port"`
// Métadonnées IP (flatten)
IPTTL uint8 `json:"ip_meta_ttl"`
IPTotalLen uint16 `json:"ip_meta_total_length"`
IPID uint16 `json:"ip_meta_id"`
IPDF bool `json:"ip_meta_df"`
// Métadonnées TCP (flatten)
TCPWindow uint16 `json:"tcp_meta_window_size"`
TCPMSS uint16 `json:"tcp_meta_mss"`
TCPWScale uint8 `json:"tcp_meta_window_scale"`
TCPOptions string `json:"tcp_meta_options"`
// Empreintes
JA4 string `json:"ja4"`
JA4Hash string `json:"ja4_hash"`
JA3 string `json:"ja3,omitempty"`
JA3Hash string `json:"ja3_hash,omitempty"`
}
// OutputConfig configure une sortie de logs.
type OutputConfig struct {
Type string `json:"type"`
Enabled bool `json:"enabled"`
Params map[string]string `json:"params"`
}
// AppConfig est la configuration complète de ja4sentinel.
type AppConfig struct {
Core Config `json:"core"`
Outputs []OutputConfig `json:"outputs"`
}