-
Notifications
You must be signed in to change notification settings - Fork 144
Add support for Unix Sockets and allow users to create ClientConnections #187
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
Conversation
* add support for Unix Sockets to Stream/RefinedTcpStream. * add a 'pub use' for ClientConnection and Stream * convert ClientConnection::new to take Into<Stream> instead of two RefinedTcpStreams.
|
Sorry for slow feedback. This is a lot to ponder, and a bit complicated by One immediate reflection regarding PeerAddr though; For a Unix peer, isn't the socket always unnamed? Only the server_addr() can even be linked to a path? This means that remote_addr() should probably return |
|
Hi Ulrik, Thanks for taking the time to look over the patch. I believe for a Either way, the current design of having Lines 149 to 155 in 325af94
I think if we want to have Request represent either a Unix or TCP connection, we need to have an enum type to unify them, similar to the Since adding Unix socket support requires changing the return type anyways, I think converting remote_addr() to return |
From what I can tell, no. From the servers perspective (which is the case for I'm not against the PeerAddr-model as such. It's explicit = great, but I argue that that for One, much more invasive way, to implement this could be to specialize the entire TinyHttp-instance with a sockettype. I think that needs a bit more thought, though. |
|
I believe you're right. I was confusing local address and peer address. This isn't a particularly useful use case, but a C client can bind the client socket to some path before calling I agree with you that for TCP, PeerAddr is a misnomer, and calling it SocketAddr would be more generic. We should also derive all the traits we can if we use an enum. Using a type parameter for socket type would also work. I haven't deeply considered it, but I feel that would make it harder to write generic code that worked easily for both a Unix and TCP server. |
|
Any news on this? I'm interested in hosting on Unix sockets.
This is possible. I can possibly take up the patches, but is this something that the maintainers will be willing to merge? |
|
@ColonelThirtyTwo absolutely, it doesn't seem like there's any good reason not to include this, however we'll need to resolve the questions Rawler and fletcherw raise above with how we adjust the external API surface to handle these anonymous peer addresses. If you want to open another PR with a rebased branch we can continue to discuss the changes there, I can close this one redirecting it over. |
|
I feel like this has been overtaken by events, given that #224 is merged and released. |
This is a WIP patch, I'm looking for feedback to see if it's mergeable in some form.
In order to integrate tiny_http into a larger application structured around a poll loop, I've been using a patch which makes
ClientConnectionpublic and then buildsClientConnectionobjects from connections that I've received manuallyWe also needed support for
UnixStreams, so I modifiedStreamto handle that. One complication was thatUnixStreamandTcpStreamhave differentSocketAddrtypes, so I created aPeerAddrstruct in refined_tcp_stream.rs that allows returning either type fromRefinedTcpStream::peer_addr()