mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 08:34:40 +01:00
removed debugging logs, fixed build
This commit is contained in:
parent
26b8415925
commit
57a7f5b63d
2 changed files with 15 additions and 3 deletions
|
@ -1,10 +1,23 @@
|
|||
package netlink
|
||||
|
||||
import (
|
||||
"net"
|
||||
|
||||
"github.com/evilsocket/opensnitch/daemon/log"
|
||||
"github.com/vishvananda/netlink"
|
||||
)
|
||||
|
||||
// https://cs.opensource.google/go/go/+/refs/tags/go1.20.6:src/net/ip.go;l=133
|
||||
// TODO: remove when upgrading go version.
|
||||
func isPrivate(ip net.IP) bool {
|
||||
if ip4 := ip.To4(); ip4 != nil {
|
||||
return ip4[0] == 10 ||
|
||||
(ip4[0] == 172 && ip4[1]&0xf0 == 16) ||
|
||||
(ip4[0] == 192 && ip4[1] == 168)
|
||||
}
|
||||
return len(ip) == 16 && ip[0]&0xfe == 0xfc
|
||||
}
|
||||
|
||||
// GetLocalAddrs returns the list of local IPs
|
||||
func GetLocalAddrs() map[string]netlink.Addr {
|
||||
localAddresses := make(map[string]netlink.Addr)
|
||||
|
|
|
@ -169,14 +169,13 @@ func KillSockets(fam, proto uint8, excludeLocal bool) error {
|
|||
}
|
||||
|
||||
for _, sock := range sockListTCP {
|
||||
if excludeLocal && (sock.ID.Destination.IsPrivate() ||
|
||||
if excludeLocal && (isPrivate(sock.ID.Destination) ||
|
||||
sock.ID.Source.IsUnspecified() ||
|
||||
sock.ID.Destination.IsUnspecified()) {
|
||||
continue
|
||||
}
|
||||
log.Error("KILLINGIT: %+v", sock.ID)
|
||||
if err := SocketKill(fam, proto, sock.ID); err != nil {
|
||||
log.Error("ERRORERRORERROR KILLING: %s", err)
|
||||
log.Debug("Unable to kill socket (%+v): %s", sock.ID, err)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue