Skip to content

Add UWS_REMOTE_ADDRESS_USERSPACE macro for userspace remote address caching#1917

Merged
uNetworkingAB merged 4 commits intomasterfrom
copilot/add-compiler-macro-check
Mar 16, 2026
Merged

Add UWS_REMOTE_ADDRESS_USERSPACE macro for userspace remote address caching#1917
uNetworkingAB merged 4 commits intomasterfrom
copilot/add-compiler-macro-check

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 16, 2026

When UWS_REMOTE_ADDRESS_USERSPACE is defined, the remote IP is cached in per-socket data at connection time (from the on_open arguments) rather than retrieved via syscall on each getRemoteAddress() call.

Changes

  • AsyncSocketData — adds char remoteAddress[16] and int remoteAddressLength fields, guarded by #ifdef UWS_REMOTE_ADDRESS_USERSPACE
  • HttpContext on_open — copies ip/ip_length into the socket ext immediately after placement-new; validates 0 < ip_length <= 16, sets length to 0 otherwise
  • AsyncSocket::getRemoteAddress() — returns a string_view into the cached socket data under the macro; falls back to us_socket_remote_address() when undefined
// With -DUWS_REMOTE_ADDRESS_USERSPACE:
// IP is captured once on connect from on_open args, stored in AsyncSocketData.
// getRemoteAddress() reads directly from socket ext — no syscall.

// Without the macro: existing behavior unchanged.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 2 commits March 16, 2026 16:34
…per-socket data

Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com>
Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com>
Copilot AI changed the title [WIP] Add compiler macro check for remote address caching Add UWS_REMOTE_ADDRESS_USERSPACE macro for userspace remote address caching Mar 16, 2026
Copilot AI requested a review from uNetworkingAB March 16, 2026 16:36
@uNetworkingAB uNetworkingAB marked this pull request as ready for review March 16, 2026 17:19
@uNetworkingAB uNetworkingAB merged commit 2d18f69 into master Mar 16, 2026
6 checks passed
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