Switch connection state lookups to use the packet.Info struct

Also, rename the Direction attribute on packet.Info to Inbound
This commit is contained in:
Daniel
2020-05-18 17:08:32 +02:00
parent 0036d25672
commit 7649859ba6
10 changed files with 95 additions and 139 deletions

View File

@@ -60,16 +60,17 @@ func apiAuthenticator(s *http.Server, r *http.Request) (grantAccess bool, err er
var procsChecked []string
// get process
proc, _, err := process.GetProcessByEndpoints(
proc, _, err := process.GetProcessByConnection(
r.Context(),
packet.IPv4,
packet.TCP,
// switch reverse/local to get remote process
remoteIP,
remotePort,
localIP,
localPort,
false,
&packet.Info{
Inbound: false, // outbound as we are looking for the process of the source address
Version: packet.IPv4,
Protocol: packet.TCP,
Src: remoteIP, // source as in the process we are looking for
SrcPort: remotePort, // source as in the process we are looking for
Dst: localIP,
DstPort: localPort,
},
)
if err != nil {
return false, fmt.Errorf("failed to get process: %s", err)