Skip to content

Commit 879b9fc

Browse files
committed
ipv6 support
1 parent 8bef6d7 commit 879b9fc

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

internal/discovery/fingerprint.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,14 @@ func DiscoverServices(ctx context.Context, targets []ScanTarget, results chan<-
6161
}
6262

6363
log.Printf("fingerprint: scanning %d targets (attempt %d)\n", len(t), attempt+1)
64+
for _, target := range t {
65+
log.Printf(" Scanning target %s\n", target.Address.String())
66+
}
6467
scanned, err := scan.ScanTargets(t, scan.Config{
6568
UDP: false,
6669
FastMode: false,
6770
Verbose: false,
68-
DefaultTimeout: time.Second,
71+
DefaultTimeout: 2 * time.Second,
6972
})
7073
if err != nil {
7174
log.Printf("fingerprint: scan error (attempt %d): %v\n", attempt+1, err)

internal/discovery/process.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ func (w *ProcessWatcher) processEntry(state *scanState, entry portEntry) {
206206
return
207207
}
208208

209-
w.addListeningProcess(state, pid, port, subdomain, cwd, needsCustomMapping)
209+
w.addListeningProcess(state, pid, port, ip, subdomain, cwd, needsCustomMapping)
210210
state.usedPorts[port] = true
211211
}
212212

@@ -248,14 +248,14 @@ func (w *ProcessWatcher) addWellKnownProcess(state *scanState, pid int, port int
248248
state.usedPorts[port] = true
249249
}
250250

251-
func (w *ProcessWatcher) addListeningProcess(state *scanState, pid int, port int, subdomain string, cwd string, needsCustomMapping bool) {
251+
func (w *ProcessWatcher) addListeningProcess(state *scanState, pid int, port int, ip string, subdomain string, cwd string, needsCustomMapping bool) {
252252
if state.seenPID[pid] {
253253
return
254254
}
255255
state.results = append(state.results, DiscoveredService{
256256
Subdomain: subdomain,
257257
Port: port,
258-
IP: "127.0.0.1",
258+
IP: ip,
259259
Source: RouteSourceProcess,
260260
Process: &ProcessInfo{
261261
PID: pid,

internal/discovery/process_darwin.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import "C"
2424

2525
import (
2626
"bufio"
27+
"fmt"
2728
"os/exec"
2829
"strconv"
2930
"strings"
@@ -82,7 +83,10 @@ func (w *ProcessWatcher) getListeningPorts() ([]portEntry, error) {
8283
ipStr := addr[:colonIdx]
8384
if ipStr == "*" {
8485
ipStr = "127.0.0.1"
86+
} else if strings.HasPrefix(ipStr, "[") && strings.HasSuffix(ipStr, "]") {
87+
ipStr = ipStr[1 : len(ipStr)-1]
8588
}
89+
fmt.Println("IP", ipStr)
8690

8791
result = append(result, portEntry{PID: pid, Port: port, IP: ipStr})
8892
}

internal/discovery/process_nocgo_darwin.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ func (w *ProcessWatcher) getListeningPorts() ([]portEntry, error) {
6161
ipStr := addr[:colonIdx]
6262
if ipStr == "*" {
6363
ipStr = "127.0.0.1"
64+
} else if strings.HasPrefix(ipStr, "[") && strings.HasSuffix(ipStr, "]") {
65+
ipStr = ipStr[1 : len(ipStr)-1]
6466
}
6567

6668
result = append(result, portEntry{PID: pid, Port: port, IP: ipStr})

0 commit comments

Comments
 (0)