@@ -70,9 +70,9 @@ def find_config():
70
70
71
71
def check_config (config ):
72
72
if config .get ('local_address' , '' ) in [b'0.0.0.0' ]:
73
- logging .warn ('warning: local set to listen 0.0.0.0, which is not safe' )
73
+ logging .warn ('warning: local set to listen on 0.0.0.0, it \' s not safe' )
74
74
if config .get ('server' , '' ) in [b'127.0.0.1' , b'localhost' ]:
75
- logging .warn ('warning: server set to listen %s:%s, are you sure?' %
75
+ logging .warn ('warning: server set to listen on %s:%s, are you sure?' %
76
76
(config ['server' ], config ['server_port' ]))
77
77
if (config .get ('method' , '' ) or '' ).lower () == b'table' :
78
78
logging .warn ('warning: table is not safe; please use a safer cipher, '
@@ -96,11 +96,11 @@ def get_config(is_local):
96
96
logging .basicConfig (level = logging .INFO ,
97
97
format = '%(levelname)-s: %(message)s' )
98
98
if is_local :
99
- shortopts = 'hs :b:p:k:l:m:c:t:vq'
100
- longopts = ['fast-open' ]
99
+ shortopts = 'hd:s :b:p:k:l:m:c:t:vq'
100
+ longopts = ['help' , ' fast-open' , 'pid-file=' , 'log-file= ' ]
101
101
else :
102
- shortopts = 'hs :p:k:m:c:t:vq'
103
- longopts = ['fast-open' , 'workers=' ]
102
+ shortopts = 'hd:s :p:k:m:c:t:vq'
103
+ longopts = ['help' , ' fast-open' , 'pid-file=' , 'log-file= ' , 'workers=' ]
104
104
try :
105
105
config_path = find_config ()
106
106
optlist , args = getopt .getopt (sys .argv [1 :], shortopts , longopts )
@@ -146,12 +146,18 @@ def get_config(is_local):
146
146
config ['fast_open' ] = True
147
147
elif key == '--workers' :
148
148
config ['workers' ] = int (value )
149
- elif key == '-h' :
149
+ elif key in ( '-h' , '--help' ) :
150
150
if is_local :
151
151
print_local_help ()
152
152
else :
153
153
print_server_help ()
154
154
sys .exit (0 )
155
+ elif key == '-d' :
156
+ config ['daemon' ] = value
157
+ elif key == '--pid-file' :
158
+ config ['pid-file' ] = value
159
+ elif key == '--log-file' :
160
+ config ['log-file' ] = value
155
161
elif key == '-q' :
156
162
v_count -= 1
157
163
config ['verbose' ] = v_count
@@ -171,6 +177,9 @@ def get_config(is_local):
171
177
config ['timeout' ] = int (config .get ('timeout' , 300 ))
172
178
config ['fast_open' ] = config .get ('fast_open' , False )
173
179
config ['workers' ] = config .get ('workers' , 1 )
180
+ config ['pid-file' ] = config .get ('pid-file' , '/var/run/shadowsocks.pid' )
181
+ config ['log-file' ] = config .get ('log-file' , '/var/log/shadowsocks.log' )
182
+ config ['workers' ] = config .get ('workers' , 1 )
174
183
config ['verbose' ] = config .get ('verbose' , False )
175
184
config ['local_address' ] = config .get ('local_address' , '127.0.0.1' )
176
185
config ['local_port' ] = config .get ('local_port' , 1080 )
@@ -231,21 +240,29 @@ def print_help(is_local):
231
240
def print_local_help ():
232
241
print ('''usage: sslocal [-h] -s SERVER_ADDR [-p SERVER_PORT]
233
242
[-b LOCAL_ADDR] [-l LOCAL_PORT] -k PASSWORD [-m METHOD]
234
- [-t TIMEOUT] [-c CONFIG] [--fast-open] [-v] [-q]
235
-
236
- optional arguments:
237
- -h, --help show this help message and exit
238
- -s SERVER_ADDR server address
239
- -p SERVER_PORT server port, default: 8388
240
- -b LOCAL_ADDR local binding address, default: 127.0.0.1
241
- -l LOCAL_PORT local port, default: 1080
242
- -k PASSWORD password
243
- -m METHOD encryption method, default: aes-256-cfb
244
- -t TIMEOUT timeout in seconds, default: 300
245
- -c CONFIG path to config file
246
- --fast-open use TCP_FASTOPEN, requires Linux 3.7+
247
- -v, -vv verbose mode
248
- -q, -qq quiet mode, only show warnings/errors
243
+ [-t TIMEOUT] [-c CONFIG] [--fast-open] [-v] -[d] [-q]
244
+ A fast tunnel proxy that helps you bypass firewalls.
245
+
246
+ You can supply configurations via either config file or command line arguments.
247
+
248
+ Proxy options:
249
+ -h, --help show this help message and exit
250
+ -c CONFIG path to config file
251
+ -s SERVER_ADDR server address
252
+ -p SERVER_PORT server port, default: 8388
253
+ -b LOCAL_ADDR local binding address, default: 127.0.0.1
254
+ -l LOCAL_PORT local port, default: 1080
255
+ -k PASSWORD password
256
+ -m METHOD encryption method, default: aes-256-cfb
257
+ -t TIMEOUT timeout in seconds, default: 300
258
+ --fast-open use TCP_FASTOPEN, requires Linux 3.7+
259
+
260
+ General options:
261
+ -d start/stop/restart daemon mode
262
+ --pid-file PID_FILE pid file for daemon mode
263
+ --log-file LOG_FILE log file for daemon mode
264
+ -v, -vv verbose mode
265
+ -q, -qq quiet mode, only show warnings/errors
249
266
250
267
Online help: <https://github.com/clowwindy/shadowsocks>
251
268
''' )
@@ -254,20 +271,28 @@ def print_local_help():
254
271
def print_server_help ():
255
272
print ('''usage: ssserver [-h] [-s SERVER_ADDR] [-p SERVER_PORT] -k PASSWORD
256
273
-m METHOD [-t TIMEOUT] [-c CONFIG] [--fast-open]
257
- [--workers WORKERS] [-v] [-q]
258
-
259
- optional arguments:
260
- -h, --help show this help message and exit
261
- -s SERVER_ADDR server address, default: 0.0.0.0
262
- -p SERVER_PORT server port, default: 8388
263
- -k PASSWORD password
264
- -m METHOD encryption method, default: aes-256-cfb
265
- -t TIMEOUT timeout in seconds, default: 300
266
- -c CONFIG path to config file
267
- --fast-open use TCP_FASTOPEN, requires Linux 3.7+
268
- --workers WORKERS number of workers, available on Unix/Linux
269
- -v, -vv verbose mode
270
- -q, -qq quiet mode, only show warnings/errors
274
+ [--workers WORKERS] [-v] [-d start] [-q]
275
+ A fast tunnel proxy that helps you bypass firewalls.
276
+
277
+ You can supply configurations via either config file or command line arguments.
278
+
279
+ Proxy options:
280
+ -h, --help show this help message and exit
281
+ -c CONFIG path to config file
282
+ -s SERVER_ADDR server address, default: 0.0.0.0
283
+ -p SERVER_PORT server port, default: 8388
284
+ -k PASSWORD password
285
+ -m METHOD encryption method, default: aes-256-cfb
286
+ -t TIMEOUT timeout in seconds, default: 300
287
+ --fast-open use TCP_FASTOPEN, requires Linux 3.7+
288
+ --workers WORKERS number of workers, available on Unix/Linux
289
+
290
+ General options:
291
+ -d start/stop/restart daemon mode
292
+ --pid-file PID_FILE pid file for daemon mode
293
+ --log-file LOG_FILE log file for daemon mode
294
+ -v, -vv verbose mode
295
+ -q, -qq quiet mode, only show warnings/errors
271
296
272
297
Online help: <https://github.com/clowwindy/shadowsocks>
273
298
''' )
0 commit comments