nixcloud / ip2unix

Turn IP sockets into Unix domain sockets
GNU Lesser General Public License v3.0
361 stars 10 forks source link

ip2unix socket unlinks immediately after creation #28

Open leifwalsh opened 3 years ago

leifwalsh commented 3 years ago

I'm trying to use ip2unix to make JetBrains Projector listen on a unix socket instead of an ip socket, as described in https://youtrack.jetbrains.com/issue/PRJ-278. I can put Projector behind an Envoy reverse proxy to terminate SSL and authentication/authorization, but I'm concerned that Projector will still be listening on the loopback address, which means on shared hosts, other users can connect to Projector directly without going through Envoy.

I tried wrapping Projector in ip2unix -r tcp,address=::ffff:127.0.0.1,port=8887,path=/tmp/projector.sock, but it appears that the process creates the socket file but then immediately unlinks it. I think maybe this has something to do with #16, possibly the JVM is binding the socket and then passing it to a child, or creating a child (I guess a thread) that then causes it to close.

As described in https://github.com/nixcloud/ip2unix/issues/16#issuecomment-637473455, I tried commenting out this line to prevent unlink altogether: https://github.com/nixcloud/ip2unix/blob/b54905a0699d2ff3f24d9e219655a3ad7c9b3d85/src/socket.cc#L352

If I do that, it doesn't get unlinked, but then inbound connections hang forever instead of just failing to connect.

I'm not sure what to do to get more information here.

aszlig commented 3 years ago

If I do that, it doesn't get unlinked, but then inbound connections hang forever instead of just failing to connect.

Can you please supply a run of ip2unix -vvvvv with that modification?

Additionally, can you provide a way to reproduce this in an automated test, eg. like this? I usually try to test with the affected software directly but I don't know anything about Projector.