Commit Graph

376 Commits

Author SHA1 Message Date
Sunny 8af359ae05 Use IPNetwork supporting forbidden ip feature in config utils
This commit also make "forbidden_ip" field available in config file.
If no forbidden ip specified in command line and config file,
default to "127.0.0.0/8,::1".
2015-01-31 22:56:23 +08:00
Sunny 100ebcf064 Add IPNetwork class to support CIDR calculation
Usage:
Use IPNetwork(str|list<str>) to create an IPNetwork object.
Use operator 'in' to determine whether the specified
IP address is in the IP network or not, like:
>>> '192.168.1.1' in IPNetwork('192.168.1.0/24')
True

Both IPv4 and IPv6 address are supported.
Note: When using string to initialize the IPNetwork,
a comma seperated IP network list should be provided.

Currently, IPNetwork just support standard CIDR like:
x.x.x.x/y eg. 192.168.1.0/24
::x/y     eg. ::1/10
If pure IP address was provided,
it will be treated as implicit IP network,
like 192.168.0.0 will be treated as 192.168.0.0/16
and  192.168.1.1 will be treated as 192.168.1.1/32
This implicit translate may cause some unexpected behavior,
like user provide 192.168.2.0 and expect it will be treated as
192.168.2.0/24 but actually it will be translated to
192.168.2.0/23 because there are 9 continuous 0 from right.
In order to avoid confusion, a warning message
will be displayed when pure IP address was provided.

Other variants of CIDR are not supported yet.
2015-01-31 22:56:16 +08:00
Sunny 8783e0e9ae Move is_ip from asyncdns to common
Since implement CIDR forbidden need this function,
move it to common file seems to be a better choice.
2015-01-31 22:56:09 +08:00
clowwindy ada97ab6d9 improve comments 2015-01-31 02:58:40 +08:00
clowwindy 1f8819f790 fix #270 2015-01-23 17:33:48 +08:00
clowwindy 6efb3d00e4 fix #264 2015-01-16 18:52:40 +08:00
clowwindy bd22e3ef75 try every dll that matches by name in PATH 2015-01-16 16:50:18 +08:00
clowwindy af6c6f3f23 also search lib* for library names 2015-01-14 12:59:43 +08:00
clowwindy 5c05a74727 fix a potential name conflict 2015-01-13 00:42:27 +08:00
clowwindy 53a7e4d0e4 remove print 2015-01-12 23:21:16 +08:00
clowwindy f7316c0047 change logging level for UDP warning 2015-01-12 23:08:27 +08:00
clowwindy 4312eb9e58 add forbidden support for UDP and add tests 2015-01-12 23:02:59 +08:00
clowwindy eb94bd1cc3 support forbidden iplist 2015-01-12 22:30:03 +08:00
clowwindy 80b8bd7014 remove M2Crypto completely 2015-01-12 14:11:33 +08:00
clowwindy a4b0ea5b8f fix find_library 2015-01-12 14:08:21 +08:00
clowwindy e582b2b929 rename ctypes_* and remove salsa20-ctr 2015-01-12 14:05:20 +08:00
clowwindy 3d03dbf716 extract find_library 2015-01-12 14:00:35 +08:00
fa08c ebfd1486d8 Removing the overhead of creating a new list per event 2015-01-12 10:32:03 +08:00
fa08c 6eadfca78e Removing trailing whites 2015-01-11 15:19:31 +08:00
fa08c 3294a92a61 Search libcrypto.so in more locations
Some linux distro may store .so in some alternative locations. Now we
try harder to find them.
2015-01-10 22:26:20 +08:00
fa08c 2711002142 Merge remote-tracking branch 'upstream/master' 2015-01-10 21:27:41 +08:00
fa08c 18da3554ff Minor fix: never use except: unless you reraise 2015-01-08 08:27:28 -06:00
peter 8b2deb01d8 Set default method as bytes.
Default method as string may cause false error report.
2015-01-08 11:22:34 +08:00
fa08c 176e97bb45 Fixing some minor issues 2015-01-08 11:03:12 +08:00
clowwindy 4598e09b78 now works on OpenWRT 2015-01-07 00:25:28 +08:00
clowwindy 0bc0117cd7 update help url 2015-01-04 23:55:50 +08:00
clowwindy bac675d7f6 2015 2015-01-03 13:24:40 +08:00
clowwindy 291adf8b85 log client address 2015-01-03 12:48:03 +08:00
v3aqb d91f7d85d4 Update ctypes_libsodium.py 2014-12-28 08:30:29 +08:00
clowwindy e8501da271 fix vim 2014-12-25 16:23:43 +08:00
clowwindy 99c8bbafe7 fix fastopen and add a new test 2014-12-25 16:20:15 +08:00
clowwindy 30f4f78557 fix travis 2014-12-24 18:23:35 +08:00
clowwindy 5ea8403e56 fix daemon and add fastopen tests 2014-12-22 22:42:39 +08:00
clowwindy be1d1d5032 add SIGINT in workers 2014-12-22 17:29:58 +08:00
clowwindy 536b7d1ee6 use SIGINT instead in tests
Conflicts:
	tests/test.py
2014-12-22 17:25:39 +08:00
clowwindy 2b4c3619d6 reorder setsid and kill 2014-12-21 14:52:00 +08:00
clowwindy dae2624b30 add setsid 2014-12-21 14:49:51 +08:00
clowwindy 35c3b0b41c refine documentation 2014-12-21 14:06:28 +08:00
clowwindy 28347b685e add unit test for daemon 2014-12-21 13:46:27 +08:00
clowwindy 134497c24f implement daemon 2014-12-21 12:47:07 +08:00
clowwindy 7274c7ad96 fix comments 2014-12-18 13:34:41 +08:00
clowwindy 706a137b3f fix typo 2014-12-18 13:29:00 +08:00
clowwindy 4b0b252953 improve comments 2014-12-18 13:23:59 +08:00
clowwindy 163992b98b small fix 2014-12-12 00:04:17 +08:00
clowwindy 676bf9617b fix key cache when just method changes 2014-12-11 23:45:39 +08:00
clowwindy cbbc880f44 try to find the problem 2014-12-11 23:22:48 +08:00
clowwindy 810db996cd disable M2Crypto on Python 3 2014-12-11 22:54:49 +08:00
clowwindy 3e503bf677 log method in encrypt unit test 2014-12-11 22:43:46 +08:00
clowwindy 1459282ae6 only test some ciphers 2014-12-11 18:02:57 +08:00
clowwindy 4d5d6c7c85 add unit tests in encrypt 2014-12-11 17:47:12 +08:00
clowwindy 134bf332a4 remove domain not existed test(causing time out) 2014-12-11 14:13:58 +08:00
clowwindy e1f2046229 lint code 2014-12-11 14:09:18 +08:00
clowwindy 030cdbcec0 add asyncdns test 2014-12-11 14:08:34 +08:00
clowwindy d42a32fbc0 master should wait for child to quit 2014-12-11 13:00:08 +08:00
clowwindy e6416562fc add salsa20 and chacha20 2014-12-10 23:19:11 +08:00
clowwindy 84dcff83c1 add libsodium support 2014-12-10 23:11:22 +08:00
clowwindy fa31a233b6 add ipv6 tests 2014-11-10 15:04:30 +08:00
Bin Wang f43906006a fix str/byte issue in python 3 2014-11-10 10:37:37 +08:00
clowwindy 70dae91e7c add tests for common.py 2014-11-06 14:04:28 +08:00
clowwindy b5010df575 fix args on Python 3 2014-11-06 13:08:40 +08:00
clowwindy 6bbf347d0e Merge branch 'master' of https://github.com/jinliu/shadowsocks into jinliu-master 2014-11-05 18:48:49 +08:00
clowwindy 5209860db1 fix cipher name in test 2014-11-05 18:42:01 +08:00
clowwindy f9ba6f7390 fix table test 2014-11-05 18:40:51 +08:00
clowwindy 710fe14190 rename test_cipher as it will break unit tests 2014-11-05 18:32:01 +08:00
clowwindy 039451bcfb fix encrypt_all 2014-11-05 18:30:18 +08:00
clowwindy cbf8c6705b refactor table into a single cipher plugin 2014-11-05 18:27:18 +08:00
clowwindy 2519fb9abe Merge pull request #208 from felixonmars/table-py3
encrypt.py: port table to support python 3 (recreated)
2014-11-05 17:15:43 +08:00
Felix Yan aca86f8685 encrypt.py: port table to support python 3 2014-11-05 16:54:51 +08:00
刘缙 fb27cf52a9 Fix str/byte related TypeError in Python 3.4
Traceback (most recent call last):
File "/usr/bin/sslocal", line 9, in <module>
load_entry_point('shadowsocks==2.4', 'console_scripts', 'sslocal')()
File "/usr/lib/python3.4/site-packages/shadowsocks/local.py", line 68, in main
loop.run()
File "/usr/lib/python3.4/site-packages/shadowsocks/eventloop.py", line 230, in run
handler(events)
File "/usr/lib/python3.4/site-packages/shadowsocks/tcprelay.py", line 630, in _handle_events
handler.handle_event(sock, event)
File "/usr/lib/python3.4/site-packages/shadowsocks/tcprelay.py", line 458, in handle_event
self._on_local_read()
File "/usr/lib/python3.4/site-packages/shadowsocks/tcprelay.py", line 377, in _on_local_read
self._handle_stage_reply(data)
File "/usr/lib/python3.4/site-packages/shadowsocks/tcprelay.py", line 212, in _handle_stage_reply
s = remote_sock.sendto(data, MSG_FASTOPEN, self._chosen_server)
TypeError: 'str' does not support the buffer interface
2014-11-05 11:04:40 +08:00
clowwindy f02e9a3132 fix EVP_CIPHER_CTX_new's arg types 2014-11-02 17:13:56 +08:00
Felix Yan d971cb44a8 tcprelay.py: wrap long line for PEP8 2014-11-02 00:41:29 +08:00
Felix Yan 833c98e114 tcprelay.py: decode remote_addr to fix extra b'' in logging on python 3 2014-11-02 00:23:44 +08:00
clowwindy 90dc03c762 prefer ctypes over m2crypto in rc4-md5 2014-11-01 13:52:16 +08:00
clowwindy 4affb56d36 fix test 2014-11-01 13:24:40 +08:00
clowwindy 13c6c393db fix pyflakes 2014-11-01 13:10:19 +08:00
clowwindy 82ddafafa5 skip m2crypto tests on pypy 2014-11-01 13:03:13 +08:00
clowwindy 1205b8c50e skip m2crypto tests on Python 3 2014-11-01 12:52:51 +08:00
clowwindy 812a286f12 lint code 2014-11-01 12:44:22 +08:00
clowwindy 7bff002202 more cipher tests 2014-11-01 12:40:06 +08:00
clowwindy c69a127772 add some tests 2014-11-01 12:25:44 +08:00
clowwindy 50e5e620a3 fix version detection 2014-10-31 22:27:12 +08:00
clowwindy aff411a456 seems that dependency requires 3.3+ 2014-10-31 22:16:44 +08:00
clowwindy 0719e80fbd fix python 3.* 2014-10-31 22:08:51 +08:00
clowwindy efd45ddfc6 fix UDP server 2014-10-31 21:59:22 +08:00
clowwindy 4699de1dd9 fix python 3.2 2014-10-31 21:53:53 +08:00
clowwindy a502dd32fc fix UDP 2014-10-31 21:49:22 +08:00
clowwindy 5024b300f1 fix rc4-md5 2014-10-31 19:21:13 +08:00
clowwindy be045f1687 fix import 2014-10-31 19:10:29 +08:00
clowwindy 497524b313 drop table on Python 3 2014-10-31 19:08:00 +08:00
clowwindy 05ba3cc5aa lint code 2014-10-31 18:57:06 +08:00
clowwindy ede2b1b120 fix salsa20 on python 3 2014-10-31 18:56:24 +08:00
clowwindy f0b0c1edfa update python requirement 2014-10-31 18:45:21 +08:00
clowwindy 0fd2f30911 lint code 2014-10-31 18:43:15 +08:00
clowwindy 2a53b67c65 python 3 support; not stable yet 2014-10-31 18:28:22 +08:00
clowwindy 0814888ba5 use absolute import 2014-10-31 16:29:19 +08:00
clowwindy 89dc6031e8 lint code 2014-10-31 16:14:28 +08:00
clowwindy c553e7a725 lint code 2014-10-31 16:10:41 +08:00
clowwindy ac94104ac0 use deque instead of heapq 2014-10-31 15:49:24 +08:00
clowwindy da11d02706 fix memory leak 2014-10-31 15:14:28 +08:00
clowwindy 2461f623dd change lru behaviour; #202 2014-10-31 14:33:43 +08:00
clowwindy 9e8aa1c56a fix libcrypto on Windows 2014-10-11 00:38:19 +08:00
clowwindy eb9b6f0a9b does not require M2Crypto anymore 2014-10-08 21:03:01 +08:00
sybblow dfd4cdd758 avoid memory leak
Although fd is always the smallest number which haven't been allocated, which means memory leak is quite small. but the worst situation may consume lots of memory.
2014-09-25 20:18:02 +08:00
clowwindy dda8f31bd3 fix PEP8 2014-09-20 20:21:09 +08:00
clowwindy c668ddbc1b fix multiple ports 2014-09-20 19:57:55 +08:00
clowwindy f677c8152d close #185 2014-09-20 19:11:33 +08:00
clowwindy ab74c010fd close #183 2014-09-20 19:01:52 +08:00
clowwindy 81223902d0 fix a potential BOF 2014-09-19 01:07:10 +08:00
clowwindy 4be2731293 fix PEP8 2014-09-17 14:15:24 +08:00
clowwindy f6951c9633 fix m2 2014-09-17 13:54:33 +08:00
clowwindy d6a5c567ae lint 2014-09-17 13:52:28 +08:00
clowwindy 402bc5743b add comment about buf 2014-09-17 00:11:50 +08:00
clowwindy 0e649453ed support CTR mode 2014-09-16 23:55:50 +08:00
clowwindy 2122f96aeb lint code 2014-09-16 11:03:36 +08:00
clowwindy 76fed23b34 refactor encrypt; add cfb1 and cfb8 modes 2014-09-16 10:58:45 +08:00
clowwindy 5aece6f464 remove test in asyncdns 2014-09-14 10:17:45 +08:00
clowwindy e72594ffbe only end querying when response is of query type AAAA 2014-09-14 10:16:40 +08:00
clowwindy 3ce7c18dfb close #180 2014-09-14 10:06:16 +08:00
clowwindy 21f61c7d91 avoid removing items of the handler list while iterating over it; #179 2014-09-13 00:02:21 +08:00
clowwindy 2a61e80071 only output exception in verbose mode 2014-09-12 23:06:18 +08:00
clowwindy ea70a5bd79 exit 1 on error; #179 2014-09-12 22:20:33 +08:00
clowwindy 380a646f09 handle signal soon; #179 2014-09-12 22:18:08 +08:00
clowwindy e43520da58 log when closing port 2014-09-12 20:59:47 +08:00
clowwindy fdb3a36170 implement graceful shutdown in sslocal; close #179 2014-09-12 20:47:04 +08:00
clowwindy a6b8a5eef9 add some debug logs 2014-09-12 00:53:12 +08:00
clowwindy 327c70e353 Graceful shutdown; close #179 2014-09-12 00:51:25 +08:00
clowwindy 3e3c885a42 remove print 2014-09-09 16:18:39 +08:00
clowwindy 1044358a6b use md5 instead of sha256; #178 2014-09-09 16:17:33 +08:00
clowwindy c9b489b5e3 fix UDP 2014-09-09 14:43:32 +08:00
clowwindy 1b4e885818 add rc4-sha256; close #178 2014-09-09 14:26:34 +08:00
clowwindy 972bf22e6d fix PEP8 2014-08-27 00:17:26 +08:00
clowwindy e51aa4f137 use only ipv4 dns server 2014-08-10 12:23:44 +08:00
clowwindy ca6f72e22b better error msg 2014-08-01 17:21:43 +08:00
clowwindy 72fe18212e add quiet mode; close #164 2014-07-26 17:52:42 +08:00
clowwindy da842918bd close #158 2014-07-23 14:33:55 +08:00
clowwindy c66d9b2c20 more details 2014-07-12 17:48:33 +08:00
clowwindy e7e226768a add instructions for installing m2crypto 2014-07-12 17:45:56 +08:00
clowwindy a323f878e1 prefer addrtype 1 and 4 over 3 in UDP relay 2014-07-12 10:32:51 +08:00
clowwindy a1bc23c161 fix salsa20 2014-07-11 18:48:57 +08:00
clowwindy 2950f99da6 fix salsa20 for UDP 2014-07-11 18:46:26 +08:00
clowwindy 040c956472 fix server-multi-ports 2014-07-11 18:40:18 +08:00
clowwindy 122f233143 fix udprelay for local 2014-07-11 18:00:58 +08:00
clowwindy b0c8e50492 fix #145 2014-07-04 22:25:27 +03:00
clowwindy 13436b224e add EWOULDBLOCK to fix Windows; close #138 2014-07-04 22:01:10 +03:00
clowwindy 012ab70500 use multiple DNS instead of trying each one 2014-06-23 21:46:23 +08:00
clowwindy d4458bceb7 add timeout support in DNS 2014-06-23 21:35:39 +08:00
clowwindy 61d9e17cae remove print 2014-06-22 19:50:34 +08:00
clowwindy f9fef0e229 add TypeError 2014-06-22 11:58:22 +08:00
clowwindy 4b3c018aa9 verify hostname 2014-06-20 22:58:14 +08:00
clowwindy cb5481499e fix tcp fastopen 2014-06-20 22:32:02 +08:00