cactus / go-camo

A secure image proxy server
MIT License
254 stars 48 forks source link

add ability to bind to a unix domain socket #53

Closed ewdurbin closed 2 years ago

ewdurbin commented 2 years ago

Description

Hi! We (PyPI) are looking to move away from the unmaintained node version of camo. In our existing deployment infrastructure, we bind to unix domain sockets which are then exposed via managed tls proxies...

This is my novice attempt to add the ability to bind to a unix domain socket, which would allow us to rollout go-camo.

I made it an explicit flag, since http.Server doesn't natively support binding to unix:// as I am accustomed in Python, but I'm unsure if this is the ideal way forward.

This PR is mainly opened to get feedback at this stage.

Checklist

dropwhile commented 2 years ago

First off, I think this is a very reasonable feature. 👍 I haven't had a chance to review the code yet -- I try to slate some time to do so later this evening.

dropwhile commented 2 years ago

@ewdurbin I participated in the PR and added a commit that seems to accomplish what you want, and also adds the ability for slightly more graceful shutdown semantics -- which also allows the internal go server code to remove the socket file as part of graceful shutdown.

Let me know if this would suit your needs or not.

ewdurbin commented 2 years ago

Works great! Thank you for pushing it across the line.

dropwhile commented 2 years ago

Just a note — if you want to only bind to a unix socket, you can do this to not listen on the default tcp port:

go-camo -k "somekey" --socket-listen="out.sock" --listen=""