Skip to content

hbbs: enforce outbound initiator whitelist by peer ID#1

Open
tango103 wants to merge 2 commits intomasterfrom
codex/verify-repository-and-locate-functions-in-rustdesk-server
Open

hbbs: enforce outbound initiator whitelist by peer ID#1
tango103 wants to merge 2 commits intomasterfrom
codex/verify-repository-and-locate-functions-in-rustdesk-server

Conversation

@tango103
Copy link
Copy Markdown
Owner

@tango103 tango103 commented Mar 9, 2026

Motivation

  • Add server-side enforcement so only authorized peer IDs can initiate outbound (A->B) punch-hole/relay requests while keeping inbound receive behavior unchanged.
  • Provide a simple, file-based whitelist (whitelist.txt) that is easy to edit on the server and only affects hbbs logic.

Description

  • Load whitelist.txt at hbbs startup (one ID per line, ignore empty lines and lines beginning with #) and store it in RendezvousServer::outbound_whitelist via load_outbound_whitelist.
  • Before forwarding a PunchHoleRequest in handle_punch_hole_request, resolve the source peer ID from the request SocketAddr using a new helper PeerMap::get_id_by_socket_addr and reject the request if the source ID is missing or not in the whitelist.
  • Added PeerMap::get_id_by_socket_addr to map a SocketAddr to the peer ID by scanning the in-memory PeerMap.
  • Added a template whitelist.txt and updated src/rendezvous_server.rs and src/peer.rs to implement the feature.

Testing

  • Ran rustfmt on the modified files with rustfmt --edition 2021 src/rendezvous_server.rs src/peer.rs which completed successfully.
  • Attempted cargo fmt --all which failed in this environment because the workspace member libs/hbb_common is missing, so full workspace formatting could not be performed.
  • Attempted cargo check -p hbbs which failed for the same reason (libs/hbb_common/Cargo.toml missing), so a full build/check could not be completed here.

Codex Task

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant