mirror of
https://github.com/shadowsocks/shadowsocks-libev.git
synced 2026-10-29 20:43:44 +00:00
Fix #1217
This commit is contained in:
+9
-5
@@ -159,10 +159,6 @@ construct_command_line(struct manager_ctx *manager, struct server *server)
|
||||
int len = strlen(cmd);
|
||||
snprintf(cmd + len, BUF_SIZE - len, " --fast-open");
|
||||
}
|
||||
if (manager->reuse_port) {
|
||||
int len = strlen(cmd);
|
||||
snprintf(cmd + len, BUF_SIZE - len, " --reuse-port");
|
||||
}
|
||||
if (manager->ipv6first) {
|
||||
int len = strlen(cmd);
|
||||
snprintf(cmd + len, BUF_SIZE - len, " -6");
|
||||
@@ -187,6 +183,11 @@ construct_command_line(struct manager_ctx *manager, struct server *server)
|
||||
int len = strlen(cmd);
|
||||
snprintf(cmd + len, BUF_SIZE - len, " -s %s", manager->hosts[i]);
|
||||
}
|
||||
// Always enable reuse port
|
||||
{
|
||||
int len = strlen(cmd);
|
||||
snprintf(cmd + len, BUF_SIZE - len, " --reuse-port");
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
LOGI("cmd: %s", cmd);
|
||||
@@ -434,7 +435,7 @@ static void
|
||||
get_and_release_sock_lock(char *port)
|
||||
{
|
||||
if (verbose) {
|
||||
LOGI("try to get and release sock lock at port: %s", port);
|
||||
LOGI("try to release sock lock at port: %s", port);
|
||||
}
|
||||
|
||||
sock_lock_t *sock_lock = NULL;
|
||||
@@ -635,6 +636,9 @@ remove_server(char *prefix, char *port)
|
||||
static void
|
||||
update_stat(char *port, uint64_t traffic)
|
||||
{
|
||||
if (verbose) {
|
||||
LOGI("update traffic %" PRIu64 " for port %s", traffic, port);
|
||||
}
|
||||
void *ret = cork_hash_table_get(server_table, (void *)port);
|
||||
if (ret != NULL) {
|
||||
struct server *server = (struct server *)ret;
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef UPDATE_INTERVAL
|
||||
#define UPDATE_INTERVAL 10
|
||||
#define UPDATE_INTERVAL 5
|
||||
#endif
|
||||
|
||||
/** byte size of ip4 address */
|
||||
|
||||
+6
-3
@@ -117,7 +117,7 @@ static int server_conn = 0;
|
||||
|
||||
static char *plugin = NULL;
|
||||
static char *bind_address = NULL;
|
||||
static char *server_port = NULL;
|
||||
static char *remote_port = NULL;
|
||||
static char *manager_address = NULL;
|
||||
uint64_t tx = 0;
|
||||
uint64_t rx = 0;
|
||||
@@ -142,7 +142,7 @@ stat_update_cb(EV_P_ ev_timer *watcher, int revents)
|
||||
LOGI("update traffic stat: tx: %" PRIu64 " rx: %" PRIu64 "", tx, rx);
|
||||
}
|
||||
|
||||
snprintf(resp, BUF_SIZE, "stat: {\"%s\":%" PRIu64 "}", server_port, tx + rx);
|
||||
snprintf(resp, BUF_SIZE, "stat: {\"%s\":%" PRIu64 "}", remote_port, tx + rx);
|
||||
msgLen = strlen(resp) + 1;
|
||||
|
||||
ss_addr_t ip_addr = { .host = NULL, .port = NULL };
|
||||
@@ -157,7 +157,7 @@ stat_update_cb(EV_P_ ev_timer *watcher, int revents)
|
||||
|
||||
memset(&claddr, 0, sizeof(struct sockaddr_un));
|
||||
claddr.sun_family = AF_UNIX;
|
||||
snprintf(claddr.sun_path, sizeof(claddr.sun_path), "/tmp/shadowsocks.%s", server_port);
|
||||
snprintf(claddr.sun_path, sizeof(claddr.sun_path), "/tmp/shadowsocks.%s", remote_port);
|
||||
|
||||
unlink(claddr.sun_path);
|
||||
|
||||
@@ -1345,6 +1345,7 @@ main(int argc, char **argv)
|
||||
char *conf_path = NULL;
|
||||
char *iface = NULL;
|
||||
|
||||
char *server_port = NULL;
|
||||
char *plugin_opts = NULL;
|
||||
char *plugin_port = NULL;
|
||||
char tmp_port[8];
|
||||
@@ -1558,6 +1559,8 @@ main(int argc, char **argv)
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
remote_port = server_port;
|
||||
|
||||
if (plugin != NULL) {
|
||||
uint16_t port = get_local_port();
|
||||
if (port == 0) {
|
||||
|
||||
Reference in New Issue
Block a user