mirror of
https://github.com/netbirdio/netbird.git
synced 2026-05-06 17:08:53 +00:00
Fix ipv6 capture output
This commit is contained in:
@@ -4,7 +4,9 @@ import (
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/netip"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -91,9 +93,9 @@ func (tw *TextWriter) writeTCP(timeStr string, dir Direction, info *packetInfo,
|
||||
}
|
||||
|
||||
if !tw.verbose {
|
||||
_, err := fmt.Fprintf(tw.w, "%s %s %s:%d > %s:%d [%s] length %d%s\n",
|
||||
_, err := fmt.Fprintf(tw.w, "%s %s %s > %s [%s] length %d%s\n",
|
||||
timeStr, tag(dir, "TCP"),
|
||||
info.srcIP, info.srcPort, info.dstIP, info.dstPort,
|
||||
net.JoinHostPort(info.srcIP.String(), strconv.Itoa(int(info.srcPort))), net.JoinHostPort(info.dstIP.String(), strconv.Itoa(int(info.dstPort))),
|
||||
flags, plen, annotation)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -125,9 +127,9 @@ func (tw *TextWriter) writeTCP(timeStr string, dir Direction, info *packetInfo,
|
||||
|
||||
verbose := tw.verboseIP(data, info.family)
|
||||
|
||||
_, err := fmt.Fprintf(tw.w, "%s %s %s:%d > %s:%d [%s]%s%s, win %d%s, length %d%s%s\n",
|
||||
_, err := fmt.Fprintf(tw.w, "%s %s %s > %s [%s]%s%s, win %d%s, length %d%s%s\n",
|
||||
timeStr, tag(dir, "TCP"),
|
||||
info.srcIP, info.srcPort, info.dstIP, info.dstPort,
|
||||
net.JoinHostPort(info.srcIP.String(), strconv.Itoa(int(info.srcPort))), net.JoinHostPort(info.dstIP.String(), strconv.Itoa(int(info.dstPort))),
|
||||
flags, seqStr, ackStr, tcp.Window, opts, plen, annotation, verbose)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -153,9 +155,9 @@ func (tw *TextWriter) writeUDP(timeStr string, dir Direction, info *packetInfo,
|
||||
if tw.verbose {
|
||||
verbose = tw.verboseIP(data, info.family)
|
||||
}
|
||||
_, err := fmt.Fprintf(tw.w, "%s %s %s:%d > %s:%d %s%s\n",
|
||||
_, err := fmt.Fprintf(tw.w, "%s %s %s > %s %s%s\n",
|
||||
timeStr, tag(dir, "UDP"),
|
||||
info.srcIP, info.srcPort, info.dstIP, info.dstPort,
|
||||
net.JoinHostPort(info.srcIP.String(), strconv.Itoa(int(info.srcPort))), net.JoinHostPort(info.dstIP.String(), strconv.Itoa(int(info.dstPort))),
|
||||
s, verbose)
|
||||
return err
|
||||
}
|
||||
@@ -165,9 +167,9 @@ func (tw *TextWriter) writeUDP(timeStr string, dir Direction, info *packetInfo,
|
||||
if tw.verbose {
|
||||
verbose = tw.verboseIP(data, info.family)
|
||||
}
|
||||
_, err := fmt.Fprintf(tw.w, "%s %s %s:%d > %s:%d length %d%s\n",
|
||||
_, err := fmt.Fprintf(tw.w, "%s %s %s > %s length %d%s\n",
|
||||
timeStr, tag(dir, "UDP"),
|
||||
info.srcIP, info.srcPort, info.dstIP, info.dstPort,
|
||||
net.JoinHostPort(info.srcIP.String(), strconv.Itoa(int(info.srcPort))), net.JoinHostPort(info.dstIP.String(), strconv.Itoa(int(info.dstPort))),
|
||||
plen, verbose)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -216,9 +218,9 @@ func (tw *TextWriter) writeICMPv6(timeStr string, dir Direction, info *packetInf
|
||||
}
|
||||
|
||||
func (tw *TextWriter) writeFallback(timeStr string, dir Direction, proto string, info *packetInfo, data []byte) error {
|
||||
_, err := fmt.Fprintf(tw.w, "%s %s %s:%d > %s:%d length %d\n",
|
||||
_, err := fmt.Fprintf(tw.w, "%s %s %s > %s length %d\n",
|
||||
timeStr, tag(dir, proto),
|
||||
info.srcIP, info.srcPort, info.dstIP, info.dstPort,
|
||||
net.JoinHostPort(info.srcIP.String(), strconv.Itoa(int(info.srcPort))), net.JoinHostPort(info.dstIP.String(), strconv.Itoa(int(info.dstPort))),
|
||||
len(data)-info.hdrLen)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user