Fix windowskext linter errors

This commit is contained in:
Daniel
2020-04-10 13:18:37 +02:00
parent ddc01e648f
commit fd4f059ebb
5 changed files with 29 additions and 29 deletions

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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

View File

@@ -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.

View File

@@ -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)
}
}
}