mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 08:34:40 +01:00
also detect applications that use the AF_INET6 socket for IPv4 connections
This commit is contained in:
parent
5c8f7102c2
commit
0efcfe9e65
1 changed files with 17 additions and 1 deletions
|
@ -2,11 +2,27 @@ package netstat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net"
|
"net"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/evilsocket/opensnitch/daemon/log"
|
"github.com/evilsocket/opensnitch/daemon/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
func FindEntry(proto string, srcIP net.IP, srcPort uint, dstIP net.IP, dstPort uint) *Entry {
|
func FindEntry(proto string, srcIP net.IP, srcPort uint, dstIP net.IP, dstPort uint) *Entry {
|
||||||
|
if entry := findEntryForProtocol(proto, srcIP, srcPort, dstIP, dstPort); entry != nil {
|
||||||
|
return entry
|
||||||
|
}
|
||||||
|
|
||||||
|
ipv6Suffix := "6"
|
||||||
|
if strings.HasSuffix(proto, ipv6Suffix) == false {
|
||||||
|
otherProto := proto + ipv6Suffix
|
||||||
|
log.Debug("Searching for %s netstat entry instead of %s", otherProto, proto)
|
||||||
|
return findEntryForProtocol(otherProto, srcIP, srcPort, dstIP, dstPort)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
func findEntryForProtocol(proto string, srcIP net.IP, srcPort uint, dstIP net.IP, dstPort uint) *Entry {
|
||||||
entries, err := Parse(proto)
|
entries, err := Parse(proto)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Warning("Error while searching for %s netstat entry: %s", proto, err)
|
log.Warning("Error while searching for %s netstat entry: %s", proto, err)
|
||||||
|
|
Loading…
Add table
Reference in a new issue