Skip to content

on_pre_open: add ip to the handler#251

Merged
uNetworkingAB merged 1 commit intouNetworking:masterfrom
BV-WebDev:on_pre_open
Apr 13, 2026
Merged

on_pre_open: add ip to the handler#251
uNetworkingAB merged 1 commit intouNetworking:masterfrom
BV-WebDev:on_pre_open

Conversation

@BV-WebDev
Copy link
Copy Markdown
Contributor

Related to uWS.js issue 1257.
Allows the IP to be exported in addition to the FD.

@uNetworkingAB
Copy link
Copy Markdown
Contributor

You also need to change the adopt socket call to pass along the IP to on_open

@BV-WebDev
Copy link
Copy Markdown
Contributor Author

adopt_accepted_socket calls were already passing IP along to the open handler.
I have tested these in JS and it seems to work. Do you see anything missing?

Changes summary:
uSockets: add the IP to the pre_open handler.
uWS: pass the IP to the pre_open handler.
uWS: update adoptSocket() to accept an optional IP parameter and pass it to uSockets.
uWS: update LocalCluster and addChildApp() to retrieve the IP on pre_open and pass it to adoptSocket().
uWS.js: update adoptSocket() to accept an optional IP parameter.

If someone accepts external FD, needs the IP on the request and uses the UWS_REMOTE_ADDRESS_USERSPACE cache, they have to pass the IP to adoptSocket().

@uNetworkingAB
Copy link
Copy Markdown
Contributor

If someone accepts external FD, needs the IP on the request and uses the UWS_REMOTE_ADDRESS_USERSPACE cache, they have to pass the IP to adoptSocket().

That's okay they can get it from the FD before they pass it

@uNetworkingAB uNetworkingAB merged commit 86097c4 into uNetworking:master Apr 13, 2026
@BV-WebDev BV-WebDev deleted the on_pre_open branch April 14, 2026 07:51
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