[WIP] Updater support for windows

This commit is contained in:
Vladimir Stoilov
2024-09-11 18:52:36 +03:00
parent 8c6eb04292
commit 83ec18f552
11 changed files with 371 additions and 115 deletions

View File

@@ -10,14 +10,13 @@ import (
"github.com/safing/portmaster/service/mgr"
"github.com/safing/portmaster/service/network"
"github.com/safing/portmaster/service/network/packet"
"github.com/safing/portmaster/service/updates"
)
var useOldKext = false
// start starts the interception.
func startInterception(packets chan packet.Packet) error {
kextFile, err := updates.GetPlatformFile("kext/portmaster-kext.sys")
kextFile, err := module.instance.BinaryUpdates().GetFile("portmaster-kext.sys")
if err != nil {
return fmt.Errorf("interception: could not get kext sys: %s", err)
}
@@ -77,7 +76,6 @@ func startInterception(packets chan packet.Packet) error {
case <-w.Done():
return nil
}
}
})
@@ -95,7 +93,6 @@ func startInterception(packets chan packet.Packet) error {
case <-w.Done():
return nil
}
}
})
@@ -112,7 +109,6 @@ func startInterception(packets chan packet.Packet) error {
case <-w.Done():
return nil
}
}
})
}
@@ -159,5 +155,4 @@ func GetKextVersion() (string, error) {
}
return version.String(), nil
}
}

View File

@@ -8,6 +8,7 @@ import (
"github.com/safing/portmaster/base/log"
"github.com/safing/portmaster/service/mgr"
"github.com/safing/portmaster/service/network/packet"
"github.com/safing/portmaster/service/updates"
)
// Interception is the packet interception module.
@@ -97,4 +98,6 @@ func New(instance instance) (*Interception, error) {
return module, nil
}
type instance interface{}
type instance interface {
BinaryUpdates() *updates.Updates
}

View File

@@ -62,6 +62,9 @@ func GetKextServiceHandle() windows.Handle {
// Stop intercepting.
func Stop() error {
if kextFile == nil {
return fmt.Errorf("kextfile is nil")
}
// Prepare kernel for shutdown
err := shutdownRequest()
if err != nil {