diff --git a/firewall/interception/interception_linux.go b/firewall/interception/interception_linux.go index 0021d9e3..aecbf6e2 100644 --- a/firewall/interception/interception_linux.go +++ b/firewall/interception/interception_linux.go @@ -2,10 +2,8 @@ package interception import "github.com/safing/portmaster/network/packet" -var ( - // Packets channel for feeding the firewall. - Packets = make(chan packet.Packet, 1000) -) +// Packets channel for feeding the firewall. +var Packets = make(chan packet.Packet, 1000) // Start starts the interception. func Start() error { diff --git a/firewall/interception/interception_windows.go b/firewall/interception/interception_windows.go index 3844022e..1a5d4e44 100644 --- a/firewall/interception/interception_windows.go +++ b/firewall/interception/interception_windows.go @@ -11,12 +11,8 @@ import ( "github.com/safing/portmaster/updates" ) -var Packets chan packet.Packet - -func init() { - // Packets channel for feeding the firewall. - Packets = make(chan packet.Packet, 1000) -} +// Packets channel for feeding the firewall. +var Packets = make(chan packet.Packet, 1000) // Start starts the interception. func Start() error { diff --git a/firewall/interception/windowskext/doc.go b/firewall/interception/windowskext/doc.go index dc37d6a3..c68a942f 100644 --- a/firewall/interception/windowskext/doc.go +++ b/firewall/interception/windowskext/doc.go @@ -1,4 +1,4 @@ // +build windows -// Package windowskext provides network interception capabilites on windows via the Portmaster Kernel Extension. +// Package windowskext provides network interception capabilities on windows via the Portmaster Kernel Extension. package windowskext diff --git a/firewall/interception/windowskext/handler.go b/firewall/interception/windowskext/handler.go index f33cf025..99ad9b59 100644 --- a/firewall/interception/windowskext/handler.go +++ b/firewall/interception/windowskext/handler.go @@ -14,20 +14,20 @@ import ( // VerdictRequest is the request structure from the Kext. type VerdictRequest struct { - id uint32 /* ID from RegisterPacket */ - processID uint64 /* Process ID. Nice to have*/ - direction uint8 - ipV6 uint8 /* True: IPv6, False: IPv4 */ - protocol uint8 /* Protocol */ - _ uint8 - localIP [4]uint32 /* Source Address */ - remoteIP [4]uint32 /* Destination Address */ - localPort uint16 /* Source Port */ - remotePort uint16 /* Destination port */ - compartmentID uint32 - interfaceIndex uint32 - subInterfaceIndex uint32 - packetSize uint32 + id uint32 // ID from RegisterPacket + _ uint64 // Process ID - does not yet work + direction uint8 + ipV6 uint8 // True: IPv6, False: IPv4 + protocol uint8 // Protocol + _ uint8 + localIP [4]uint32 // Source Address + remoteIP [4]uint32 // Destination Address + localPort uint16 // Source Port + remotePort uint16 // Destination port + _ uint32 // compartmentID + _ uint32 // interfaceIndex + _ uint32 // subInterfaceIndex + packetSize uint32 } // Handler transforms received packets to the Packet interface. diff --git a/firewall/interception/windowskext/test/main.go b/firewall/interception/windowskext/test/main.go index 0b3642c8..c36a4094 100644 --- a/firewall/interception/windowskext/test/main.go +++ b/firewall/interception/windowskext/test/main.go @@ -32,7 +32,7 @@ func main() { } // logging - log.Start() + _ = log.Start() log.Info("starting Portmaster Windows Kext Test Program") // init @@ -52,7 +52,7 @@ func main() { go handlePackets() // catch interrupt for clean shutdown - signalCh := make(chan os.Signal) + signalCh := make(chan os.Signal, 1) signal.Notify( signalCh, os.Interrupt, @@ -98,13 +98,19 @@ func handlePackets() { // reroute dns requests to nameserver if pkt.IsOutbound() && !pkt.Info().Src.Equal(pkt.Info().Dst) && pkt.Info().DstPort == 53 { log.Infof("rerouting %s", pkt) - pkt.RerouteToNameserver() + err = pkt.RerouteToNameserver() + if err != nil { + log.Errorf("failed to reroute: %s", err) + } continue } // accept all log.Infof("accepting %s", pkt) - pkt.PermanentAccept() + err = pkt.PermanentAccept() + if err != nil { + log.Errorf("failed to accept: %s", err) + } } }