Fix linting errors

This commit is contained in:
Patrick Pacher
2024-03-27 16:17:58 +01:00
parent 653a365bce
commit 61176af14e
48 changed files with 167 additions and 153 deletions

View File

@@ -136,11 +136,11 @@ func AddNetworkDebugData(di *debug.Info, profile, where string) {
// Collect matching connections.
var ( //nolint:prealloc // We don't know the size.
debugConns []*Connection
accepted int
total int
debugConns []*Connection
accepted int
total int
)
for maybeConn := range it.Next {
// Switch to correct type.
conn, ok := maybeConn.(*Connection)

View File

@@ -751,12 +751,14 @@ func (conn *Connection) SaveWhenFinished() {
func (conn *Connection) Save() {
conn.UpdateMeta()
// nolint:exhaustive
switch conn.Verdict {
case VerdictAccept, VerdictRerouteToNameserver:
conn.ConnectionEstablished = true
case VerdictRerouteToTunnel:
// this is already handled when the connection tunnel has been
// established.
default:
}
// Do not save/update until data is complete.

View File

@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"net"
"strconv"
"github.com/google/gopacket"
)
@@ -207,9 +208,9 @@ func (pkt *Base) FmtRemoteIP() string {
func (pkt *Base) FmtRemotePort() string {
if pkt.info.SrcPort != 0 {
if pkt.info.Inbound {
return fmt.Sprintf("%d", pkt.info.SrcPort)
return strconv.FormatUint(uint64(pkt.info.SrcPort), 10)
}
return fmt.Sprintf("%d", pkt.info.DstPort)
return strconv.FormatUint(uint64(pkt.info.DstPort), 10)
}
return "-"
}
@@ -235,10 +236,10 @@ type Packet interface {
ExpectInfo() bool
// Info.
SetCtx(context.Context)
SetCtx(ctx context.Context)
Ctx() context.Context
Info() *Info
SetPacketInfo(Info)
SetPacketInfo(info Info)
IsInbound() bool
IsOutbound() bool
SetInbound()
@@ -253,8 +254,8 @@ type Packet interface {
Payload() []byte
// Matching.
MatchesAddress(bool, IPProtocol, *net.IPNet, uint16) bool
MatchesIP(bool, *net.IPNet) bool
MatchesAddress(remote bool, protocol IPProtocol, network *net.IPNet, port uint16) bool
MatchesIP(endpoint bool, network *net.IPNet) bool
// Formatting.
String() string

View File

@@ -44,7 +44,7 @@ type Address struct {
// Info is a generic interface to both ConnectionInfo and BindInfo.
type Info interface {
GetPID() int
SetPID(int)
SetPID(pid int)
GetUID() int
GetUIDandInode() (int, int)
}