Create interface for socket info structs, fix caching bug

From PR Review https://github.com/safing/portmaster/pull/72
This commit is contained in:
Daniel
2020-07-10 14:09:53 +02:00
parent 3d0e01383f
commit 7c6c4552aa
5 changed files with 54 additions and 52 deletions

View File

@@ -29,3 +29,35 @@ type Address struct {
IP net.IP
Port uint16
}
// Info is a generic interface to both ConnectionInfo and BindInfo.
type Info interface {
GetPID() int
SetPID(int)
GetUID() int
GetInode() int
}
// GetPID returns the PID.
func (i *ConnectionInfo) GetPID() int { return i.PID }
// SetPID sets the PID to the given value.
func (i *ConnectionInfo) SetPID(pid int) { i.PID = pid }
// GetUID returns the UID.
func (i *ConnectionInfo) GetUID() int { return i.UID }
// GetInode returns the Inode.
func (i *ConnectionInfo) GetInode() int { return i.Inode }
// GetPID returns the PID.
func (i *BindInfo) GetPID() int { return i.PID }
// SetPID sets the PID to the given value.
func (i *BindInfo) SetPID(pid int) { i.PID = pid }
// GetUID returns the UID.
func (i *BindInfo) GetUID() int { return i.UID }
// GetInode returns the Inode.
func (i *BindInfo) GetInode() int { return i.Inode }