-
-
Notifications
You must be signed in to change notification settings - Fork 306
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
Feature: listen on unix domain sockets #935
base: master
Are you sure you want to change the base?
Feature: listen on unix domain sockets #935
Conversation
Signed-off-by: Ayrton Sparling <[email protected]>
Signed-off-by: Ayrton Sparling <[email protected]>
Signed-off-by: Ayrton Sparling <[email protected]>
Signed-off-by: Ayrton Sparling <[email protected]>
Signed-off-by: Ayrton Sparling <[email protected]>
Hey, is this still WIP? Would you like to add some tests and rebase and then I can take a proper look at this? |
Wasn't looking forward to fixing the tests. Let me try to finish this up by today/tomorrow. |
Signed-off-by: Ayrton Sparling <[email protected]>
Signed-off-by: Ayrton Sparling <[email protected]>
Ready for review. I moved the tests so that the working directory is set to the tmpdir of each test. This required tls files to be copied into a test's tmpdir so it could access them. This was mainly done so each test could create a socket file in their own directory. If you'd like any changes please let me know. |
Not sure why checks are failing. Same command succeeds on my machine. |
Add support for listening on unix domain sockets
Synopsis
Initial conversations converged on using the
--port
argument but after attempting to implement this,--interface
seemed more promising based on the current code structure. Also, a unix socket is more similar to an interface than a port so this made sense logically as well.Interface arguments are now parsed into an
Interface
enum consisting of either aInterface::Address
(IP address) orInterface::Path
(Unix socket path). If an interface argument starts with a.
or/
it is considered aInterface::Path
.Currently the code does not clean up the socket file it creates. I'm not really sure what the desired behavior should be. Perhaps if miniserve creates the socket file, it should also delete it on shutdown. But then again what if another, different process is listening on the socket file... This does not cause any issues with starting miniserve up again since miniserve will use an existing socket file.
You can listen on both unix sockets and tcp sockets at the same time when given more than one
--interface
flag.Tests
As for test code there is only one added test to ensure we don't overwrite non-socket files. I tried to get a
GET
test working but it keeps throwing an error about serve path even though it is provided. The non working test is commented out intests/bind.rs
.A test for IPv6 binding is failing but seems to work in manual testing. Not sure what is going on there.
Testing
An easy way to test this is to use the following commands:
You can also test in your browser using socat as a TCP->UNIX proxy:
Todo
Let me know if you have any questions or changes you'd like.