@@ -92,7 +92,7 @@ destroy_server(struct server *server) {
92
92
}
93
93
94
94
static void
95
- build_config (char * prefix , struct server * server )
95
+ build_config (char * prefix , struct manager_ctx * manager , struct server * server )
96
96
{
97
97
char * path = NULL ;
98
98
int path_size = strlen (prefix ) + strlen (server -> port ) + 20 ;
@@ -110,11 +110,18 @@ build_config(char *prefix, struct server *server)
110
110
fprintf (f , "{\n" );
111
111
fprintf (f , "\"server_port\":%d,\n" , atoi (server -> port ));
112
112
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 );
118
125
fprintf (f , "\n}\n" );
119
126
fclose (f );
120
127
ss_free (path );
@@ -124,17 +131,17 @@ static char *
124
131
construct_command_line (struct manager_ctx * manager , struct server * server )
125
132
{
126
133
static char cmd [BUF_SIZE ];
127
- char * method = manager -> method ;
128
134
int i ;
135
+ int port ;
129
136
130
- build_config (working_dir , server );
137
+ port = atoi (server -> port );
138
+
139
+ build_config (working_dir , manager , server );
131
140
132
- if (server -> method ) method = server -> method ;
133
141
memset (cmd , 0 , BUF_SIZE );
134
142
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 );
138
145
139
146
if (manager -> acl != NULL ) {
140
147
int len = strlen (cmd );
0 commit comments