Switch connection state lookups to use the packet.Info struct

Also, rename the Direction attribute on packet.Info to Inbound
This commit is contained in:
Daniel
2020-05-18 17:08:32 +02:00
parent 0036d25672
commit 7649859ba6
10 changed files with 95 additions and 139 deletions

View File

@@ -62,7 +62,7 @@ func Handler(packets chan packet.Packet) {
}
info := new.Info()
info.Direction = packetInfo.direction > 0
info.Inbound = packetInfo.direction > 0
info.InTunnel = false
info.Protocol = packet.IPProtocol(packetInfo.protocol)
@@ -76,7 +76,7 @@ func Handler(packets chan packet.Packet) {
// IPs
if info.Version == packet.IPv4 {
// IPv4
if info.Direction {
if info.Inbound {
// Inbound
info.Src = convertIPv4(packetInfo.remoteIP)
info.Dst = convertIPv4(packetInfo.localIP)
@@ -87,7 +87,7 @@ func Handler(packets chan packet.Packet) {
}
} else {
// IPv6
if info.Direction {
if info.Inbound {
// Inbound
info.Src = convertIPv6(packetInfo.remoteIP)
info.Dst = convertIPv6(packetInfo.localIP)
@@ -99,7 +99,7 @@ func Handler(packets chan packet.Packet) {
}
// Ports
if info.Direction {
if info.Inbound {
// Inbound
info.SrcPort = packetInfo.remotePort
info.DstPort = packetInfo.localPort