mirror of
https://github.com/safing/portmaster
synced 2025-09-04 19:49:15 +00:00
Implement review suggestions, fix tests
This commit is contained in:
parent
5d0db1c250
commit
be75c2d99b
4 changed files with 8 additions and 6 deletions
|
@ -95,12 +95,12 @@ func (e *Entity) Init() *Entity {
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddDstPort adds the destination port.
|
// SetDstPort sets the destination port.
|
||||||
func (e *Entity) AddDstPort(dstPort uint16) {
|
func (e *Entity) SetDstPort(dstPort uint16) {
|
||||||
e.dstPort = dstPort
|
e.dstPort = dstPort
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddDstPort adds the destination port.
|
// DstPort returns the destination port.
|
||||||
func (e *Entity) DstPort() uint16 {
|
func (e *Entity) DstPort() uint16 {
|
||||||
return e.dstPort
|
return e.dstPort
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// Windows specific constants for the WSAIoctl interface.
|
// Windows specific constants for the WSAIoctl interface.
|
||||||
//nolint:golint
|
//nolint:golint,stylecheck
|
||||||
const (
|
const (
|
||||||
SIO_RCVALL = syscall.IOC_IN | syscall.IOC_VENDOR | 1
|
SIO_RCVALL = syscall.IOC_IN | syscall.IOC_VENDOR | 1
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ func NewConnectionFromFirstPacket(pkt packet.Packet) *Connection {
|
||||||
Protocol: uint8(pkt.Info().Protocol),
|
Protocol: uint8(pkt.Info().Protocol),
|
||||||
Port: pkt.Info().SrcPort,
|
Port: pkt.Info().SrcPort,
|
||||||
}
|
}
|
||||||
entity.AddDstPort(pkt.Info().DstPort)
|
entity.SetDstPort(pkt.Info().DstPort)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ func NewConnectionFromFirstPacket(pkt packet.Packet) *Connection {
|
||||||
Protocol: uint8(pkt.Info().Protocol),
|
Protocol: uint8(pkt.Info().Protocol),
|
||||||
Port: pkt.Info().DstPort,
|
Port: pkt.Info().DstPort,
|
||||||
}
|
}
|
||||||
entity.AddDstPort(entity.Port)
|
entity.SetDstPort(entity.Port)
|
||||||
|
|
||||||
// check if we can find a domain for that IP
|
// check if we can find a domain for that IP
|
||||||
ipinfo, err := resolver.GetIPInfo(proc.LocalProfileKey, pkt.Info().Dst.String())
|
ipinfo, err := resolver.GetIPInfo(proc.LocalProfileKey, pkt.Info().Dst.String())
|
||||||
|
|
|
@ -17,6 +17,8 @@ func TestMain(m *testing.M) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func testEndpointMatch(t *testing.T, ep Endpoint, entity *intel.Entity, expectedResult EPResult) {
|
func testEndpointMatch(t *testing.T, ep Endpoint, entity *intel.Entity, expectedResult EPResult) {
|
||||||
|
entity.SetDstPort(entity.Port)
|
||||||
|
|
||||||
result, _ := ep.Matches(context.TODO(), entity)
|
result, _ := ep.Matches(context.TODO(), entity)
|
||||||
if result != expectedResult {
|
if result != expectedResult {
|
||||||
t.Errorf(
|
t.Errorf(
|
||||||
|
|
Loading…
Add table
Reference in a new issue