commit
743ddf42d5
8 changed files with 45 additions and 69 deletions
56
README.md
56
README.md
|
@ -7,10 +7,6 @@ This project is https://github.com/shadowsocks/shadowsocks clone. I JUST fix bug
|
||||||
shadowsocks
|
shadowsocks
|
||||||
===========
|
===========
|
||||||
|
|
||||||
[![PyPI version]][PyPI]
|
|
||||||
[![Build Status]][Travis CI]
|
|
||||||
[![Coverage Status]][Coverage]
|
|
||||||
|
|
||||||
A fast tunnel proxy that helps you bypass firewalls.
|
A fast tunnel proxy that helps you bypass firewalls.
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
@ -58,16 +54,6 @@ To check the log:
|
||||||
Check all the options via `-h`. You can also use a [Configuration] file
|
Check all the options via `-h`. You can also use a [Configuration] file
|
||||||
instead.
|
instead.
|
||||||
|
|
||||||
Client
|
|
||||||
------
|
|
||||||
|
|
||||||
* [Windows] / [OS X]
|
|
||||||
* [Android] / [iOS]
|
|
||||||
* [OpenWRT]
|
|
||||||
|
|
||||||
Use GUI clients on your local PC/phones. Check the README of your client
|
|
||||||
for more information.
|
|
||||||
|
|
||||||
Documentation
|
Documentation
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
@ -76,44 +62,4 @@ You can find all the documentation in the [Wiki].
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Copyright 2015 clowwindy
|
Apache License
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
not use this file except in compliance with the License. You may obtain
|
|
||||||
a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
License for the specific language governing permissions and limitations
|
|
||||||
under the License.
|
|
||||||
|
|
||||||
Bugs and Issues
|
|
||||||
----------------
|
|
||||||
|
|
||||||
* [Troubleshooting]
|
|
||||||
* [Issue Tracker]
|
|
||||||
* [Mailing list]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[Android]: https://github.com/shadowsocks/shadowsocks-android
|
|
||||||
[Build Status]: https://img.shields.io/travis/shadowsocks/shadowsocks/master.svg?style=flat
|
|
||||||
[Configuration]: https://github.com/shadowsocks/shadowsocks/wiki/Configuration-via-Config-File
|
|
||||||
[Coverage Status]: https://jenkins.shadowvpn.org/result/shadowsocks
|
|
||||||
[Coverage]: https://jenkins.shadowvpn.org/job/Shadowsocks/ws/PYENV/py34/label/linux/htmlcov/index.html
|
|
||||||
[Debian sid]: https://packages.debian.org/unstable/python/shadowsocks
|
|
||||||
[iOS]: https://github.com/shadowsocks/shadowsocks-iOS/wiki/Help
|
|
||||||
[Issue Tracker]: https://github.com/shadowsocks/shadowsocks/issues?state=open
|
|
||||||
[Install Server on Windows]: https://github.com/shadowsocks/shadowsocks/wiki/Install-Shadowsocks-Server-on-Windows
|
|
||||||
[Mailing list]: https://groups.google.com/group/shadowsocks
|
|
||||||
[OpenWRT]: https://github.com/shadowsocks/openwrt-shadowsocks
|
|
||||||
[OS X]: https://github.com/shadowsocks/shadowsocks-iOS/wiki/Shadowsocks-for-OSX-Help
|
|
||||||
[PyPI]: https://pypi.python.org/pypi/shadowsocks
|
|
||||||
[PyPI version]: https://img.shields.io/pypi/v/shadowsocks.svg?style=flat
|
|
||||||
[Travis CI]: https://travis-ci.org/shadowsocks/shadowsocks
|
|
||||||
[Troubleshooting]: https://github.com/shadowsocks/shadowsocks/wiki/Troubleshooting
|
|
||||||
[Wiki]: https://github.com/shadowsocks/shadowsocks/wiki
|
|
||||||
[Windows]: https://github.com/shadowsocks/shadowsocks-csharp
|
|
||||||
|
|
|
@ -248,7 +248,7 @@ STATUS_IPV6 = 1
|
||||||
|
|
||||||
class DNSResolver(object):
|
class DNSResolver(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self, server_list=None):
|
||||||
self._loop = None
|
self._loop = None
|
||||||
self._hosts = {}
|
self._hosts = {}
|
||||||
self._hostname_status = {}
|
self._hostname_status = {}
|
||||||
|
@ -256,8 +256,11 @@ class DNSResolver(object):
|
||||||
self._cb_to_hostname = {}
|
self._cb_to_hostname = {}
|
||||||
self._cache = lru_cache.LRUCache(timeout=300)
|
self._cache = lru_cache.LRUCache(timeout=300)
|
||||||
self._sock = None
|
self._sock = None
|
||||||
self._servers = None
|
if server_list is None:
|
||||||
self._parse_resolv()
|
self._servers = None
|
||||||
|
self._parse_resolv()
|
||||||
|
else:
|
||||||
|
self._servers = server_list
|
||||||
self._parse_hosts()
|
self._parse_hosts()
|
||||||
# TODO monitor hosts change and reload hosts
|
# TODO monitor hosts change and reload hosts
|
||||||
# TODO parse /etc/gai.conf and follow its rules
|
# TODO parse /etc/gai.conf and follow its rules
|
||||||
|
|
|
@ -117,7 +117,7 @@ def daemon_start(pid_file, log_file):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
os.setsid()
|
os.setsid()
|
||||||
signal.signal(signal.SIG_IGN, signal.SIGHUP)
|
signal.signal(signal.SIGHUP, signal.SIG_IGN)
|
||||||
|
|
||||||
print('started')
|
print('started')
|
||||||
os.kill(ppid, signal.SIGTERM)
|
os.kill(ppid, signal.SIGTERM)
|
||||||
|
|
|
@ -42,12 +42,13 @@ def main():
|
||||||
'will be ignored')
|
'will be ignored')
|
||||||
else:
|
else:
|
||||||
config['port_password'] = {}
|
config['port_password'] = {}
|
||||||
server_port = config['server_port']
|
server_port = config.get('server_port', None)
|
||||||
if type(server_port) == list:
|
if server_port:
|
||||||
for a_server_port in server_port:
|
if type(server_port) == list:
|
||||||
config['port_password'][a_server_port] = config['password']
|
for a_server_port in server_port:
|
||||||
else:
|
config['port_password'][a_server_port] = config['password']
|
||||||
config['port_password'][str(server_port)] = config['password']
|
else:
|
||||||
|
config['port_password'][str(server_port)] = config['password']
|
||||||
|
|
||||||
if config.get('manager_address', 0):
|
if config.get('manager_address', 0):
|
||||||
logging.info('entering manager mode')
|
logging.info('entering manager mode')
|
||||||
|
@ -56,7 +57,12 @@ def main():
|
||||||
|
|
||||||
tcp_servers = []
|
tcp_servers = []
|
||||||
udp_servers = []
|
udp_servers = []
|
||||||
dns_resolver = asyncdns.DNSResolver()
|
|
||||||
|
if 'dns_server' in config: # allow override settings in resolv.conf
|
||||||
|
dns_resolver = asyncdns.DNSResolver(config['dns_server'])
|
||||||
|
else:
|
||||||
|
dns_resolver = asyncdns.DNSResolver()
|
||||||
|
|
||||||
port_password = config['port_password']
|
port_password = config['port_password']
|
||||||
del config['port_password']
|
del config['port_password']
|
||||||
for port, password in port_password.items():
|
for port, password in port_password.items():
|
||||||
|
|
|
@ -84,7 +84,8 @@ def check_config(config, is_local):
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
if not is_local and not config.get('password', None) \
|
if not is_local and not config.get('password', None) \
|
||||||
and not config.get('port_password', None):
|
and not config.get('port_password', None) \
|
||||||
|
and not config.get('manager_address'):
|
||||||
logging.error('password or port_password not specified')
|
logging.error('password or port_password not specified')
|
||||||
print_help(is_local)
|
print_help(is_local)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
@ -92,7 +93,7 @@ def check_config(config, is_local):
|
||||||
if 'local_port' in config:
|
if 'local_port' in config:
|
||||||
config['local_port'] = int(config['local_port'])
|
config['local_port'] = int(config['local_port'])
|
||||||
|
|
||||||
if 'server_port' in config and type(config['server_port']) != list:
|
if config.get('server_port', None) and type(config['server_port']) != list:
|
||||||
config['server_port'] = int(config['server_port'])
|
config['server_port'] = int(config['server_port'])
|
||||||
|
|
||||||
if config.get('local_address', '') in [b'0.0.0.0']:
|
if config.get('local_address', '') in [b'0.0.0.0']:
|
||||||
|
@ -240,7 +241,7 @@ def get_config(is_local):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(e)
|
logging.error(e)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
config['server_port'] = config.get('server_port', 8388)
|
config['server_port'] = config.get('server_port', None)
|
||||||
|
|
||||||
logging.getLogger('').handlers = []
|
logging.getLogger('').handlers = []
|
||||||
logging.addLevelName(VERBOSE_LEVEL, 'VERBOSE')
|
logging.addLevelName(VERBOSE_LEVEL, 'VERBOSE')
|
||||||
|
|
|
@ -42,6 +42,7 @@ run_test python tests/test.py --with-coverage -c tests/chacha20.json
|
||||||
run_test python tests/test.py --with-coverage -c tests/table.json
|
run_test python tests/test.py --with-coverage -c tests/table.json
|
||||||
run_test python tests/test.py --with-coverage -c tests/server-multi-ports.json
|
run_test python tests/test.py --with-coverage -c tests/server-multi-ports.json
|
||||||
run_test python tests/test.py --with-coverage -s tests/aes.json -c tests/client-multi-server-ip.json
|
run_test python tests/test.py --with-coverage -s tests/aes.json -c tests/client-multi-server-ip.json
|
||||||
|
run_test python tests/test.py --with-coverage -s tests/server-dnsserver.json -c tests/client-multi-server-ip.json
|
||||||
run_test python tests/test.py --with-coverage -s tests/server-multi-passwd.json -c tests/server-multi-passwd-client-side.json
|
run_test python tests/test.py --with-coverage -s tests/server-multi-passwd.json -c tests/server-multi-passwd-client-side.json
|
||||||
run_test python tests/test.py --with-coverage -c tests/workers.json
|
run_test python tests/test.py --with-coverage -c tests/workers.json
|
||||||
run_test python tests/test.py --with-coverage -s tests/ipv6.json -c tests/ipv6-client-side.json
|
run_test python tests/test.py --with-coverage -s tests/ipv6.json -c tests/ipv6-client-side.json
|
||||||
|
|
11
tests/server-dnsserver.json
Normal file
11
tests/server-dnsserver.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"server":"127.0.0.1",
|
||||||
|
"server_port":8388,
|
||||||
|
"local_port":1081,
|
||||||
|
"password":"aes_password",
|
||||||
|
"timeout":60,
|
||||||
|
"method":"aes-256-cfb",
|
||||||
|
"local_address":"127.0.0.1",
|
||||||
|
"fast_open":false,
|
||||||
|
"dns_server": ["8.8.8.8","8.8.4.4"]
|
||||||
|
}
|
8
tests/server-multi-passwd-empty.json
Normal file
8
tests/server-multi-passwd-empty.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"server": "127.0.0.1",
|
||||||
|
"local_port": 1081,
|
||||||
|
"port_password": {
|
||||||
|
},
|
||||||
|
"timeout": 60,
|
||||||
|
"method": "aes-256-cfb"
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue