rofl0r / microsocks

tiny, portable SOCKS5 server with very moderate resource usage
Other
1.59k stars 277 forks source link

Some queries about the implementation of the server #31

Closed itsjfx closed 4 years ago

itsjfx commented 4 years ago

Hey, just had some thoughts looking at the code and was wondering what your thoughts on them were.

1. How come you resolve the bind address given by a user but not the listen IP? (actually in hindsight I think this is because the socket server won't run if the listen IP is bad anyway, so need to resolve) https://github.com/rofl0r/microsocks/blob/31557857ccce5e4fdd2cfdae7ab640d589aa2b41/sockssrv.c#L396 https://github.com/rofl0r/microsocks/blob/31557857ccce5e4fdd2cfdae7ab640d589aa2b41/sockssrv.c#L407

  1. Also correct me if I'm wrong, but I don't think the socket recv you use in your clientthread has a timeout: https://github.com/rofl0r/microsocks/blob/31557857ccce5e4fdd2cfdae7ab640d589aa2b41/sockssrv.c#L304 - couldn't this potentially lead to the thread hanging for a long time in some rare case? if its waiting for the client to send info such as auth, etc?

Sorry if these are noob queries I am new to socket/this type of low level programming in general so some things may not be that obvious to me.

Cheers

rofl0r commented 4 years ago

some thoughts looking at the code

if you'd single-step through the code with gdb rather than looking, you'd see that server_setup() does the resolving.

couldn't this potentially lead to the thread hanging for a long time in some rare case

indeed, i've never had any issues reported though in this regard (and never experienced any either)

itsjfx commented 4 years ago

Cool, thanks for the answers, love your work.