diff --git a/src/local.c b/src/local.c index 6e9f152c..12e154c9 100644 --- a/src/local.c +++ b/src/local.c @@ -1629,6 +1629,11 @@ main(int argc, char **argv) ev_signal_init(&sigchld_watcher, signal_cb, SIGCHLD); ev_signal_start(EV_DEFAULT, &sigchld_watcher); + if (strcmp(local_addr, ":") > 0) + LOGI("listening at [%s]:%s", local_addr, local_port); + else + LOGI("listening at %s:%s", local_addr, local_port); + struct ev_loop *loop = EV_DEFAULT; if (mode != UDP_ONLY) { @@ -1674,11 +1679,6 @@ main(int argc, char **argv) else #endif - if (strcmp(local_addr, ":") > 0) - LOGI("listening at [%s]:%s", local_addr, local_port); - else - LOGI("listening at %s:%s", local_addr, local_port); - // setuid if (user != NULL && !run_as(user)) { FATAL("failed to switch user"); @@ -1795,6 +1795,11 @@ _start_ss_local_server(profile_t profile, ss_local_callback callback, void *udat listen_ctx.iface = NULL; listen_ctx.mptcp = mptcp; + if (strcmp(local_addr, ":") > 0) + LOGI("listening at [%s]:%s", local_addr, local_port_str); + else + LOGI("listening at %s:%s", local_addr, local_port_str); + if (mode != UDP_ONLY) { // Setup socket int listenfd; @@ -1823,11 +1828,6 @@ _start_ss_local_server(profile_t profile, ss_local_callback callback, void *udat get_sockaddr_len(addr), mtu, crypto, timeout, NULL); } - if (strcmp(local_addr, ":") > 0) - LOGI("listening at [%s]:%s", local_addr, local_port_str); - else - LOGI("listening at %s:%s", local_addr, local_port_str); - // Init connections cork_dllist_init(&connections); diff --git a/src/redir.c b/src/redir.c index f94f07ac..65f7f838 100644 --- a/src/redir.c +++ b/src/redir.c @@ -1236,6 +1236,13 @@ main(int argc, char **argv) listen_ctx_t *listen_ctx_current = &listen_ctx; do { + + if (listen_ctx_current->tos) { + LOGI("listening at %s:%s (TOS 0x%x)", local_addr, local_port, listen_ctx_current->tos); + } else { + LOGI("listening at %s:%s", local_addr, local_port); + } + if (mode != UDP_ONLY) { // Setup socket int listenfd; @@ -1273,12 +1280,6 @@ main(int argc, char **argv) LOGI("TCP relay disabled"); } - if (listen_ctx_current->tos) { - LOGI("listening at %s:%s (TOS 0x%x)", local_addr, local_port, listen_ctx_current->tos); - } else { - LOGI("listening at %s:%s", local_addr, local_port); - } - // Handle additionals TOS/DSCP listening ports if (dscp_num > 0) { listen_ctx_current = (listen_ctx_t *)ss_malloc(sizeof(listen_ctx_t)); diff --git a/src/server.c b/src/server.c index 6af84a7e..be7db43f 100644 --- a/src/server.c +++ b/src/server.c @@ -1845,6 +1845,11 @@ main(int argc, char **argv) host = "127.0.0.1"; } + if (host && strcmp(host, ":") > 0) + LOGI("tcp server listening at [%s]:%s", host, server_port); + else + LOGI("tcp server listening at %s:%s", host ? host : "0.0.0.0", server_port); + // Bind to port int listenfd; listenfd = create_and_bind(host, server_port, mptcp); @@ -1867,11 +1872,6 @@ main(int argc, char **argv) ev_io_init(&listen_ctx->io, accept_cb, listenfd, EV_READ); ev_io_start(loop, &listen_ctx->io); - if (host && strcmp(host, ":") > 0) - LOGI("tcp server listening at [%s]:%s", host, server_port); - else - LOGI("tcp server listening at %s:%s", host ? host : "0.0.0.0", server_port); - if (plugin != NULL) break; } @@ -1884,12 +1884,12 @@ main(int argc, char **argv) if (plugin != NULL) { port = plugin_port; } - // Setup UDP - init_udprelay(host, port, mtu, crypto, atoi(timeout), iface); if (host && strcmp(host, ":") > 0) LOGI("udp server listening at [%s]:%s", host, port); 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); } } diff --git a/src/tunnel.c b/src/tunnel.c index 7b3abcb0..27573c14 100644 --- a/src/tunnel.c +++ b/src/tunnel.c @@ -1108,6 +1108,8 @@ main(int argc, char **argv) listen_ctx.iface = iface; listen_ctx.mptcp = mptcp; + LOGI("listening at %s:%s", local_addr, local_port); + struct ev_loop *loop = EV_DEFAULT; if (mode != UDP_ONLY) { @@ -1147,8 +1149,6 @@ main(int argc, char **argv) LOGI("TCP relay disabled"); } - LOGI("listening at %s:%s", local_addr, local_port); - // setuid if (user != NULL && !run_as(user)) { FATAL("failed to switch user");