Refactoring the names used in config file
This commit is contained in:
parent
a61c718a33
commit
dda8326592
3 changed files with 16 additions and 23 deletions
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"server":"localhost",
|
||||
"server_port":8388,
|
||||
"local_port":1080,
|
||||
"port":8388,
|
||||
"localport":1080,
|
||||
"password":"barfoo!",
|
||||
"timeout":60
|
||||
}
|
||||
}
|
||||
|
|
19
local.py
19
local.py
|
@ -125,10 +125,6 @@ if __name__ == '__main__':
|
|||
|
||||
with open('config.json', 'rb') as f:
|
||||
config = json.load(f)
|
||||
SERVER = config['server']
|
||||
REMOTE_PORT = config['server_port']
|
||||
PORT = config['local_port']
|
||||
KEY = config['password']
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description='ShadowSocks Client'
|
||||
|
@ -142,15 +138,14 @@ if __name__ == '__main__':
|
|||
sys.exit(1)
|
||||
|
||||
args = parser.parse_args()
|
||||
d = vars(args)
|
||||
_config = dict((k,d[k]) for k in d if d[k])
|
||||
config.update(_config)
|
||||
|
||||
if args.server:
|
||||
SERVER = args.server
|
||||
if args.port:
|
||||
REMOTE_PORT = args.port
|
||||
if args.key:
|
||||
KEY = args.key
|
||||
if args.localport:
|
||||
PORT = args.localport
|
||||
SERVER = config['server']
|
||||
REMOTE_PORT = config['port']
|
||||
PORT = config['localport']
|
||||
KEY = config['password']
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-8s %(message)s',
|
||||
datefmt='%Y-%m-%d %H:%M:%S', filemode='a+')
|
||||
|
|
14
server.py
14
server.py
|
@ -102,10 +102,6 @@ if __name__ == '__main__':
|
|||
with open('config.json', 'rb') as f:
|
||||
config = json.load(f)
|
||||
|
||||
SERVER = config['server']
|
||||
PORT = config['server_port']
|
||||
KEY = config['password']
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
description='ShadowSocks Server'
|
||||
)
|
||||
|
@ -116,12 +112,14 @@ if __name__ == '__main__':
|
|||
sys.exit(1)
|
||||
|
||||
args = parser.parse_args()
|
||||
d = vars(args)
|
||||
_config = dict((k,d[k]) for k in d if d[k])
|
||||
|
||||
if args.key:
|
||||
KEY = args.key
|
||||
config.update(_config)
|
||||
|
||||
if args.port:
|
||||
PORT = args.port
|
||||
SERVER = config['server']
|
||||
PORT = config['port']
|
||||
KEY = config['password']
|
||||
|
||||
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-8s %(message)s',
|
||||
datefmt='%Y-%m-%d %H:%M:%S', filemode='a+')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue