mirror of
https://github.com/safing/portmaster
synced 2025-04-25 13:29:10 +00:00
Clean up process/proc
This commit is contained in:
parent
eeef53e01e
commit
5799d2559b
4 changed files with 10 additions and 3 deletions
process/proc
|
@ -5,6 +5,7 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// PID querying return codes
|
||||
const (
|
||||
Success uint8 = iota
|
||||
NoSocket
|
||||
|
@ -48,7 +49,7 @@ func GetPidOfConnection(localIP net.IP, localPort uint16, protocol uint8) (pid i
|
|||
return
|
||||
}
|
||||
|
||||
// GetPidOfConnection returns the PID of the given incoming connection.
|
||||
// GetPidOfIncomingConnection returns the PID of the given incoming connection.
|
||||
func GetPidOfIncomingConnection(localIP net.IP, localPort uint16, protocol uint8) (pid int, status uint8) {
|
||||
uid, inode, ok := getListeningSocket(localIP, localPort, protocol)
|
||||
if !ok {
|
||||
|
|
|
@ -5,18 +5,22 @@ import (
|
|||
"net"
|
||||
)
|
||||
|
||||
// GetTCP4PacketInfo searches the network state tables for a TCP4 connection
|
||||
func GetTCP4PacketInfo(localIP net.IP, localPort uint16, remoteIP net.IP, remotePort uint16, pktDirection bool) (pid int, direction bool, err error) {
|
||||
return search(TCP4, localIP, localPort, pktDirection)
|
||||
}
|
||||
|
||||
// GetTCP6PacketInfo searches the network state tables for a TCP6 connection
|
||||
func GetTCP6PacketInfo(localIP net.IP, localPort uint16, remoteIP net.IP, remotePort uint16, pktDirection bool) (pid int, direction bool, err error) {
|
||||
return search(TCP6, localIP, localPort, pktDirection)
|
||||
}
|
||||
|
||||
// GetUDP4PacketInfo searches the network state tables for a UDP4 connection
|
||||
func GetUDP4PacketInfo(localIP net.IP, localPort uint16, remoteIP net.IP, remotePort uint16, pktDirection bool) (pid int, direction bool, err error) {
|
||||
return search(UDP4, localIP, localPort, pktDirection)
|
||||
}
|
||||
|
||||
// GetUDP6PacketInfo searches the network state tables for a UDP6 connection
|
||||
func GetUDP6PacketInfo(localIP net.IP, localPort uint16, remoteIP net.IP, remotePort uint16, pktDirection bool) (pid int, direction bool, err error) {
|
||||
return search(UDP6, localIP, localPort, pktDirection)
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ var (
|
|||
pidsByUser = make(map[int][]int)
|
||||
)
|
||||
|
||||
// GetPidOfInode returns the pid of the given uid and socket inode.
|
||||
func GetPidOfInode(uid, inode int) (int, bool) {
|
||||
pidsByUserLock.Lock()
|
||||
defer pidsByUserLock.Unlock()
|
||||
|
|
|
@ -32,6 +32,7 @@ Cache every step!
|
|||
|
||||
*/
|
||||
|
||||
// Network Related Constants
|
||||
const (
|
||||
TCP4 uint8 = iota
|
||||
UDP4
|
||||
|
@ -211,7 +212,7 @@ func convertIPv4(data string) net.IP {
|
|||
return nil
|
||||
}
|
||||
if len(decoded) != 4 {
|
||||
log.Warningf("process: decoded IPv4 %s has wrong length")
|
||||
log.Warningf("process: decoded IPv4 %s has wrong length", decoded)
|
||||
return nil
|
||||
}
|
||||
ip := net.IPv4(decoded[3], decoded[2], decoded[1], decoded[0])
|
||||
|
@ -225,7 +226,7 @@ func convertIPv6(data string) net.IP {
|
|||
return nil
|
||||
}
|
||||
if len(decoded) != 16 {
|
||||
log.Warningf("process: decoded IPv6 %s has wrong length")
|
||||
log.Warningf("process: decoded IPv6 %s has wrong length", decoded)
|
||||
return nil
|
||||
}
|
||||
ip := net.IP(decoded)
|
||||
|
|
Loading…
Add table
Reference in a new issue