Browse Source

listen at server; show warnings

1.4
clowwindy 12 years ago
parent
commit
29c4fd7de9
  1. 4
      CHANGES
  2. 2
      README.md
  3. 2
      README.rst
  4. 2
      setup.py
  5. 30
      shadowsocks/local.py
  6. 27
      shadowsocks/server.py
  7. 8
      shadowsocks/utils.py
  8. 2
      test.py

4
CHANGES

@ -1,3 +1,7 @@
1.3.2 2013-07-04
- Server will listen at server IP specified in config
- Check config file and show some warning messages
1.3.1 2013-06-29
- Fix -c arg

2
README.md

@ -2,7 +2,7 @@ shadowsocks
===========
[![Build Status](https://travis-ci.org/clowwindy/shadowsocks.png)](https://travis-ci.org/clowwindy/shadowsocks)
Current version: 1.3.1
Current version: 1.3.2
shadowsocks is a lightweight tunnel proxy which can help you get through firewalls

2
README.rst

@ -1,7 +1,7 @@
shadowsocks
===========
|Build Status| Current version: 1.3.1
|Build Status|
shadowsocks is a lightweight tunnel proxy which can help you get through
firewalls

2
setup.py

@ -6,7 +6,7 @@ with open('README.rst') as f:
setup(
name = "shadowsocks",
version = "1.3.1",
version = "1.3.2",
license = 'MIT',
description = "a lightweight tunnel proxy",
author = 'clowwindy',

30
shadowsocks/local.py

@ -178,40 +178,42 @@ def main():
logging.info('loading config from %s' % config_path)
with open(config_path, 'rb') as f:
config = json.load(f)
SERVER = config['server']
REMOTE_PORT = config['server_port']
PORT = config['local_port']
KEY = config['password']
METHOD = config.get('method', None)
LOCAL = config.get('local', '')
optlist, args = getopt.getopt(sys.argv[1:], 's:b:p:k:l:m:c:6')
for key, value in optlist:
if key == '-p':
REMOTE_PORT = int(value)
config['server_port'] = int(value)
elif key == '-k':
KEY = value
config['password'] = value
elif key == '-l':
PORT = int(value)
config['local_port'] = int(value)
elif key == '-s':
SERVER = value
config['server'] = value
elif key == '-m':
METHOD = value
config['method'] = value
elif key == '-b':
LOCAL = value
config['local'] = value
elif key == '-6':
IPv6 = True
SERVER = config['server']
REMOTE_PORT = config['server_port']
PORT = config['local_port']
KEY = config['password']
METHOD = config.get('method', None)
LOCAL = config.get('local', '')
if not KEY and not config_path:
sys.exit('config not specified, please read https://github.com/clowwindy/shadowsocks')
utils.check_config(config)
encrypt.init_table(KEY, METHOD)
try:
if IPv6:
ThreadingTCPServer.address_family = socket.AF_INET6
server = ThreadingTCPServer((LOCAL, PORT), Socks5Server)
logging.info("starting server at %s:%d" % tuple(server.server_address[:2]))
logging.info("starting local at %s:%d" % tuple(server.server_address[:2]))
server.serve_forever()
except socket.error, e:
logging.error(e)

27
shadowsocks/server.py

@ -144,7 +144,7 @@ def main():
IPv6 = False
config_path = utils.find_config()
optlist, args = getopt.getopt(sys.argv[1:], 'p:k:m:c:6')
optlist, args = getopt.getopt(sys.argv[1:], 's:p:k:m:c:6')
for key, value in optlist:
if key == '-c':
config_path = value
@ -153,31 +153,36 @@ def main():
with open(config_path, 'rb') as f:
config = json.load(f)
logging.info('loading config from %s' % config_path)
SERVER = config['server']
PORT = config['server_port']
KEY = config['password']
METHOD = config.get('method', None)
optlist, args = getopt.getopt(sys.argv[1:], 'p:k:m:c:6')
optlist, args = getopt.getopt(sys.argv[1:], 's:p:k:m:c:6')
for key, value in optlist:
if key == '-p':
PORT = int(value)
config['server_port'] = int(value)
elif key == '-k':
KEY = value
config['password'] = value
elif key == '-s':
config['server'] = value
elif key == '-m':
METHOD = value
config['method'] = value
elif key == '-6':
IPv6 = True
SERVER = config['server']
PORT = config['server_port']
KEY = config['password']
METHOD = config.get('method', None)
if not KEY and not config_path:
sys.exit('config not specified, please read https://github.com/clowwindy/shadowsocks')
utils.check_config(config)
encrypt.init_table(KEY, METHOD)
if IPv6:
ThreadingTCPServer.address_family = socket.AF_INET6
try:
server = ThreadingTCPServer(('', PORT), Socks5Server)
logging.info("starting server at port %d ..." % PORT)
server = ThreadingTCPServer((SERVER, PORT), Socks5Server)
logging.info("starting server at %s:%d" % tuple(server.server_address[:2]))
server.serve_forever()
except socket.error, e:
logging.error(e)

8
shadowsocks/utils.py

@ -2,6 +2,7 @@
# -*- coding: utf-8 -*-
import os
import logging
def find_config():
@ -12,3 +13,10 @@ def find_config():
if os.path.exists(config_path):
return config_path
return None
def check_config(config):
if config.get('server', '') in ['127.0.0.1', 'localhost']:
logging.warn('Server is set to "%s", maybe it\'s not correct' % config['server'])
logging.warn('Notice server will listen at %s:%s' % (config['server'], config['server_port']))
if (config.get('method', '') or '').lower() == 'rc4':
logging.warn('RC4 is not safe; please use a safer cipher, like AES-256-CFB')

2
test.py

@ -101,7 +101,7 @@ try:
for fd in r:
line = fd.readline()
sys.stdout.write(line)
if line.find('starting server') >= 0:
if line.find('starting') >= 0:
ready_count += 1
if ready_count == 2 and p3 is None:

Loading…
Cancel
Save