mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-28 19:53:46 +00:00
fix bugs with when ss-server bind_address enabled (#725)
* SO_REUSEADDR for remote sockfd avoid ERROR: bind_to_address: Address already in use * set addr->sin_port to be 0
This commit is contained in:
@@ -91,6 +91,7 @@ int bind_to_address(int socket_fd, const char *host)
|
||||
if (host != NULL) {
|
||||
struct cork_ip ip;
|
||||
struct sockaddr_storage storage;
|
||||
memset(&storage, 0, sizeof(storage));
|
||||
if (cork_ip_init(&ip, host) != -1) {
|
||||
if (ip.version == 4) {
|
||||
struct sockaddr_in *addr = (struct sockaddr_in *)&storage;
|
||||
|
||||
@@ -415,6 +415,7 @@ static remote_t *connect_to_remote(struct addrinfo *res,
|
||||
#ifdef SO_NOSIGPIPE
|
||||
setsockopt(sockfd, SOL_SOCKET, SO_NOSIGPIPE, &opt, sizeof(opt));
|
||||
#endif
|
||||
setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
|
||||
|
||||
remote_t *remote = new_remote(sockfd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user