Skip to content

Conversation

pappz
Copy link
Contributor

@pappz pappz commented Oct 14, 2025

Describe your changes

Issue ticket number and link

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__

@Copilot Copilot AI review requested due to automatic review settings October 14, 2025 10:14
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request extends Darwin network monitoring functionality by adding system wakeup detection capabilities alongside the existing network change monitoring. The implementation monitors macOS system wakeups by polling the kern.sleeptime sysctl value and detecting changes that indicate the system has resumed from sleep.

  • Creates Darwin-specific network monitoring with wakeup detection
  • Separates Darwin implementation from other BSD systems
  • Adds logging for network monitoring startup

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
client/internal/networkmonitor/monitor.go Adds logging message for network monitoring startup
client/internal/networkmonitor/check_change_darwin.go New Darwin-specific implementation with route monitoring and wakeup detection
client/internal/networkmonitor/check_change_bsd.go Updates build constraint to exclude Darwin systems

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

log.Infof("Network monitor: default route changed: via %s, interface %s", route.Gw, intf)
return
case unix.RTM_DELETE:
if nexthopv4.Intf != nil && route.Gw.Compare(nexthopv4.IP) == 0 || nexthopv6.Intf != nil && route.Gw.Compare(nexthopv6.IP) == 0 {
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logical expression lacks parentheses to clarify operator precedence. Consider grouping the conditions: (nexthopv4.Intf != nil && route.Gw.Compare(nexthopv4.IP) == 0) || (nexthopv6.Intf != nil && route.Gw.Compare(nexthopv6.IP) == 0)

Suggested change
if nexthopv4.Intf != nil && route.Gw.Compare(nexthopv4.IP) == 0 || nexthopv6.Intf != nil && route.Gw.Compare(nexthopv6.IP) == 0 {
if (nexthopv4.Intf != nil && route.Gw.Compare(nexthopv4.IP) == 0) || (nexthopv6.Intf != nil && route.Gw.Compare(nexthopv6.IP) == 0) {

Copilot uses AI. Check for mistakes.

Comment on lines +204 to +206
if _, err := hasher.Write(data); err != nil {
return 0, err
}
Copy link

Copilot AI Oct 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hasher.Write() method never returns an error for FNV hash implementations. The error check is unnecessary and can be simplified to just hasher.Write(data).

Suggested change
if _, err := hasher.Write(data); err != nil {
return 0, err
}
hasher.Write(data)

Copilot uses AI. Check for mistakes.

@pappz pappz changed the title Extend Darwin network monitoring with wakeup detection [client] Extend Darwin network monitoring with wakeup detection Oct 14, 2025
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
41.7% Duplication on New Code (required ≤ 5%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant