[GH-ISSUE #3057] [Feature] Expose the local address of a socket for request handling #1123

Open
opened 2026-03-16 01:40:31 +03:00 by kerem · 2 comments
Owner

Originally created by @Tibso on GitHub (Jun 16, 2025).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/3057

Is your feature request related to a problem?

I would like to sort incoming requests based on the socket they originate from.

However, currently, there is no way to identify which socket a request is coming from.

As a result, I am forced to run multiple server instances, each with its own set of registered sockets, which is inefficient and cumbersome.

Describe the solution you'd like.

I'd like to expose sockets local addresses from register_socket() and register_listener() to inside the Request struct via handle_raw_request() and handle_request().

With this change, we would be able for example to request.socket_local_addr from inside handle_request() or handle_response(), and therefore be able to identify which socket the request came from.

I have to look more into it because using the Request struct for this doesn't make much sense.
There must be a smarter way to do this.

There might also be a smarter/more efficient way to identify a socket than to keep a SocketAddr around.

I will be working on a PR in an attempt to add this functionality.
I'll try to add examples here using Request, just to get an idea.

In the meantime, I'd like to know what people think about this or if people have more insight about this.

Originally created by @Tibso on GitHub (Jun 16, 2025). Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/3057 ***Is your feature request related to a problem?*** I would like to sort incoming requests based on the socket they originate from. However, currently, there is no way to identify which socket a request is coming from. As a result, I am forced to run multiple server instances, each with its own set of registered sockets, which is inefficient and cumbersome. ***Describe the solution you'd like.*** I'd like to expose sockets local addresses from `register_socket()` and `register_listener()` to inside the `Request` struct via `handle_raw_request()` and `handle_request()`. With this change, we would be able ***for example*** to `request.socket_local_addr` from inside `handle_request()` or `handle_response()`, and therefore be able to identify which socket the request came from. I have to look more into it because using the `Request` struct for this doesn't make much sense. There must be a smarter way to do this. There might also be a smarter/more efficient way to identify a socket than to keep a `SocketAddr` around. I will be working on a PR in an attempt to add this functionality. I'll try to add examples here using `Request`, just to get an idea. In the meantime, I'd like to know what people think about this or if people have more insight about this.
Author
Owner

@djc commented on GitHub (Jun 17, 2025):

As a result, I am forced to run multiple server instances, each with its own set of registered sockets, which is inefficient and cumbersome.

What exactly about this is inefficient, and does it really need to be cumbersome?

<!-- gh-comment-id:2979373539 --> @djc commented on GitHub (Jun 17, 2025): > As a result, I am forced to run multiple server instances, each with its own set of registered sockets, which is inefficient and cumbersome. What exactly about this is inefficient, and does it really need to be cumbersome?
Author
Owner

@marcus0x62 commented on GitHub (Jun 26, 2025):

I would like to sort incoming requests based on the socket they originate from.

Why do you want to do this?

<!-- gh-comment-id:3008381190 --> @marcus0x62 commented on GitHub (Jun 26, 2025): > I would like to sort incoming requests based on the socket they originate from. Why do you want to do this?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/hickory-dns#1123
No description provided.