Skip to content

Commit c16f697

Browse files
committed
conntrack/netstat-nat: filter by protocol
1 parent bedadbd commit c16f697

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

netstat-nat.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
)
1212

1313
// TODO implement the following flags
14-
// -p <protocol> : display connections by protocol
1514
// -s <source-host> : display connections by source
1615
// -d <destination-host>: display connections by destination
1716
// -x: extended hostnames view
@@ -25,6 +24,7 @@ var onlyLocal = flag.Bool("L", false, "Display only local connections (originati
2524
var onlyRouted = flag.Bool("R", false, "Display only connections routed through the router")
2625
var noResolve = flag.Bool("n", false, "Do not resolve hostnames") // TODO resolve port names as well
2726
var noHeader = flag.Bool("o", false, "Strip output header")
27+
var protocol = flag.String("p", "", "Filter connections by protocol")
2828

2929
func main() {
3030
flag.Parse()
@@ -60,6 +60,9 @@ func main() {
6060
}
6161

6262
filteredFlows := flows.FilterByType(which)
63+
if *protocol != "" {
64+
filteredFlows = filteredFlows.FilterByProtocol(*protocol)
65+
}
6366

6467
for _, flow := range filteredFlows {
6568
sHostname := lookup.Resolve(flow.Original.Source, *noResolve)

0 commit comments

Comments
 (0)