rofl0r / microsocks

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

Harmonize socket address families: ipv4 vs ipv6 #50

Closed parke closed 2 years ago

parke commented 2 years ago

If -b bindaddr is used, then created sockets must be of the same address family as bindaddr (otherwise, calls to bind() will fail).

This patch harmonizes the address family across the calls to socket(), bind(), and connect().

Prior to this patch, microsocks would use the first addrinfo record returned by getaddrinfo(). On systems with both IPv4 and IPv6 enabled, frequently the address family of the first record would be a mismatch with bindaddr. As a result, the call to bind() would fail.

This patch may fix issue #30. (And issue #40?)

rofl0r commented 2 years ago

thanks, merged as 6ecc398072abf792088af2c90fc7252c05d7c94a