mirror of
https://github.com/safing/portmaster
synced 2025-04-16 17:09:09 +00:00
[service] Minor windows kext improvments
This commit is contained in:
parent
5459c1ccb2
commit
6f9b0a8249
2 changed files with 23 additions and 33 deletions
service/firewall/interception
|
@ -66,19 +66,16 @@ func startInterception(packets chan packet.Packet) error {
|
||||||
// Start bandwidth stats monitor.
|
// Start bandwidth stats monitor.
|
||||||
module.StartServiceWorker("kext bandwidth request worker", 0, func(ctx context.Context) error {
|
module.StartServiceWorker("kext bandwidth request worker", 0, func(ctx context.Context) error {
|
||||||
timer := time.NewTicker(1 * time.Second)
|
timer := time.NewTicker(1 * time.Second)
|
||||||
|
defer timer.Stop()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
{
|
err := kext2.SendBandwidthStatsRequest()
|
||||||
err := kext2.SendBandwidthStatsRequest()
|
if err != nil {
|
||||||
if err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
{
|
return nil
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -87,19 +84,16 @@ func startInterception(packets chan packet.Packet) error {
|
||||||
// Start kext logging. The worker will periodically send request to the kext to send logs.
|
// Start kext logging. The worker will periodically send request to the kext to send logs.
|
||||||
module.StartServiceWorker("kext log request worker", 0, func(ctx context.Context) error {
|
module.StartServiceWorker("kext log request worker", 0, func(ctx context.Context) error {
|
||||||
timer := time.NewTicker(1 * time.Second)
|
timer := time.NewTicker(1 * time.Second)
|
||||||
|
defer timer.Stop()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
{
|
err := kext2.SendLogRequest()
|
||||||
err := kext2.SendLogRequest()
|
if err != nil {
|
||||||
if err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
{
|
return nil
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -107,19 +101,16 @@ func startInterception(packets chan packet.Packet) error {
|
||||||
|
|
||||||
module.StartServiceWorker("kext clean ended connection worker", 0, func(ctx context.Context) error {
|
module.StartServiceWorker("kext clean ended connection worker", 0, func(ctx context.Context) error {
|
||||||
timer := time.NewTicker(30 * time.Second)
|
timer := time.NewTicker(30 * time.Second)
|
||||||
|
defer timer.Stop()
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-timer.C:
|
case <-timer.C:
|
||||||
{
|
err := kext2.SendCleanEndedConnection()
|
||||||
err := kext2.SendCleanEndedConnection()
|
if err != nil {
|
||||||
if err != nil {
|
return err
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
{
|
return nil
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,16 +40,15 @@ func Handler(ctx context.Context, packets chan packet.Packet, bandwidthUpdate ch
|
||||||
switch {
|
switch {
|
||||||
case packetInfo.ConnectionV4 != nil:
|
case packetInfo.ConnectionV4 != nil:
|
||||||
{
|
{
|
||||||
log.Tracef("packet: %+v", packetInfo.ConnectionV4)
|
// log.Tracef("packet: %+v", packetInfo.ConnectionV4)
|
||||||
conn := packetInfo.ConnectionV4
|
conn := packetInfo.ConnectionV4
|
||||||
// New Packet
|
// New Packet
|
||||||
new := &Packet{
|
newPacket := &Packet{
|
||||||
verdictRequest: conn.Id,
|
verdictRequest: conn.Id,
|
||||||
payload: conn.Payload,
|
payload: conn.Payload,
|
||||||
verdictSet: abool.NewBool(false),
|
verdictSet: abool.NewBool(false),
|
||||||
}
|
}
|
||||||
new.Base.Payload()
|
info := newPacket.Info()
|
||||||
info := new.Info()
|
|
||||||
info.Inbound = conn.Direction > 0
|
info.Inbound = conn.Direction > 0
|
||||||
info.InTunnel = false
|
info.InTunnel = false
|
||||||
info.Protocol = packet.IPProtocol(conn.Protocol)
|
info.Protocol = packet.IPProtocol(conn.Protocol)
|
||||||
|
@ -88,19 +87,19 @@ func Handler(ctx context.Context, packets chan packet.Packet, bandwidthUpdate ch
|
||||||
info.DstPort = conn.RemotePort
|
info.DstPort = conn.RemotePort
|
||||||
}
|
}
|
||||||
|
|
||||||
packets <- new
|
packets <- newPacket
|
||||||
}
|
}
|
||||||
case packetInfo.ConnectionV6 != nil:
|
case packetInfo.ConnectionV6 != nil:
|
||||||
{
|
{
|
||||||
log.Tracef("packet: %+v", packetInfo.ConnectionV6)
|
// log.Tracef("packet: %+v", packetInfo.ConnectionV6)
|
||||||
conn := packetInfo.ConnectionV6
|
conn := packetInfo.ConnectionV6
|
||||||
// New Packet
|
// New Packet
|
||||||
new := &Packet{
|
newPacket := &Packet{
|
||||||
verdictRequest: conn.Id,
|
verdictRequest: conn.Id,
|
||||||
payload: conn.Payload,
|
payload: conn.Payload,
|
||||||
verdictSet: abool.NewBool(false),
|
verdictSet: abool.NewBool(false),
|
||||||
}
|
}
|
||||||
info := new.Info()
|
info := newPacket.Info()
|
||||||
info.Inbound = conn.Direction > 0
|
info.Inbound = conn.Direction > 0
|
||||||
info.InTunnel = false
|
info.InTunnel = false
|
||||||
info.Protocol = packet.IPProtocol(conn.Protocol)
|
info.Protocol = packet.IPProtocol(conn.Protocol)
|
||||||
|
@ -139,7 +138,7 @@ func Handler(ctx context.Context, packets chan packet.Packet, bandwidthUpdate ch
|
||||||
info.DstPort = conn.RemotePort
|
info.DstPort = conn.RemotePort
|
||||||
}
|
}
|
||||||
|
|
||||||
packets <- new
|
packets <- newPacket
|
||||||
}
|
}
|
||||||
case packetInfo.LogLine != nil:
|
case packetInfo.LogLine != nil:
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue