cloudfoundry / socks5-proxy

This is a go library for starting a socks5 proxy server via SSH
https://cloudfoundry.org
Apache License 2.0
49 stars 21 forks source link

Add Socks5Proxy.SetListenPort #22

Closed xor-gate closed 2 weeks ago

xor-gate commented 1 month ago

Currently the proxy dynamicly uses a listen port for the SOCKS5 channel. This PR adds functionality to set a static listen port which is needed in certain scenarios. It is a method addition and doesn't break the existing API.

linux-foundation-easycla[bot] commented 1 month ago

CLA Signed

The committers listed above are authorized under a signed CLA.

jpalermo commented 1 month ago

Could a test be added for this?

xor-gate commented 1 month ago

I added a first test to call the new SetListenPort function and test if the Addrreturns it. An extra test is needed to check what happens when the static port is already in use. Currently the server.ListenAndServe on s.port is scheduled in the background with any feedback. Also it is currently not possible to gracefull stop the server. But then this PR would probably be a lot bigger change. Let met know what you think. Probably the best thing to do is check if the ListenAndServe returns and write in a channel the failure. Then set s.port back to zero. But i'm dusting off my Golang skills.

xor-gate commented 1 month ago

Also the used unittest framework is a little complex at first sight. I was used to the more simple github.com/stretchr/testify.

xor-gate commented 2 weeks ago

Thanks!