Merge pull request #107 from safing/feature/building-on-unsupported-platforms

Enable building on unsupported systems
This commit is contained in:
Daniel 2020-07-22 11:59:53 +02:00 committed by GitHub
commit 7aa039a331
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 62 additions and 32 deletions

View file

@ -1,3 +1,5 @@
//+build !windows,!linux
package netenv
import "net"

View file

@ -0,0 +1,43 @@
// +build !windows,!linux
package state
import (
"time"
"github.com/safing/portbase/config"
"github.com/safing/portmaster/network/socket"
)
func init() {
// This increases performance on unsupported system.
// It's not critical at all and does not break anything if it fails.
go func() {
// Wait for one minute before we set the default value, as we
// currently cannot easily integrate into the startup procedure.
time.Sleep(1 * time.Minute)
// We cannot use process.CfgOptionEnableProcessDetectionKey, because of an import loop.
config.SetDefaultConfigOption("core/enableProcessDetection", false)
}()
}
func getTCP4Table() (connections []*socket.ConnectionInfo, listeners []*socket.BindInfo, err error) {
return nil, nil, nil
}
func getTCP6Table() (connections []*socket.ConnectionInfo, listeners []*socket.BindInfo, err error) {
return nil, nil, nil
}
func getUDP4Table() (binds []*socket.BindInfo, err error) {
return nil, nil
}
func getUDP6Table() (binds []*socket.BindInfo, err error) {
return nil, nil
}
func checkPID(socketInfo socket.Info, connInbound bool) (pid int, inbound bool, err error) {
return socketInfo.GetPID(), connInbound, nil
}

View file

@ -70,11 +70,13 @@ function build {
function check_all {
GOOS=linux GOARCH=amd64 check
GOOS=windows GOARCH=amd64 check
GOOS=darwin GOARCH=amd64 check
}
function build_all {
GOOS=linux GOARCH=amd64 build
GOOS=windows GOARCH=amd64 build
GOOS=darwin GOARCH=amd64 build
}
case $1 in

View file

@ -70,11 +70,13 @@ function build {
function check_all {
GOOS=linux GOARCH=amd64 check
GOOS=windows GOARCH=amd64 check
GOOS=darwin GOARCH=amd64 check
}
function build_all {
GOOS=linux GOARCH=amd64 build
GOOS=windows GOARCH=amd64 build
GOOS=darwin GOARCH=amd64 build
}
case $1 in

View file

@ -0,0 +1,13 @@
//+build !windows,!linux
package process
// IsKernel returns whether the process is the Kernel.
func (p *Process) IsKernel() bool {
return p.Pid == 0
}
// specialOSInit does special OS specific Process initialization.
func (p *Process) specialOSInit() {
}

View file

@ -1,20 +1,5 @@
package process
// IsUser returns whether the process is run by a normal user.
func (p *Process) IsUser() bool {
return p.UserID >= 1000
}
// IsAdmin returns whether the process is run by an admin user.
func (p *Process) IsAdmin() bool {
return p.UserID >= 0
}
// IsSystem returns whether the process is run by the operating system.
func (p *Process) IsSystem() bool {
return p.UserID == 0
}
// IsKernel returns whether the process is the Kernel.
func (p *Process) IsKernel() bool {
return p.Pid == 0

View file

@ -2,28 +2,11 @@ package process
import (
"fmt"
"strings"
"github.com/safing/portbase/log"
"github.com/safing/portbase/utils/osdetail"
)
// IsUser returns whether the process is run by a normal user.
func (p *Process) IsUser() bool {
return p.Pid != 4 && // Kernel
!strings.HasPrefix(p.UserName, "NT") // NT-Authority (localized!)
}
// IsAdmin returns whether the process is run by an admin user.
func (p *Process) IsAdmin() bool {
return strings.HasPrefix(p.UserName, "NT") // NT-Authority (localized!)
}
// IsSystem returns whether the process is run by the operating system.
func (p *Process) IsSystem() bool {
return p.Pid == 4
}
// IsKernel returns whether the process is the Kernel.
func (p *Process) IsKernel() bool {
return p.Pid == 4