Skip to content

[client] Fix/nil relayed address #4153

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

Merged
merged 6 commits into from
Jul 15, 2025
Merged

[client] Fix/nil relayed address #4153

merged 6 commits into from
Jul 15, 2025

Conversation

pappz
Copy link
Contributor

@pappz pappz commented Jul 15, 2025

Describe your changes

Fix nil pointer in Relay conn address

Meanwhile, we create a relayed net.Conn struct instance, it is possible to set the relayedURL to nil.

panic: value method github.com/netbirdio/netbird/relay/client.RelayAddr.String called using nil *RelayAddr pointer
  • Fix relayed URL variable protection
  • Protect the channel closing

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)
  • Extended the README / documentation, if necessary

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

pappz added 2 commits July 15, 2025 17:56
…ne status

- handle the map in thread safe way
- distinguish channel close and write operations
@Copilot Copilot AI review requested due to automatic review settings July 15, 2025 16:41
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 fixes concurrency and nil pointer issues in the relay client code. The changes address a nil pointer panic that occurs when accessing the RelayAddr's String method and add proper synchronization to prevent race conditions in the peer subscription system.

  • Adds mutex protection to prevent race conditions when accessing shared maps in PeersStateSubscription
  • Refactors connection and handshake methods to properly handle RelayAddr lifecycle and prevent nil pointer access
  • Improves channel handling to use buffered channels and proper signaling instead of relying on channel closure

Reviewed Changes

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

File Description
relay/client/peer_subscription.go Adds mutex synchronization, improves channel handling with buffered channels, and enhances error handling
relay/client/client.go Refactors connection methods to return RelayAddr and adds proper instanceURL lifecycle management

@pappz pappz changed the title [client] Fix/invalid notification [client] Fix/nil relayed address Jul 15, 2025
lixmal
lixmal previously approved these changes Jul 15, 2025
@netbirdio netbirdio deleted a comment from Copilot AI Jul 15, 2025
@netbirdio netbirdio deleted a comment from Copilot AI Jul 15, 2025
Copy link

@pappz pappz merged commit b524f48 into main Jul 15, 2025
31 of 32 checks passed
@pappz pappz deleted the fix/invalid-notification branch July 15, 2025 22:00
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.

2 participants