From 15e81433899bb7c36c44e8e15af985b85b81b5ab Mon Sep 17 00:00:00 2001 From: Markus Graf Date: Wed, 25 Mar 2026 12:11:02 +0100 Subject: [PATCH] feat(01-01): install Go 1.24, initialize module, create shared types - Initialize Go module github.com/netsynth/netsynth with Go 1.24.1 - Create classify/types.go with 11 TrafficClass constants (ICMP, DNS, HTTPS, HTTP, SSH, SMTP, NTP, DHCP, other-TCP, other-UDP, unknown) - Add ClassifiedPacket and WindowSnapshot shared types - Add Phase 1 dependencies: gopacket v1.5.0, go-pcap, cobra v1.10.2 --- classify/types.go | 43 +++++++++++++++++++++++++++++++++++++++++++ go.mod | 14 ++++++++++++++ go.sum | 27 +++++++++++++++++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 classify/types.go create mode 100644 go.mod create mode 100644 go.sum diff --git a/classify/types.go b/classify/types.go new file mode 100644 index 0000000..f58dd3a --- /dev/null +++ b/classify/types.go @@ -0,0 +1,43 @@ +package classify + +// TrafficClass represents a classified network traffic category. +type TrafficClass string + +const ( + ClassICMP TrafficClass = "ICMP" + ClassDNS TrafficClass = "DNS" + ClassHTTPS TrafficClass = "HTTPS" + ClassHTTP TrafficClass = "HTTP" + ClassSSH TrafficClass = "SSH" + ClassSMTP TrafficClass = "SMTP" + ClassNTP TrafficClass = "NTP" + ClassDHCP TrafficClass = "DHCP" + ClassOtherTCP TrafficClass = "other-TCP" + ClassOtherUDP TrafficClass = "other-UDP" + ClassUnknown TrafficClass = "unknown" +) + +// AllClasses returns all known traffic classes in display order. +func AllClasses() []TrafficClass { + return []TrafficClass{ + ClassICMP, ClassDNS, ClassHTTPS, ClassHTTP, ClassSSH, + ClassSMTP, ClassNTP, ClassDHCP, ClassOtherTCP, ClassOtherUDP, ClassUnknown, + } +} + +// ClassifiedPacket pairs a raw packet's classification result with metadata. +type ClassifiedPacket struct { + Class TrafficClass + SrcPort uint16 + DstPort uint16 + Protocol string // "tcp", "udp", "icmp" + Length int +} + +// WindowSnapshot holds aggregated packet counts for a time window. +// This is the contract between the aggregation stage and future audio synthesis (Phase 2). +type WindowSnapshot struct { + Counts map[TrafficClass]int64 + TotalPackets int64 + WindowIndex int +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..d8fa6fc --- /dev/null +++ b/go.mod @@ -0,0 +1,14 @@ +module github.com/netsynth/netsynth + +go 1.24.1 + +require ( + github.com/gopacket/gopacket v1.5.0 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/packetcap/go-pcap v0.0.0-20251215121130-f2cf9f991e7c // indirect + github.com/sirupsen/logrus v1.9.3 // indirect + github.com/spf13/cobra v1.10.2 // indirect + github.com/spf13/pflag v1.0.9 // indirect + golang.org/x/net v0.39.0 // indirect + golang.org/x/sys v0.32.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..bfad154 --- /dev/null +++ b/go.sum @@ -0,0 +1,27 @@ +github.com/cpuguy83/go-md2man/v2 v2.0.6/go.mod h1:oOW0eioCTA6cOiMLiUPZOpcVxMig6NIQQ7OS05n1F4g= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/gopacket/gopacket v1.5.0 h1:9s9fcSUVKFlRV97B77Bq9XNV3ly2gvvsneFMQUGjc+M= +github.com/gopacket/gopacket v1.5.0/go.mod h1:i3NaGaqfoWKAr1+g7qxEdWsmfT+MXuWkAe9+THv8LME= +github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= +github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= +github.com/packetcap/go-pcap v0.0.0-20251215121130-f2cf9f991e7c h1:B5gWB1LB6OxpoXz+FsLUhQEcCAtMpajhBZ2K0X9KjfE= +github.com/packetcap/go-pcap v0.0.0-20251215121130-f2cf9f991e7c/go.mod h1:1jryUz9E2ndKwZBNHzVhLMzS3WHO0fOKydYi9XWWu9w= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/spf13/cobra v1.10.2 h1:DMTTonx5m65Ic0GOoRY2c16WCbHxOOw6xxezuLaBpcU= +github.com/spf13/cobra v1.10.2/go.mod h1:7C1pvHqHw5A4vrJfjNwvOdzYu0Gml16OCs2GRiTUUS4= +github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY= +github.com/spf13/pflag v1.0.9/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= +golang.org/x/net v0.39.0 h1:ZCu7HMWDxpXpaiKdhzIfaltL9Lp31x/3fCP11bc6/fY= +golang.org/x/net v0.39.0/go.mod h1:X7NRbYVEA+ewNkCNyJ513WmMdQ3BineSwVtN2zD/d+E= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.32.0 h1:s77OFDvIQeibCmezSnk/q6iAfkdiQaJi4VzroCFrN20= +golang.org/x/sys v0.32.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=