Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: do not crash if wifi is not connected #27

Merged
merged 1 commit into from
Dec 28, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/find/find.go
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ func (f *Finder) Run(args Args) error {
}
fmt.Printf("Found %d IP addresses\n", len(ipv4List))

fmt.Printf("Zear IP addresses (user: %s)...\n", args.User)
fmt.Printf("Scanning IP addresses (user: %s)...\n", args.User)
start := time.Now()
f.findArgs = args
f.totalIPs = ipv4List
10 changes: 7 additions & 3 deletions pkg/networking/networking.go
Original file line number Diff line number Diff line change
@@ -146,7 +146,7 @@ func (n *networkingManager) getIfaceToConMap() (map[string]string, error) {
return nil, fmt.Errorf("error getting network interfaces: %w", err)
}

r := regexp.MustCompile(`([\w ]+)\s+([a-z0-9-]+)\s+(\w+)\s+(\w+)`)
r := regexp.MustCompile(`([\w ]+)\s+([a-z0-9-]+)\s+(\w+)\s+([\w-]+)`)

lines := strings.Split(stdout, "\n")
data := make(map[string]string)
@@ -156,9 +156,13 @@ func (n *networkingManager) getIfaceToConMap() (map[string]string, error) {
}
matches := r.FindStringSubmatch(line)
if len(matches) < 5 {
return nil, fmt.Errorf("error parsing network interfaces: %s", line)
return nil, fmt.Errorf("error parsing network interfaces: '%s'", line)
}
// Detect if the interface is not connected
if matches[4] == "--" {
n.log.Debug().Str("name", matches[3]).Str("uuid", matches[2]).Msg("Skipping connection, no device connected")
continue
}

data[matches[4]] = matches[2]
}