mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-30 22:13:49 +00:00
Fix #1915
This commit is contained in:
+3
-3
@@ -110,8 +110,9 @@ static void close_and_free_server(EV_P_ server_t *server);
|
||||
static void resolv_cb(struct sockaddr *addr, void *data);
|
||||
static void resolv_free_cb(void *data);
|
||||
|
||||
int verbose = 0;
|
||||
int reuse_port = 0;
|
||||
int verbose = 0;
|
||||
int reuse_port = 0;
|
||||
char *local_addr = NULL;
|
||||
|
||||
static crypto_t *crypto;
|
||||
|
||||
@@ -128,7 +129,6 @@ static int remote_conn = 0;
|
||||
static int server_conn = 0;
|
||||
|
||||
static char *plugin = NULL;
|
||||
static char *local_addr = NULL;
|
||||
static char *remote_port = NULL;
|
||||
static char *manager_addr = NULL;
|
||||
uint64_t tx = 0;
|
||||
|
||||
+31
-7
@@ -97,6 +97,7 @@ extern int reuse_port;
|
||||
#ifdef MODULE_REMOTE
|
||||
extern uint64_t tx;
|
||||
extern uint64_t rx;
|
||||
extern char *local_addr;
|
||||
#endif
|
||||
|
||||
static int packet_size = DEFAULT_PACKET_SIZE;
|
||||
@@ -358,10 +359,22 @@ create_remote_socket(int ipv6)
|
||||
ERROR("[udp] cannot create socket");
|
||||
return -1;
|
||||
}
|
||||
if (bind(remote_sock, (struct sockaddr *)&addr, sizeof(addr)) != 0) {
|
||||
FATAL("[udp] cannot bind remote");
|
||||
return -1;
|
||||
#ifdef MODULE_REMOTE
|
||||
if (local_addr != NULL) {
|
||||
if (bind_to_address(remote_sock, local_addr) == -1) {
|
||||
ERROR("bind_to_address");
|
||||
FATAL("[udp] cannot bind remote");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
if (bind(remote_sock, (struct sockaddr *)&addr, sizeof(addr)) != 0) {
|
||||
FATAL("[udp] cannot bind remote");
|
||||
return -1;
|
||||
}
|
||||
#ifdef MODULE_REMOTE
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
// Or else bind to IPv4
|
||||
struct sockaddr_in addr;
|
||||
@@ -374,11 +387,22 @@ create_remote_socket(int ipv6)
|
||||
ERROR("[udp] cannot create socket");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (bind(remote_sock, (struct sockaddr *)&addr, sizeof(addr)) != 0) {
|
||||
FATAL("[udp] cannot bind remote");
|
||||
return -1;
|
||||
#ifdef MODULE_REMOTE
|
||||
if (local_addr != NULL) {
|
||||
if (bind_to_address(remote_sock, local_addr) == -1) {
|
||||
ERROR("bind_to_address");
|
||||
FATAL("[udp] cannot bind remote");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
if (bind(remote_sock, (struct sockaddr *)&addr, sizeof(addr)) != 0) {
|
||||
FATAL("[udp] cannot bind remote");
|
||||
return -1;
|
||||
}
|
||||
#ifdef MODULE_REMOTE
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return remote_sock;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user