Hey,
I'm currently working on an rclone integration that would benefit from having the ability to interact with the rcd over unix socket. This would simplify things by removing the need for HTTP authentication, removing the need for CORS and it would also enhance security in multi-user environments by not listening on localhost
. I made a quick implementation to get an idea of how much work would be involved but wanted to start a conversation here to get some feedback before spending more time on it:
$ rm -f /tmp/rclone.sock && go run rclone.go rcd --rc-net=unix --rc-addr=/tmp/rclone.sock
2022/10/19 23:26:27 NOTICE: Serving remote control on unix:/tmp/rclone.sock
$ go run rclone.go rc --unix=/tmp/rclone.sock core/pid
{
"pid": 3227748
}
Known issues:
- There's still an issue with detecting SIGINT and performing cleanup of the socket on shutdown.
- It does make changes to the shared
httplib
code so additional testing would be required to ensure all code importing it would also support unix sockets. - Add additional check to prevent
Open the files in the browser
from returning an error inrcserver.go
Feedback required:
- OS Compatibility: I think it's fine just to make a note of it in the documentation as it would be an opt in feature. If someone did happen to enable it on an unsupported system,
net.Listen
would ultimately throw an error. - Do we refactor to reuse the unix socket code already implemented in
cmd/serve/docker/unix.go
? - Where to store the socket? My first thought was to keep it simple, just piggyback off the default config dir and put it next to
rclone.conf
. - Then ideally, we would add a few global config options / flags / env vars so you'd configure it once and not have to pass flags to every
rc / rcd
command call:- Enable the functionality:
rcd_unix = true
- Change the default socket path:
rcd_unix_path = /new/path/to/rclone.sock
- Maybe add the other rc fields and call it a quality of life improvement? lol
- Enable the functionality:
Cheers,
Tom