Remove dependence on network.Connection.Scope

This commit is contained in:
Daniel 2021-04-16 17:44:01 +02:00
parent a879d2715a
commit 4c5461a788
3 changed files with 9 additions and 9 deletions

View file

@ -106,10 +106,10 @@ func createPrompt(ctx context.Context, conn *network.Connection, pkt packet.Pack
switch {
case conn.Inbound, conn.Entity.Domain == "": // connection to/from IP
nID = fmt.Sprintf(
"%s-%s-%s-%s",
"%s-%s-%v-%s",
promptIDPrefix,
localProfile.ID,
conn.Scope,
conn.Inbound,
pkt.Info().RemoteIP(),
)
default: // connection to domain
@ -117,7 +117,7 @@ func createPrompt(ctx context.Context, conn *network.Connection, pkt packet.Pack
"%s-%s-%s",
promptIDPrefix,
localProfile.ID,
conn.Scope,
conn.Entity.Domain,
)
}

View file

@ -650,12 +650,12 @@ func (conn *Connection) SetInspectorData(new map[uint8]interface{}) {
// String returns a string representation of conn.
func (conn *Connection) String() string {
switch conn.Scope {
case IncomingHost, IncomingLAN, IncomingInternet, IncomingInvalid:
switch {
case conn.Inbound:
return fmt.Sprintf("%s <- %s", conn.process, conn.Entity.IP)
case PeerHost, PeerLAN, PeerInternet, PeerInvalid:
return fmt.Sprintf("%s -> %s", conn.process, conn.Entity.IP)
default:
case conn.Entity.Domain != "":
return fmt.Sprintf("%s to %s (%s)", conn.process, conn.Entity.Domain, conn.Entity.IP)
default:
return fmt.Sprintf("%s -> %s", conn.process, conn.Entity.IP)
}
}

View file

@ -55,7 +55,7 @@ func SaveOpenDNSRequest(conn *Connection) {
openDNSRequestsLock.Lock()
defer openDNSRequestsLock.Unlock()
key := getDNSRequestCacheKey(conn.process.Pid, conn.Scope)
key := getDNSRequestCacheKey(conn.process.Pid, conn.Entity.Domain)
if existingConn, ok := openDNSRequests[key]; ok {
existingConn.Lock()
defer existingConn.Unlock()