mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-28 11:43:50 +00:00
Refine #2162
This commit is contained in:
+8
-1
@@ -2050,6 +2050,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (mode != TCP_ONLY) {
|
||||
int num_listen_ctx = 0;
|
||||
for (int i = 0; i < server_num; i++) {
|
||||
const char *host = server_host[i];
|
||||
const char *port = server_port;
|
||||
@@ -2061,7 +2062,13 @@ main(int argc, char **argv)
|
||||
else
|
||||
LOGI("udp server listening at %s:%s", host ? host : "0.0.0.0", port);
|
||||
// Setup UDP
|
||||
init_udprelay(host, port, mtu, crypto, atoi(timeout), iface);
|
||||
int err = init_udprelay(host, port, mtu, crypto, atoi(timeout), iface);
|
||||
if (err == -1) continue;
|
||||
num_listen_ctx++;
|
||||
}
|
||||
|
||||
if (num_listen_ctx == 0) {
|
||||
FATAL("failed to listen on any address");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -1355,20 +1355,20 @@ init_udprelay(const char *server_host, const char *server_port,
|
||||
buf_size = packet_size * 2;
|
||||
}
|
||||
|
||||
// Initialize cache
|
||||
struct cache *conn_cache;
|
||||
cache_create(&conn_cache, MAX_UDP_CONN_NUM, free_cb);
|
||||
|
||||
// ////////////////////////////////////////////////
|
||||
// Setup server context
|
||||
|
||||
// Bind to port
|
||||
int serverfd = create_server_socket(server_host, server_port);
|
||||
if (serverfd < 0) {
|
||||
FATAL("[udp] bind() error");
|
||||
return -1;
|
||||
}
|
||||
setnonblocking(serverfd);
|
||||
|
||||
// Initialize cache
|
||||
struct cache *conn_cache;
|
||||
cache_create(&conn_cache, MAX_UDP_CONN_NUM, free_cb);
|
||||
|
||||
server_ctx_t *server_ctx = new_server_ctx(serverfd);
|
||||
#ifdef MODULE_REMOTE
|
||||
server_ctx->loop = loop;
|
||||
|
||||
Reference in New Issue
Block a user