Merge pull request #31 from safing/fix/travis/deps-and-golangci-lint
Fix Travis deps, testing and golangci lint
This commit is contained in:
@@ -14,6 +14,13 @@ branches:
|
|||||||
- /^feature\/travis\/.+$/ # feature/travis/*
|
- /^feature\/travis\/.+$/ # feature/travis/*
|
||||||
- /^fix\/travis\/.+$/ # fix/travis/*
|
- /^fix\/travis\/.+$/ # fix/travis/*
|
||||||
|
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
update: true
|
||||||
|
|
||||||
|
before_install:
|
||||||
|
- if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get -y install libnetfilter-queue-dev; fi
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- go get -d -u github.com/golang/dep
|
- go get -d -u github.com/golang/dep
|
||||||
- go install github.com/golang/dep/cmd/dep
|
- go install github.com/golang/dep/cmd/dep
|
||||||
|
|||||||
@@ -2,10 +2,8 @@ package interception
|
|||||||
|
|
||||||
import "github.com/safing/portmaster/network/packet"
|
import "github.com/safing/portmaster/network/packet"
|
||||||
|
|
||||||
var (
|
// Packets channel for feeding the firewall.
|
||||||
// Packets channel for feeding the firewall.
|
var Packets = make(chan packet.Packet, 1000)
|
||||||
Packets = make(chan packet.Packet, 1000)
|
|
||||||
)
|
|
||||||
|
|
||||||
// Start starts the interception.
|
// Start starts the interception.
|
||||||
func Start() error {
|
func Start() error {
|
||||||
|
|||||||
@@ -11,12 +11,8 @@ import (
|
|||||||
"github.com/safing/portmaster/updates"
|
"github.com/safing/portmaster/updates"
|
||||||
)
|
)
|
||||||
|
|
||||||
var Packets chan packet.Packet
|
// Packets channel for feeding the firewall.
|
||||||
|
var Packets = make(chan packet.Packet, 1000)
|
||||||
func init() {
|
|
||||||
// Packets channel for feeding the firewall.
|
|
||||||
Packets = make(chan packet.Packet, 1000)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start starts the interception.
|
// Start starts the interception.
|
||||||
func Start() error {
|
func Start() error {
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
|
// +build linux
|
||||||
|
|
||||||
// Package nfqueue provides network interception capabilities on linux via iptables nfqueue.
|
// Package nfqueue provides network interception capabilities on linux via iptables nfqueue.
|
||||||
package nfqueue
|
package nfqueue
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// +build linux
|
||||||
|
|
||||||
package nfqueue
|
package nfqueue
|
||||||
|
|
||||||
// suspended for now
|
// suspended for now
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// +build linux
|
||||||
|
|
||||||
package nfqueue
|
package nfqueue
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// +build linux
|
||||||
|
|
||||||
package nfqueue
|
package nfqueue
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// +build windows
|
// +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
|
package windowskext
|
||||||
|
|||||||
@@ -14,20 +14,20 @@ import (
|
|||||||
|
|
||||||
// VerdictRequest is the request structure from the Kext.
|
// VerdictRequest is the request structure from the Kext.
|
||||||
type VerdictRequest struct {
|
type VerdictRequest struct {
|
||||||
id uint32 /* ID from RegisterPacket */
|
id uint32 // ID from RegisterPacket
|
||||||
processID uint64 /* Process ID. Nice to have*/
|
_ uint64 // Process ID - does not yet work
|
||||||
direction uint8
|
direction uint8
|
||||||
ipV6 uint8 /* True: IPv6, False: IPv4 */
|
ipV6 uint8 // True: IPv6, False: IPv4
|
||||||
protocol uint8 /* Protocol */
|
protocol uint8 // Protocol
|
||||||
_ uint8
|
_ uint8
|
||||||
localIP [4]uint32 /* Source Address */
|
localIP [4]uint32 // Source Address
|
||||||
remoteIP [4]uint32 /* Destination Address */
|
remoteIP [4]uint32 // Destination Address
|
||||||
localPort uint16 /* Source Port */
|
localPort uint16 // Source Port
|
||||||
remotePort uint16 /* Destination port */
|
remotePort uint16 // Destination port
|
||||||
compartmentID uint32
|
_ uint32 // compartmentID
|
||||||
interfaceIndex uint32
|
_ uint32 // interfaceIndex
|
||||||
subInterfaceIndex uint32
|
_ uint32 // subInterfaceIndex
|
||||||
packetSize uint32
|
packetSize uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handler transforms received packets to the Packet interface.
|
// Handler transforms received packets to the Packet interface.
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// logging
|
// logging
|
||||||
log.Start()
|
_ = log.Start()
|
||||||
log.Info("starting Portmaster Windows Kext Test Program")
|
log.Info("starting Portmaster Windows Kext Test Program")
|
||||||
|
|
||||||
// init
|
// init
|
||||||
@@ -52,7 +52,7 @@ func main() {
|
|||||||
go handlePackets()
|
go handlePackets()
|
||||||
|
|
||||||
// catch interrupt for clean shutdown
|
// catch interrupt for clean shutdown
|
||||||
signalCh := make(chan os.Signal)
|
signalCh := make(chan os.Signal, 1)
|
||||||
signal.Notify(
|
signal.Notify(
|
||||||
signalCh,
|
signalCh,
|
||||||
os.Interrupt,
|
os.Interrupt,
|
||||||
@@ -98,13 +98,19 @@ func handlePackets() {
|
|||||||
// reroute dns requests to nameserver
|
// reroute dns requests to nameserver
|
||||||
if pkt.IsOutbound() && !pkt.Info().Src.Equal(pkt.Info().Dst) && pkt.Info().DstPort == 53 {
|
if pkt.IsOutbound() && !pkt.Info().Src.Equal(pkt.Info().Dst) && pkt.Info().DstPort == 53 {
|
||||||
log.Infof("rerouting %s", pkt)
|
log.Infof("rerouting %s", pkt)
|
||||||
pkt.RerouteToNameserver()
|
err = pkt.RerouteToNameserver()
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("failed to reroute: %s", err)
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// accept all
|
// accept all
|
||||||
log.Infof("accepting %s", pkt)
|
log.Infof("accepting %s", pkt)
|
||||||
pkt.PermanentAccept()
|
err = pkt.PermanentAccept()
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("failed to accept: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
// +build !linux
|
|
||||||
|
|
||||||
package netenv
|
|
||||||
|
|
||||||
func getNameserversFromDbus() ([]Nameserver, error) {
|
|
||||||
var nameservers []Nameserver
|
|
||||||
return nameservers, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func getConnectivityStateFromDbus() (uint8, error) {
|
|
||||||
return StatusUnknown, nil
|
|
||||||
}
|
|
||||||
@@ -6,6 +6,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestDbus(t *testing.T) {
|
func TestDbus(t *testing.T) {
|
||||||
|
if testing.Short() {
|
||||||
|
t.Skip("skipping test in short mode because it fails in the CI")
|
||||||
|
}
|
||||||
|
|
||||||
if _, err := os.Stat("/var/run/dbus/system_bus_socket"); os.IsNotExist(err) {
|
if _, err := os.Stat("/var/run/dbus/system_bus_socket"); os.IsNotExist(err) {
|
||||||
t.Logf("skipping dbus tests, as dbus does not seem to be installed: %s", err)
|
t.Logf("skipping dbus tests, as dbus does not seem to be installed: %s", err)
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ package netenv
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: find a good way to identify a network
|
// TODO: find a good way to identify a network
|
||||||
@@ -15,25 +13,6 @@ import (
|
|||||||
// windows: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365917
|
// windows: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365917
|
||||||
// this info might already be included in the interfaces api provided by golang!
|
// this info might already be included in the interfaces api provided by golang!
|
||||||
|
|
||||||
const (
|
|
||||||
gatewaysRecheck = 2 * time.Second
|
|
||||||
nameserversRecheck = 2 * time.Second
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// interfaces = make(map[*net.IP]net.Flags)
|
|
||||||
// interfacesLock sync.Mutex
|
|
||||||
// interfacesExpires = time.Now()
|
|
||||||
|
|
||||||
gateways = make([]*net.IP, 0)
|
|
||||||
gatewaysLock sync.Mutex
|
|
||||||
gatewaysExpires = time.Now()
|
|
||||||
|
|
||||||
nameservers = make([]Nameserver, 0)
|
|
||||||
nameserversLock sync.Mutex
|
|
||||||
nameserversExpires = time.Now()
|
|
||||||
)
|
|
||||||
|
|
||||||
// Nameserver describes a system assigned namserver.
|
// Nameserver describes a system assigned namserver.
|
||||||
type Nameserver struct {
|
type Nameserver struct {
|
||||||
IP net.IP
|
IP net.IP
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
@@ -14,7 +15,22 @@ import (
|
|||||||
"github.com/safing/portmaster/network/netutils"
|
"github.com/safing/portmaster/network/netutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Gateways returns the currently active gateways
|
const (
|
||||||
|
gatewaysRecheck = 2 * time.Second
|
||||||
|
nameserversRecheck = 2 * time.Second
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
gateways = make([]*net.IP, 0)
|
||||||
|
gatewaysLock sync.Mutex
|
||||||
|
gatewaysExpires = time.Now()
|
||||||
|
|
||||||
|
nameservers = make([]Nameserver, 0)
|
||||||
|
nameserversLock sync.Mutex
|
||||||
|
nameserversExpires = time.Now()
|
||||||
|
)
|
||||||
|
|
||||||
|
// Gateways returns the currently active gateways.
|
||||||
func Gateways() []*net.IP {
|
func Gateways() []*net.IP {
|
||||||
// locking
|
// locking
|
||||||
gatewaysLock.Lock()
|
gatewaysLock.Lock()
|
||||||
@@ -101,7 +117,7 @@ func Gateways() []*net.IP {
|
|||||||
return newGateways
|
return newGateways
|
||||||
}
|
}
|
||||||
|
|
||||||
// Nameservers returns the currently active nameservers
|
// Nameservers returns the currently active nameservers.
|
||||||
func Nameservers() []Nameserver {
|
func Nameservers() []Nameserver {
|
||||||
// locking
|
// locking
|
||||||
nameserversLock.Lock()
|
nameserversLock.Lock()
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ package netenv
|
|||||||
|
|
||||||
import "net"
|
import "net"
|
||||||
|
|
||||||
|
// Nameservers returns the currently active nameservers.
|
||||||
func Nameservers() []Nameserver {
|
func Nameservers() []Nameserver {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gateways returns the currently active gateways.
|
||||||
func Gateways() []*net.IP {
|
func Gateways() []*net.IP {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ func attachToParentConsole() (attached bool, err error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
r1, _, err := procAttachConsole.Call(windowsAttachParentProcess)
|
r1, _, _ := procAttachConsole.Call(windowsAttachParentProcess)
|
||||||
if r1 == 0 {
|
if r1 == 0 {
|
||||||
// possible errors:
|
// possible errors:
|
||||||
// ERROR_ACCESS_DENIED: already attached to console
|
// ERROR_ACCESS_DENIED: already attached to console
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
// Based on the offical Go examples from
|
// Based on the official Go examples from
|
||||||
// https://github.com/golang/sys/blob/master/windows/svc/example
|
// https://github.com/golang/sys/blob/master/windows/svc/example
|
||||||
// by The Go Authors.
|
// by The Go Authors.
|
||||||
// Original LICENSE (sha256sum: 2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067) can be found in vendor/pkg cache directory.
|
// Original LICENSE (sha256sum: 2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067) can be found in vendor/pkg cache directory.
|
||||||
@@ -19,6 +19,10 @@ import (
|
|||||||
"golang.org/x/sys/windows/svc/mgr"
|
"golang.org/x/sys/windows/svc/mgr"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
exeSuffix = ".exe"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rootCmd.AddCommand(installCmd)
|
rootCmd.AddCommand(installCmd)
|
||||||
installCmd.AddCommand(installService)
|
installCmd.AddCommand(installService)
|
||||||
@@ -70,8 +74,8 @@ func getExePath() (string, error) {
|
|||||||
}
|
}
|
||||||
// check if we have a .exe extension, add and check if not
|
// check if we have a .exe extension, add and check if not
|
||||||
if filepath.Ext(p) == "" {
|
if filepath.Ext(p) == "" {
|
||||||
p += ".exe"
|
p += exeSuffix
|
||||||
fi, err := os.Stat(p)
|
fi, err = os.Stat(p)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if !fi.Mode().IsDir() {
|
if !fi.Mode().IsDir() {
|
||||||
return p, nil
|
return p, nil
|
||||||
@@ -113,15 +117,7 @@ func getServiceConfig(exePath string) mgr.Config {
|
|||||||
|
|
||||||
func getRecoveryActions() (recoveryActions []mgr.RecoveryAction, resetPeriod uint32) {
|
func getRecoveryActions() (recoveryActions []mgr.RecoveryAction, resetPeriod uint32) {
|
||||||
return []mgr.RecoveryAction{
|
return []mgr.RecoveryAction{
|
||||||
//mgr.RecoveryAction{
|
{
|
||||||
// Type: mgr.ServiceRestart, // one of NoAction, ComputerReboot, ServiceRestart or RunCommand
|
|
||||||
// Delay: 1 * time.Minute, // the time to wait before performing the specified action
|
|
||||||
//},
|
|
||||||
// mgr.RecoveryAction{
|
|
||||||
// Type: mgr.ServiceRestart, // one of NoAction, ComputerReboot, ServiceRestart or RunCommand
|
|
||||||
// Delay: 1 * time.Minute, // the time to wait before performing the specified action
|
|
||||||
// },
|
|
||||||
mgr.RecoveryAction{
|
|
||||||
Type: mgr.ServiceRestart, // one of NoAction, ComputerReboot, ServiceRestart or RunCommand
|
Type: mgr.ServiceRestart, // one of NoAction, ComputerReboot, ServiceRestart or RunCommand
|
||||||
Delay: 1 * time.Minute, // the time to wait before performing the specified action
|
Delay: 1 * time.Minute, // the time to wait before performing the specified action
|
||||||
},
|
},
|
||||||
@@ -140,7 +136,7 @@ func installWindowsService(cmd *cobra.Command, args []string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to connect to service manager: %s", err)
|
return fmt.Errorf("failed to connect to service manager: %s", err)
|
||||||
}
|
}
|
||||||
defer m.Disconnect()
|
defer m.Disconnect() //nolint:errcheck // TODO
|
||||||
|
|
||||||
// open service
|
// open service
|
||||||
created := false
|
created := false
|
||||||
@@ -156,7 +152,7 @@ func installWindowsService(cmd *cobra.Command, args []string) error {
|
|||||||
created = true
|
created = true
|
||||||
} else {
|
} else {
|
||||||
// update service
|
// update service
|
||||||
s.UpdateConfig(getServiceConfig(exePath))
|
err = s.UpdateConfig(getServiceConfig(exePath))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to update service: %s", err)
|
return fmt.Errorf("failed to update service: %s", err)
|
||||||
}
|
}
|
||||||
@@ -184,7 +180,7 @@ func uninstallWindowsService(cmd *cobra.Command, args []string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer m.Disconnect()
|
defer m.Disconnect() //nolint:errcheck // TODO
|
||||||
|
|
||||||
// open service
|
// open service
|
||||||
s, err := m.OpenService(serviceName)
|
s, err := m.OpenService(serviceName)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
// Based on the offical Go examples from
|
// Based on the official Go examples from
|
||||||
// https://github.com/golang/sys/blob/master/windows/svc/example
|
// https://github.com/golang/sys/blob/master/windows/svc/example
|
||||||
// by The Go Authors.
|
// by The Go Authors.
|
||||||
// Original LICENSE (sha256sum: 2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067) can be found in vendor/pkg cache directory.
|
// Original LICENSE (sha256sum: 2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067) can be found in vendor/pkg cache directory.
|
||||||
@@ -84,7 +84,8 @@ service:
|
|||||||
changes <- svc.Status{State: svc.Stopped}
|
changes <- svc.Status{State: svc.Stopped}
|
||||||
// wait a little for the status to reach Windows
|
// wait a little for the status to reach Windows
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
return
|
|
||||||
|
return ssec, errno
|
||||||
}
|
}
|
||||||
|
|
||||||
func runService(cmd *cobra.Command, opts *Options) error {
|
func runService(cmd *cobra.Command, opts *Options) error {
|
||||||
@@ -121,7 +122,7 @@ func runService(cmd *cobra.Command, opts *Options) error {
|
|||||||
go func() {
|
go func() {
|
||||||
// run slightly delayed
|
// run slightly delayed
|
||||||
time.Sleep(250 * time.Millisecond)
|
time.Sleep(250 * time.Millisecond)
|
||||||
handleRun(cmd, opts)
|
_ = handleRun(cmd, opts) // error handled by shutdown routine
|
||||||
finishWg.Done()
|
finishWg.Done()
|
||||||
runWg.Done()
|
runWg.Done()
|
||||||
}()
|
}()
|
||||||
@@ -131,7 +132,7 @@ func runService(cmd *cobra.Command, opts *Options) error {
|
|||||||
err = getShutdownError()
|
err = getShutdownError()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("%s service experienced an error: %s\n", serviceName, err)
|
log.Printf("%s service experienced an error: %s\n", serviceName, err)
|
||||||
elog.Error(1, fmt.Sprintf("%s experienced an error: %s", serviceName, err))
|
_ = elog.Error(1, fmt.Sprintf("%s experienced an error: %s", serviceName, err))
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ func GetUDP6PacketInfo(localIP net.IP, localPort uint16, remoteIP net.IP, remote
|
|||||||
return -1, pktDirection, nil
|
return -1, pktDirection, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func search(connections, listeners []*ConnectionEntry, localIP, remoteIP net.IP, localPort, remotePort uint16, pktDirection bool) (pid int, direction bool) {
|
func search(connections, listeners []*ConnectionEntry, localIP, remoteIP net.IP, localPort, remotePort uint16, pktDirection bool) (pid int, direction bool) { //nolint:unparam // TODO: use direction, it may not be used because results caused problems, investigate.
|
||||||
lock.RLock()
|
lock.RLock()
|
||||||
defer lock.RUnlock()
|
defer lock.RUnlock()
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ func New() (*IPHelper, error) {
|
|||||||
|
|
||||||
// load dll
|
// load dll
|
||||||
new.dll = windows.NewLazySystemDLL("iphlpapi.dll")
|
new.dll = windows.NewLazySystemDLL("iphlpapi.dll")
|
||||||
new.dll.Load()
|
err = new.dll.Load()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,14 +59,14 @@ type iphelperTCP6Table struct {
|
|||||||
|
|
||||||
type iphelperTCP6Row struct {
|
type iphelperTCP6Row struct {
|
||||||
// docs: https://msdn.microsoft.com/en-us/library/windows/desktop/aa366896(v=vs.85).aspx
|
// docs: https://msdn.microsoft.com/en-us/library/windows/desktop/aa366896(v=vs.85).aspx
|
||||||
localAddr [16]byte
|
localAddr [16]byte
|
||||||
localScopeID uint32
|
_ uint32 // localScopeID
|
||||||
localPort uint32
|
localPort uint32
|
||||||
remoteAddr [16]byte
|
remoteAddr [16]byte
|
||||||
remoteScopeID uint32
|
_ uint32 // remoteScopeID
|
||||||
remotePort uint32
|
remotePort uint32
|
||||||
state uint32
|
state uint32
|
||||||
owningPid uint32
|
owningPid uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type iphelperUDPTable struct {
|
type iphelperUDPTable struct {
|
||||||
@@ -90,10 +90,10 @@ type iphelperUDP6Table struct {
|
|||||||
|
|
||||||
type iphelperUDP6Row struct {
|
type iphelperUDP6Row struct {
|
||||||
// docs: https://msdn.microsoft.com/en-us/library/windows/desktop/aa366923(v=vs.85).aspx
|
// docs: https://msdn.microsoft.com/en-us/library/windows/desktop/aa366923(v=vs.85).aspx
|
||||||
localAddr [16]byte
|
localAddr [16]byte
|
||||||
localScopeID uint32
|
_ uint32 // localScopeID
|
||||||
localPort uint32
|
localPort uint32
|
||||||
owningPid uint32
|
owningPid uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
// IP and Protocol constants
|
// IP and Protocol constants
|
||||||
@@ -137,7 +137,7 @@ func increaseBufSize() int {
|
|||||||
defer bufSizeLock.Unlock()
|
defer bufSizeLock.Unlock()
|
||||||
|
|
||||||
// increase
|
// increase
|
||||||
bufSize = bufSize * 2
|
bufSize *= 2
|
||||||
// not too much
|
// not too much
|
||||||
if bufSize > 65536 {
|
if bufSize > 65536 {
|
||||||
bufSize = 65536
|
bufSize = 65536
|
||||||
@@ -149,7 +149,7 @@ func increaseBufSize() int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GetTables returns the current connection state table of Windows of the given protocol and IP version.
|
// GetTables returns the current connection state table of Windows of the given protocol and IP version.
|
||||||
func (ipHelper *IPHelper) GetTables(protocol uint8, ipVersion uint8) (connections []*ConnectionEntry, listeners []*ConnectionEntry, err error) {
|
func (ipHelper *IPHelper) GetTables(protocol uint8, ipVersion uint8) (connections []*ConnectionEntry, listeners []*ConnectionEntry, err error) { //nolint:gocognit,gocycle // TODO
|
||||||
// docs: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365928(v=vs.85).aspx
|
// docs: https://msdn.microsoft.com/en-us/library/windows/desktop/aa365928(v=vs.85).aspx
|
||||||
|
|
||||||
if !ipHelper.valid.IsSet() {
|
if !ipHelper.valid.IsSet() {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// +build linux
|
||||||
|
|
||||||
package proc
|
package proc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// +build linux
|
||||||
|
|
||||||
package proc
|
package proc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// +build linux
|
||||||
|
|
||||||
package proc
|
package proc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// +build linux
|
||||||
|
|
||||||
package proc
|
package proc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// +build linux
|
||||||
|
|
||||||
package proc
|
package proc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// +build linux
|
||||||
|
|
||||||
package proc
|
package proc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
30
test
30
test
@@ -4,7 +4,6 @@ warnings=0
|
|||||||
errors=0
|
errors=0
|
||||||
scripted=0
|
scripted=0
|
||||||
goUp="\\e[1A"
|
goUp="\\e[1A"
|
||||||
all=0
|
|
||||||
fullTestFlags="-short"
|
fullTestFlags="-short"
|
||||||
install=0
|
install=0
|
||||||
|
|
||||||
@@ -99,7 +98,6 @@ while true; do
|
|||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
"all")
|
"all")
|
||||||
all=1
|
|
||||||
fullTestFlags=""
|
fullTestFlags=""
|
||||||
shift 1
|
shift 1
|
||||||
;;
|
;;
|
||||||
@@ -119,10 +117,8 @@ if [[ $install -eq 1 ]]; then
|
|||||||
echo "installing dependencies..."
|
echo "installing dependencies..."
|
||||||
echo "$ go get -u golang.org/x/lint/golint"
|
echo "$ go get -u golang.org/x/lint/golint"
|
||||||
go get -u golang.org/x/lint/golint
|
go get -u golang.org/x/lint/golint
|
||||||
if [[ $all -eq 1 ]]; then
|
echo "$ go get -u github.com/golangci/golangci-lint/cmd/golangci-lint"
|
||||||
echo "$ go get -u github.com/golangci/golangci-lint/cmd/golangci-lint"
|
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||||
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
|
|
||||||
fi
|
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -141,16 +137,14 @@ if [[ $(which golint) == "" ]]; then
|
|||||||
echo "or run: ./test install"
|
echo "or run: ./test install"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [[ $all -eq 1 ]]; then
|
if [[ $(which golangci-lint) == "" ]]; then
|
||||||
if [[ $(which golangci-lint) == "" ]]; then
|
echo "golangci-lint command not found"
|
||||||
echo "golangci-lint command not found"
|
echo "install locally with: go get -u github.com/golangci/golangci-lint/cmd/golangci-lint"
|
||||||
echo "install locally with: go get -u github.com/golangci/golangci-lint/cmd/golangci-lint"
|
echo "or run: ./test install all"
|
||||||
echo "or run: ./test install all"
|
echo ""
|
||||||
echo ""
|
echo "hint: install for CI with: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin vX.Y.Z"
|
||||||
echo "hint: install for CI with: curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin vX.Y.Z"
|
echo "don't forget to specify the version you want"
|
||||||
echo "don't forget to specify the version you want"
|
exit 1
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# target selection
|
# target selection
|
||||||
@@ -179,9 +173,7 @@ for package in $packages; do
|
|||||||
checkformat $package
|
checkformat $package
|
||||||
run golint -set_exit_status -min_confidence 1.0 $package
|
run golint -set_exit_status -min_confidence 1.0 $package
|
||||||
run go vet $package
|
run go vet $package
|
||||||
if [[ $all -eq 1 ]]; then
|
run golangci-lint run $GOPATH/src/$package
|
||||||
run golangci-lint run $GOPATH/src/$package
|
|
||||||
fi
|
|
||||||
run go test -cover $fullTestFlags $package
|
run go test -cover $fullTestFlags $package
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user