Skip to content

Commit c67d275

Browse files
committed
Fix #1734
1 parent 10a2d3e commit c67d275

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

src/manager.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ destroy_server(struct server *server) {
9292
}
9393

9494
static void
95-
build_config(char *prefix, struct server *server)
95+
build_config(char *prefix, struct manager_ctx *manager, struct server *server)
9696
{
9797
char *path = NULL;
9898
int path_size = strlen(prefix) + strlen(server->port) + 20;
@@ -110,11 +110,18 @@ build_config(char *prefix, struct server *server)
110110
fprintf(f, "{\n");
111111
fprintf(f, "\"server_port\":%d,\n", atoi(server->port));
112112
fprintf(f, "\"password\":\"%s\"", server->password);
113-
if (server->fast_open[0]) fprintf(f, ",\n\"fast_open\": %s", server->fast_open);
114-
if (server->mode) fprintf(f, ",\n\"mode\":\"%s\"", server->mode);
115-
if (server->method) fprintf(f, ",\n\"method\":\"%s\"", server->method);
116-
if (server->plugin) fprintf(f, ",\n\"plugin\":\"%s\"", server->plugin);
117-
if (server->plugin_opts) fprintf(f, ",\n\"plugin_opts\":\"%s\"", server->plugin_opts);
113+
if (server->method)
114+
fprintf(f, ",\n\"method\":\"%s\"", server->method);
115+
else if (manager->method)
116+
fprintf(f, ",\n\"method\":\"%s\"", manager->method);
117+
if (server->fast_open[0])
118+
fprintf(f, ",\n\"fast_open\": %s", server->fast_open);
119+
if (server->mode)
120+
fprintf(f, ",\n\"mode\":\"%s\"", server->mode);
121+
if (server->plugin)
122+
fprintf(f, ",\n\"plugin\":\"%s\"", server->plugin);
123+
if (server->plugin_opts)
124+
fprintf(f, ",\n\"plugin_opts\":\"%s\"", server->plugin_opts);
118125
fprintf(f, "\n}\n");
119126
fclose(f);
120127
ss_free(path);
@@ -124,17 +131,17 @@ static char *
124131
construct_command_line(struct manager_ctx *manager, struct server *server)
125132
{
126133
static char cmd[BUF_SIZE];
127-
char *method = manager->method;
128134
int i;
135+
int port;
129136

130-
build_config(working_dir, server);
137+
port = atoi(server->port);
138+
139+
build_config(working_dir, manager, server);
131140

132-
if (server->method) method = server->method;
133141
memset(cmd, 0, BUF_SIZE);
134142
snprintf(cmd, BUF_SIZE,
135-
"%s -m %s --manager-address %s -f %s/.shadowsocks_%s.pid -c %s/.shadowsocks_%s.conf",
136-
executable, method, manager->manager_address,
137-
working_dir, server->port, working_dir, server->port);
143+
"%s --manager-address %s -f %s/.shadowsocks_%d.pid -c %s/.shadowsocks_%d.conf",
144+
executable, manager->manager_address, working_dir, port, working_dir, port);
138145

139146
if (manager->acl != NULL) {
140147
int len = strlen(cmd);

0 commit comments

Comments
 (0)