Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b7ab23f78 | ||
|
|
0e14f3bbef | ||
|
|
42ce2569c4 | ||
|
|
581d6e687f | ||
|
|
d774286dc0 | ||
|
|
cb7062e1c1 | ||
|
|
48ddc1714b | ||
|
|
dfd81af844 | ||
|
|
783a6ef7f2 | ||
|
|
e71ce6c758 | ||
|
|
e564f17505 | ||
|
|
6d09cd21ca | ||
|
|
318d88ec89 | ||
|
|
ce805f0aea |
+2
-1
@@ -11,10 +11,11 @@ before_install:
|
|||||||
- sudo apt-get update -qq
|
- sudo apt-get update -qq
|
||||||
- sudo apt-get install -qq build-essential dnsutils iproute nginx bc
|
- sudo apt-get install -qq build-essential dnsutils iproute nginx bc
|
||||||
- sudo dd if=/dev/urandom of=/usr/share/nginx/www/file bs=1M count=10
|
- sudo dd if=/dev/urandom of=/usr/share/nginx/www/file bs=1M count=10
|
||||||
|
- sudo sh -c "echo '127.0.0.1 localhost' > /etc/hosts"
|
||||||
- sudo service nginx restart
|
- sudo service nginx restart
|
||||||
- pip install pep8 pyflakes nose coverage
|
- pip install pep8 pyflakes nose coverage
|
||||||
- sudo tests/socksify/install.sh
|
- sudo tests/socksify/install.sh
|
||||||
- sudo tests/libsodium/install.sh
|
- sudo tests/libsodium/install.sh
|
||||||
- sudo tests/setup_tc.sh
|
- sudo tests/setup_tc.sh
|
||||||
script:
|
script:
|
||||||
- ./.jenkins.sh
|
- tests/jenkins.sh
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
2.6.8 2015-02-10
|
||||||
|
- Support multiple server ip on client side
|
||||||
|
- Support --version
|
||||||
|
- Minor fixes
|
||||||
|
|
||||||
2.6.7 2015-02-02
|
2.6.7 2015-02-02
|
||||||
- Support --user
|
- Support --user
|
||||||
- Support CIDR format in --forbidden-ip
|
- Support CIDR format in --forbidden-ip
|
||||||
|
|||||||
@@ -1,21 +1,202 @@
|
|||||||
Shadowsocks
|
|
||||||
|
|
||||||
Copyright (c) 2012-2015 clowwindy
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in
|
1. Definitions.
|
||||||
all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
the copyright owner that is granting the License.
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
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.
|
||||||
|
|||||||
@@ -62,7 +62,20 @@ You can find all the documentation in the [Wiki].
|
|||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
MIT
|
|
||||||
|
Copyright 2015 clowwindy
|
||||||
|
|
||||||
|
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
|
Bugs and Issues
|
||||||
----------------
|
----------------
|
||||||
|
|||||||
+15
-1
@@ -81,7 +81,21 @@ You can find all the documentation in the
|
|||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
|
|
||||||
MIT
|
Copyright 2015 clowwindy
|
||||||
|
|
||||||
|
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
|
Bugs and Issues
|
||||||
---------------
|
---------------
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ with codecs.open('README.rst', encoding='utf-8') as f:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="shadowsocks",
|
name="shadowsocks",
|
||||||
version="2.6.7",
|
version="2.6.8",
|
||||||
license='MIT',
|
license='http://www.apache.org/licenses/LICENSE-2.0',
|
||||||
description="A fast tunnel proxy that help you get through firewalls",
|
description="A fast tunnel proxy that help you get through firewalls",
|
||||||
author='clowwindy',
|
author='clowwindy',
|
||||||
author_email='clowwindy42@gmail.com',
|
author_email='clowwindy42@gmail.com',
|
||||||
@@ -24,7 +24,7 @@ setup(
|
|||||||
ssserver = shadowsocks.server:main
|
ssserver = shadowsocks.server:main
|
||||||
""",
|
""",
|
||||||
classifiers=[
|
classifiers=[
|
||||||
'License :: OSI Approved :: MIT License',
|
'License :: OSI Approved :: Apache Software License',
|
||||||
'Programming Language :: Python :: 2',
|
'Programming Language :: Python :: 2',
|
||||||
'Programming Language :: Python :: 2.6',
|
'Programming Language :: Python :: 2.6',
|
||||||
'Programming Language :: Python :: 2.7',
|
'Programming Language :: Python :: 2.7',
|
||||||
|
|||||||
+11
-17
@@ -1,24 +1,18 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
# Copyright (c) 2014 clowwindy
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Copyright 2012-2015 clowwindy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# all copies or substantial portions of the Software.
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
#
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# License for the specific language governing permissions and limitations
|
||||||
# SOFTWARE.
|
# under the License.
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, \
|
from __future__ import absolute_import, division, print_function, \
|
||||||
with_statement
|
with_statement
|
||||||
|
|||||||
+13
-21
@@ -1,25 +1,19 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2014 clowwindy
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Copyright 2014-2015 clowwindy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# all copies or substantial portions of the Software.
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
#
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# License for the specific language governing permissions and limitations
|
||||||
# SOFTWARE.
|
# under the License.
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, \
|
from __future__ import absolute_import, division, print_function, \
|
||||||
with_statement
|
with_statement
|
||||||
@@ -31,7 +25,7 @@ import struct
|
|||||||
import re
|
import re
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from shadowsocks import common, lru_cache, eventloop
|
from shadowsocks import common, lru_cache, eventloop, shell
|
||||||
|
|
||||||
|
|
||||||
CACHE_SWEEP_INTERVAL = 30
|
CACHE_SWEEP_INTERVAL = 30
|
||||||
@@ -227,9 +221,7 @@ def parse_response(data):
|
|||||||
response.answers.append((an[1], an[2], an[3]))
|
response.answers.append((an[1], an[2], an[3]))
|
||||||
return response
|
return response
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
import traceback
|
shell.print_exception(e)
|
||||||
traceback.print_exc()
|
|
||||||
logging.error(e)
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+11
-17
@@ -1,25 +1,19 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2014 clowwindy
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Copyright 2013-2015 clowwindy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# all copies or substantial portions of the Software.
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
#
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# License for the specific language governing permissions and limitations
|
||||||
# SOFTWARE.
|
# under the License.
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, \
|
from __future__ import absolute_import, division, print_function, \
|
||||||
with_statement
|
with_statement
|
||||||
|
|||||||
@@ -1,24 +1,18 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
# Copyright (c) 2014 clowwindy
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Copyright 2015 clowwindy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# all copies or substantial portions of the Software.
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
#
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# License for the specific language governing permissions and limitations
|
||||||
# SOFTWARE.
|
# under the License.
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, \
|
from __future__ import absolute_import, division, print_function, \
|
||||||
with_statement
|
with_statement
|
||||||
|
|||||||
@@ -1,24 +1,18 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
# Copyright (c) 2014 clowwindy
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Copyright 2015 clowwindy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# all copies or substantial portions of the Software.
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
#
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# License for the specific language governing permissions and limitations
|
||||||
# SOFTWARE.
|
# under the License.
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, \
|
from __future__ import absolute_import, division, print_function, \
|
||||||
with_statement
|
with_statement
|
||||||
@@ -26,6 +20,7 @@ from __future__ import absolute_import, division, print_function, \
|
|||||||
from ctypes import c_char_p, c_int, c_long, byref,\
|
from ctypes import c_char_p, c_int, c_long, byref,\
|
||||||
create_string_buffer, c_void_p
|
create_string_buffer, c_void_p
|
||||||
|
|
||||||
|
from shadowsocks import common
|
||||||
from shadowsocks.crypto import util
|
from shadowsocks.crypto import util
|
||||||
|
|
||||||
__all__ = ['ciphers']
|
__all__ = ['ciphers']
|
||||||
@@ -64,7 +59,7 @@ def load_openssl():
|
|||||||
|
|
||||||
|
|
||||||
def load_cipher(cipher_name):
|
def load_cipher(cipher_name):
|
||||||
func_name = b'EVP_' + cipher_name.replace(b'-', b'_')
|
func_name = 'EVP_' + cipher_name.replace('-', '_')
|
||||||
if bytes != str:
|
if bytes != str:
|
||||||
func_name = str(func_name, 'utf-8')
|
func_name = str(func_name, 'utf-8')
|
||||||
cipher = getattr(libcrypto, func_name, None)
|
cipher = getattr(libcrypto, func_name, None)
|
||||||
@@ -79,6 +74,7 @@ class OpenSSLCrypto(object):
|
|||||||
self._ctx = None
|
self._ctx = None
|
||||||
if not loaded:
|
if not loaded:
|
||||||
load_openssl()
|
load_openssl()
|
||||||
|
cipher_name = common.to_bytes(cipher_name)
|
||||||
cipher = libcrypto.EVP_get_cipherbyname(cipher_name)
|
cipher = libcrypto.EVP_get_cipherbyname(cipher_name)
|
||||||
if not cipher:
|
if not cipher:
|
||||||
cipher = load_cipher(cipher_name)
|
cipher = load_cipher(cipher_name)
|
||||||
@@ -117,31 +113,31 @@ class OpenSSLCrypto(object):
|
|||||||
|
|
||||||
|
|
||||||
ciphers = {
|
ciphers = {
|
||||||
b'aes-128-cfb': (16, 16, OpenSSLCrypto),
|
'aes-128-cfb': (16, 16, OpenSSLCrypto),
|
||||||
b'aes-192-cfb': (24, 16, OpenSSLCrypto),
|
'aes-192-cfb': (24, 16, OpenSSLCrypto),
|
||||||
b'aes-256-cfb': (32, 16, OpenSSLCrypto),
|
'aes-256-cfb': (32, 16, OpenSSLCrypto),
|
||||||
b'aes-128-ofb': (16, 16, OpenSSLCrypto),
|
'aes-128-ofb': (16, 16, OpenSSLCrypto),
|
||||||
b'aes-192-ofb': (24, 16, OpenSSLCrypto),
|
'aes-192-ofb': (24, 16, OpenSSLCrypto),
|
||||||
b'aes-256-ofb': (32, 16, OpenSSLCrypto),
|
'aes-256-ofb': (32, 16, OpenSSLCrypto),
|
||||||
b'aes-128-ctr': (16, 16, OpenSSLCrypto),
|
'aes-128-ctr': (16, 16, OpenSSLCrypto),
|
||||||
b'aes-192-ctr': (24, 16, OpenSSLCrypto),
|
'aes-192-ctr': (24, 16, OpenSSLCrypto),
|
||||||
b'aes-256-ctr': (32, 16, OpenSSLCrypto),
|
'aes-256-ctr': (32, 16, OpenSSLCrypto),
|
||||||
b'aes-128-cfb8': (16, 16, OpenSSLCrypto),
|
'aes-128-cfb8': (16, 16, OpenSSLCrypto),
|
||||||
b'aes-192-cfb8': (24, 16, OpenSSLCrypto),
|
'aes-192-cfb8': (24, 16, OpenSSLCrypto),
|
||||||
b'aes-256-cfb8': (32, 16, OpenSSLCrypto),
|
'aes-256-cfb8': (32, 16, OpenSSLCrypto),
|
||||||
b'aes-128-cfb1': (16, 16, OpenSSLCrypto),
|
'aes-128-cfb1': (16, 16, OpenSSLCrypto),
|
||||||
b'aes-192-cfb1': (24, 16, OpenSSLCrypto),
|
'aes-192-cfb1': (24, 16, OpenSSLCrypto),
|
||||||
b'aes-256-cfb1': (32, 16, OpenSSLCrypto),
|
'aes-256-cfb1': (32, 16, OpenSSLCrypto),
|
||||||
b'bf-cfb': (16, 8, OpenSSLCrypto),
|
'bf-cfb': (16, 8, OpenSSLCrypto),
|
||||||
b'camellia-128-cfb': (16, 16, OpenSSLCrypto),
|
'camellia-128-cfb': (16, 16, OpenSSLCrypto),
|
||||||
b'camellia-192-cfb': (24, 16, OpenSSLCrypto),
|
'camellia-192-cfb': (24, 16, OpenSSLCrypto),
|
||||||
b'camellia-256-cfb': (32, 16, OpenSSLCrypto),
|
'camellia-256-cfb': (32, 16, OpenSSLCrypto),
|
||||||
b'cast5-cfb': (16, 8, OpenSSLCrypto),
|
'cast5-cfb': (16, 8, OpenSSLCrypto),
|
||||||
b'des-cfb': (8, 8, OpenSSLCrypto),
|
'des-cfb': (8, 8, OpenSSLCrypto),
|
||||||
b'idea-cfb': (16, 8, OpenSSLCrypto),
|
'idea-cfb': (16, 8, OpenSSLCrypto),
|
||||||
b'rc2-cfb': (16, 8, OpenSSLCrypto),
|
'rc2-cfb': (16, 8, OpenSSLCrypto),
|
||||||
b'rc4': (16, 0, OpenSSLCrypto),
|
'rc4': (16, 0, OpenSSLCrypto),
|
||||||
b'seed-cfb': (16, 16, OpenSSLCrypto),
|
'seed-cfb': (16, 16, OpenSSLCrypto),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -154,31 +150,31 @@ def run_method(method):
|
|||||||
|
|
||||||
|
|
||||||
def test_aes_128_cfb():
|
def test_aes_128_cfb():
|
||||||
run_method(b'aes-128-cfb')
|
run_method('aes-128-cfb')
|
||||||
|
|
||||||
|
|
||||||
def test_aes_256_cfb():
|
def test_aes_256_cfb():
|
||||||
run_method(b'aes-256-cfb')
|
run_method('aes-256-cfb')
|
||||||
|
|
||||||
|
|
||||||
def test_aes_128_cfb8():
|
def test_aes_128_cfb8():
|
||||||
run_method(b'aes-128-cfb8')
|
run_method('aes-128-cfb8')
|
||||||
|
|
||||||
|
|
||||||
def test_aes_256_ofb():
|
def test_aes_256_ofb():
|
||||||
run_method(b'aes-256-ofb')
|
run_method('aes-256-ofb')
|
||||||
|
|
||||||
|
|
||||||
def test_aes_256_ctr():
|
def test_aes_256_ctr():
|
||||||
run_method(b'aes-256-ctr')
|
run_method('aes-256-ctr')
|
||||||
|
|
||||||
|
|
||||||
def test_bf_cfb():
|
def test_bf_cfb():
|
||||||
run_method(b'bf-cfb')
|
run_method('bf-cfb')
|
||||||
|
|
||||||
|
|
||||||
def test_rc4():
|
def test_rc4():
|
||||||
run_method(b'rc4')
|
run_method('rc4')
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
@@ -1,24 +1,18 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
# Copyright (c) 2014 clowwindy
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Copyright 2015 clowwindy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# all copies or substantial portions of the Software.
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
#
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# License for the specific language governing permissions and limitations
|
||||||
# SOFTWARE.
|
# under the License.
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, \
|
from __future__ import absolute_import, division, print_function, \
|
||||||
with_statement
|
with_statement
|
||||||
@@ -40,15 +34,15 @@ def create_cipher(alg, key, iv, op, key_as_bytes=0, d=None, salt=None,
|
|||||||
|
|
||||||
|
|
||||||
ciphers = {
|
ciphers = {
|
||||||
b'rc4-md5': (16, 16, create_cipher),
|
'rc4-md5': (16, 16, create_cipher),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def test():
|
def test():
|
||||||
from shadowsocks.crypto import util
|
from shadowsocks.crypto import util
|
||||||
|
|
||||||
cipher = create_cipher(b'rc4-md5', b'k' * 32, b'i' * 16, 1)
|
cipher = create_cipher('rc4-md5', b'k' * 32, b'i' * 16, 1)
|
||||||
decipher = create_cipher(b'rc4-md5', b'k' * 32, b'i' * 16, 0)
|
decipher = create_cipher('rc4-md5', b'k' * 32, b'i' * 16, 0)
|
||||||
|
|
||||||
util.run_cipher(cipher, decipher)
|
util.run_cipher(cipher, decipher)
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,18 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
# Copyright (c) 2014 clowwindy
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Copyright 2015 clowwindy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# all copies or substantial portions of the Software.
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
#
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# License for the specific language governing permissions and limitations
|
||||||
# SOFTWARE.
|
# under the License.
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, \
|
from __future__ import absolute_import, division, print_function, \
|
||||||
with_statement
|
with_statement
|
||||||
@@ -70,9 +64,9 @@ class SodiumCrypto(object):
|
|||||||
self.iv = iv
|
self.iv = iv
|
||||||
self.key_ptr = c_char_p(key)
|
self.key_ptr = c_char_p(key)
|
||||||
self.iv_ptr = c_char_p(iv)
|
self.iv_ptr = c_char_p(iv)
|
||||||
if cipher_name == b'salsa20':
|
if cipher_name == 'salsa20':
|
||||||
self.cipher = libsodium.crypto_stream_salsa20_xor_ic
|
self.cipher = libsodium.crypto_stream_salsa20_xor_ic
|
||||||
elif cipher_name == b'chacha20':
|
elif cipher_name == 'chacha20':
|
||||||
self.cipher = libsodium.crypto_stream_chacha20_xor_ic
|
self.cipher = libsodium.crypto_stream_chacha20_xor_ic
|
||||||
else:
|
else:
|
||||||
raise Exception('Unknown cipher')
|
raise Exception('Unknown cipher')
|
||||||
@@ -101,22 +95,22 @@ class SodiumCrypto(object):
|
|||||||
|
|
||||||
|
|
||||||
ciphers = {
|
ciphers = {
|
||||||
b'salsa20': (32, 8, SodiumCrypto),
|
'salsa20': (32, 8, SodiumCrypto),
|
||||||
b'chacha20': (32, 8, SodiumCrypto),
|
'chacha20': (32, 8, SodiumCrypto),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def test_salsa20():
|
def test_salsa20():
|
||||||
cipher = SodiumCrypto(b'salsa20', b'k' * 32, b'i' * 16, 1)
|
cipher = SodiumCrypto('salsa20', b'k' * 32, b'i' * 16, 1)
|
||||||
decipher = SodiumCrypto(b'salsa20', b'k' * 32, b'i' * 16, 0)
|
decipher = SodiumCrypto('salsa20', b'k' * 32, b'i' * 16, 0)
|
||||||
|
|
||||||
util.run_cipher(cipher, decipher)
|
util.run_cipher(cipher, decipher)
|
||||||
|
|
||||||
|
|
||||||
def test_chacha20():
|
def test_chacha20():
|
||||||
|
|
||||||
cipher = SodiumCrypto(b'chacha20', b'k' * 32, b'i' * 16, 1)
|
cipher = SodiumCrypto('chacha20', b'k' * 32, b'i' * 16, 1)
|
||||||
decipher = SodiumCrypto(b'chacha20', b'k' * 32, b'i' * 16, 0)
|
decipher = SodiumCrypto('chacha20', b'k' * 32, b'i' * 16, 0)
|
||||||
|
|
||||||
util.run_cipher(cipher, decipher)
|
util.run_cipher(cipher, decipher)
|
||||||
|
|
||||||
|
|||||||
+14
-20
@@ -1,24 +1,18 @@
|
|||||||
# !/usr/bin/env python
|
# !/usr/bin/env python
|
||||||
|
|
||||||
# Copyright (c) 2014 clowwindy
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Copyright 2015 clowwindy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# all copies or substantial portions of the Software.
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
#
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# License for the specific language governing permissions and limitations
|
||||||
# SOFTWARE.
|
# under the License.
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, \
|
from __future__ import absolute_import, division, print_function, \
|
||||||
with_statement
|
with_statement
|
||||||
@@ -73,7 +67,7 @@ class TableCipher(object):
|
|||||||
|
|
||||||
|
|
||||||
ciphers = {
|
ciphers = {
|
||||||
b'table': (0, 0, TableCipher)
|
'table': (0, 0, TableCipher)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -169,8 +163,8 @@ def test_table_result():
|
|||||||
def test_encryption():
|
def test_encryption():
|
||||||
from shadowsocks.crypto import util
|
from shadowsocks.crypto import util
|
||||||
|
|
||||||
cipher = TableCipher(b'table', b'test', b'', 1)
|
cipher = TableCipher('table', b'test', b'', 1)
|
||||||
decipher = TableCipher(b'table', b'test', b'', 0)
|
decipher = TableCipher('table', b'test', b'', 0)
|
||||||
|
|
||||||
util.run_cipher(cipher, decipher)
|
util.run_cipher(cipher, decipher)
|
||||||
|
|
||||||
|
|||||||
+11
-17
@@ -1,24 +1,18 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
# Copyright (c) 2014 clowwindy
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Copyright 2015 clowwindy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# all copies or substantial portions of the Software.
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
#
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# License for the specific language governing permissions and limitations
|
||||||
# SOFTWARE.
|
# under the License.
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, \
|
from __future__ import absolute_import, division, print_function, \
|
||||||
with_statement
|
with_statement
|
||||||
|
|||||||
+16
-22
@@ -1,25 +1,19 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2014 clowwindy
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Copyright 2014-2015 clowwindy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# all copies or substantial portions of the Software.
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
#
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# License for the specific language governing permissions and limitations
|
||||||
# SOFTWARE.
|
# under the License.
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, \
|
from __future__ import absolute_import, division, print_function, \
|
||||||
with_statement
|
with_statement
|
||||||
@@ -29,7 +23,7 @@ import sys
|
|||||||
import logging
|
import logging
|
||||||
import signal
|
import signal
|
||||||
import time
|
import time
|
||||||
from shadowsocks import common
|
from shadowsocks import common, shell
|
||||||
|
|
||||||
# this module is ported from ShadowVPN daemon.c
|
# this module is ported from ShadowVPN daemon.c
|
||||||
|
|
||||||
@@ -64,7 +58,7 @@ def write_pid_file(pid_file, pid):
|
|||||||
fd = os.open(pid_file, os.O_RDWR | os.O_CREAT,
|
fd = os.open(pid_file, os.O_RDWR | os.O_CREAT,
|
||||||
stat.S_IRUSR | stat.S_IWUSR)
|
stat.S_IRUSR | stat.S_IWUSR)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
logging.error(e)
|
shell.print_exception(e)
|
||||||
return -1
|
return -1
|
||||||
flags = fcntl.fcntl(fd, fcntl.F_GETFD)
|
flags = fcntl.fcntl(fd, fcntl.F_GETFD)
|
||||||
assert flags != -1
|
assert flags != -1
|
||||||
@@ -133,7 +127,7 @@ def daemon_start(pid_file, log_file):
|
|||||||
freopen(log_file, 'a', sys.stdout)
|
freopen(log_file, 'a', sys.stdout)
|
||||||
freopen(log_file, 'a', sys.stderr)
|
freopen(log_file, 'a', sys.stderr)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
logging.error(e)
|
shell.print_exception(e)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
@@ -146,7 +140,7 @@ def daemon_stop(pid_file):
|
|||||||
if not buf:
|
if not buf:
|
||||||
logging.error('not running')
|
logging.error('not running')
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
logging.error(e)
|
shell.print_exception(e)
|
||||||
if e.errno == errno.ENOENT:
|
if e.errno == errno.ENOENT:
|
||||||
# always exit 0 if we are sure daemon is not running
|
# always exit 0 if we are sure daemon is not running
|
||||||
logging.error('not running')
|
logging.error('not running')
|
||||||
@@ -161,7 +155,7 @@ def daemon_stop(pid_file):
|
|||||||
logging.error('not running')
|
logging.error('not running')
|
||||||
# always exit 0 if we are sure daemon is not running
|
# always exit 0 if we are sure daemon is not running
|
||||||
return
|
return
|
||||||
logging.error(e)
|
shell.print_exception(e)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
else:
|
else:
|
||||||
logging.error('pid is not positive: %d', pid)
|
logging.error('pid is not positive: %d', pid)
|
||||||
|
|||||||
+19
-27
@@ -1,24 +1,18 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
# Copyright (c) 2014 clowwindy
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Copyright 2012-2015 clowwindy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# all copies or substantial portions of the Software.
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
#
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# License for the specific language governing permissions and limitations
|
||||||
# SOFTWARE.
|
# under the License.
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, \
|
from __future__ import absolute_import, division, print_function, \
|
||||||
with_statement
|
with_statement
|
||||||
@@ -28,6 +22,7 @@ import sys
|
|||||||
import hashlib
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from shadowsocks import common
|
||||||
from shadowsocks.crypto import rc4_md5, openssl, sodium, table
|
from shadowsocks.crypto import rc4_md5, openssl, sodium, table
|
||||||
|
|
||||||
|
|
||||||
@@ -52,8 +47,6 @@ def try_cipher(key, method=None):
|
|||||||
def EVP_BytesToKey(password, key_len, iv_len):
|
def EVP_BytesToKey(password, key_len, iv_len):
|
||||||
# equivalent to OpenSSL's EVP_BytesToKey() with count 1
|
# equivalent to OpenSSL's EVP_BytesToKey() with count 1
|
||||||
# so that we make the same key and iv as nodejs version
|
# so that we make the same key and iv as nodejs version
|
||||||
if hasattr(password, 'encode'):
|
|
||||||
password = password.encode('utf-8')
|
|
||||||
cached_key = '%s-%d-%d' % (password, key_len, iv_len)
|
cached_key = '%s-%d-%d' % (password, key_len, iv_len)
|
||||||
r = cached_keys.get(cached_key, None)
|
r = cached_keys.get(cached_key, None)
|
||||||
if r:
|
if r:
|
||||||
@@ -101,8 +94,7 @@ class Encryptor(object):
|
|||||||
return len(self.cipher_iv)
|
return len(self.cipher_iv)
|
||||||
|
|
||||||
def get_cipher(self, password, method, op, iv):
|
def get_cipher(self, password, method, op, iv):
|
||||||
if hasattr(password, 'encode'):
|
password = common.to_bytes(password)
|
||||||
password = password.encode('utf-8')
|
|
||||||
m = self._method_info
|
m = self._method_info
|
||||||
if m[0] > 0:
|
if m[0] > 0:
|
||||||
key, iv_ = EVP_BytesToKey(password, m[0], m[1])
|
key, iv_ = EVP_BytesToKey(password, m[0], m[1])
|
||||||
@@ -159,12 +151,12 @@ def encrypt_all(password, method, op, data):
|
|||||||
|
|
||||||
|
|
||||||
CIPHERS_TO_TEST = [
|
CIPHERS_TO_TEST = [
|
||||||
b'aes-128-cfb',
|
'aes-128-cfb',
|
||||||
b'aes-256-cfb',
|
'aes-256-cfb',
|
||||||
b'rc4-md5',
|
'rc4-md5',
|
||||||
b'salsa20',
|
'salsa20',
|
||||||
b'chacha20',
|
'chacha20',
|
||||||
b'table',
|
'table',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+14
-20
@@ -1,25 +1,19 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2014 clowwindy
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Copyright 2013-2015 clowwindy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# all copies or substantial portions of the Software.
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
#
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# License for the specific language governing permissions and limitations
|
||||||
# SOFTWARE.
|
# under the License.
|
||||||
|
|
||||||
# from ssloop
|
# from ssloop
|
||||||
# https://github.com/clowwindy/ssloop
|
# https://github.com/clowwindy/ssloop
|
||||||
@@ -34,6 +28,8 @@ import errno
|
|||||||
import logging
|
import logging
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
|
|
||||||
|
from shadowsocks import shell
|
||||||
|
|
||||||
|
|
||||||
__all__ = ['EventLoop', 'POLL_NULL', 'POLL_IN', 'POLL_OUT', 'POLL_ERR',
|
__all__ = ['EventLoop', 'POLL_NULL', 'POLL_IN', 'POLL_OUT', 'POLL_ERR',
|
||||||
'POLL_HUP', 'POLL_NVAL', 'EVENT_NAMES']
|
'POLL_HUP', 'POLL_NVAL', 'EVENT_NAMES']
|
||||||
@@ -229,9 +225,7 @@ class EventLoop(object):
|
|||||||
try:
|
try:
|
||||||
handler(events)
|
handler(events)
|
||||||
except (OSError, IOError) as e:
|
except (OSError, IOError) as e:
|
||||||
logging.error(e)
|
shell.print_exception(e)
|
||||||
import traceback
|
|
||||||
traceback.print_exc()
|
|
||||||
if self._handlers_to_remove:
|
if self._handlers_to_remove:
|
||||||
for handler in self._handlers_to_remove:
|
for handler in self._handlers_to_remove:
|
||||||
self._handlers.remove(handler)
|
self._handlers.remove(handler)
|
||||||
|
|||||||
+15
-26
@@ -1,25 +1,19 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2014 clowwindy
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Copyright 2012-2015 clowwindy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# all copies or substantial portions of the Software.
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
#
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# License for the specific language governing permissions and limitations
|
||||||
# SOFTWARE.
|
# under the License.
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, \
|
from __future__ import absolute_import, division, print_function, \
|
||||||
with_statement
|
with_statement
|
||||||
@@ -30,11 +24,11 @@ import logging
|
|||||||
import signal
|
import signal
|
||||||
|
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../'))
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../'))
|
||||||
from shadowsocks import utils, daemon, eventloop, tcprelay, udprelay, asyncdns
|
from shadowsocks import shell, daemon, eventloop, tcprelay, udprelay, asyncdns
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
utils.check_python()
|
shell.check_python()
|
||||||
|
|
||||||
# fix py2exe
|
# fix py2exe
|
||||||
if hasattr(sys, "frozen") and sys.frozen in \
|
if hasattr(sys, "frozen") and sys.frozen in \
|
||||||
@@ -42,12 +36,10 @@ def main():
|
|||||||
p = os.path.dirname(os.path.abspath(sys.executable))
|
p = os.path.dirname(os.path.abspath(sys.executable))
|
||||||
os.chdir(p)
|
os.chdir(p)
|
||||||
|
|
||||||
config = utils.get_config(True)
|
config = shell.get_config(True)
|
||||||
|
|
||||||
daemon.daemon_exec(config)
|
daemon.daemon_exec(config)
|
||||||
|
|
||||||
utils.print_shadowsocks()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logging.info("starting local at %s:%d" %
|
logging.info("starting local at %s:%d" %
|
||||||
(config['local_address'], config['local_port']))
|
(config['local_address'], config['local_port']))
|
||||||
@@ -73,10 +65,7 @@ def main():
|
|||||||
daemon.set_user(config.get('user', None))
|
daemon.set_user(config.get('user', None))
|
||||||
loop.run()
|
loop.run()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(e)
|
shell.print_exception(e)
|
||||||
if config['verbose']:
|
|
||||||
import traceback
|
|
||||||
traceback.print_exc()
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
+11
-17
@@ -1,25 +1,19 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2014 clowwindy
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Copyright 2015 clowwindy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# all copies or substantial portions of the Software.
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
#
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# License for the specific language governing permissions and limitations
|
||||||
# SOFTWARE.
|
# under the License.
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, \
|
from __future__ import absolute_import, division, print_function, \
|
||||||
with_statement
|
with_statement
|
||||||
|
|||||||
+15
-26
@@ -1,25 +1,19 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2014 clowwindy
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Copyright 2015 clowwindy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# all copies or substantial portions of the Software.
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
#
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# License for the specific language governing permissions and limitations
|
||||||
# SOFTWARE.
|
# under the License.
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, \
|
from __future__ import absolute_import, division, print_function, \
|
||||||
with_statement
|
with_statement
|
||||||
@@ -30,18 +24,16 @@ import logging
|
|||||||
import signal
|
import signal
|
||||||
|
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../'))
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../'))
|
||||||
from shadowsocks import utils, daemon, eventloop, tcprelay, udprelay, asyncdns
|
from shadowsocks import shell, daemon, eventloop, tcprelay, udprelay, asyncdns
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
utils.check_python()
|
shell.check_python()
|
||||||
|
|
||||||
config = utils.get_config(False)
|
config = shell.get_config(False)
|
||||||
|
|
||||||
daemon.daemon_exec(config)
|
daemon.daemon_exec(config)
|
||||||
|
|
||||||
utils.print_shadowsocks()
|
|
||||||
|
|
||||||
if config['port_password']:
|
if config['port_password']:
|
||||||
if config['password']:
|
if config['password']:
|
||||||
logging.warn('warning: port_password should not be used with '
|
logging.warn('warning: port_password should not be used with '
|
||||||
@@ -88,10 +80,7 @@ def main():
|
|||||||
daemon.set_user(config.get('user', None))
|
daemon.set_user(config.get('user', None))
|
||||||
loop.run()
|
loop.run()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(e)
|
shell.print_exception(e)
|
||||||
if config['verbose']:
|
|
||||||
import traceback
|
|
||||||
traceback.print_exc()
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if int(config['workers']) > 1:
|
if int(config['workers']) > 1:
|
||||||
|
|||||||
@@ -1,25 +1,19 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2014 clowwindy
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Copyright 2015 clowwindy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# all copies or substantial portions of the Software.
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
#
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# License for the specific language governing permissions and limitations
|
||||||
# SOFTWARE.
|
# under the License.
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, \
|
from __future__ import absolute_import, division, print_function, \
|
||||||
with_statement
|
with_statement
|
||||||
@@ -35,6 +29,8 @@ from shadowsocks import encrypt
|
|||||||
|
|
||||||
VERBOSE_LEVEL = 5
|
VERBOSE_LEVEL = 5
|
||||||
|
|
||||||
|
verbose = 0
|
||||||
|
|
||||||
|
|
||||||
def check_python():
|
def check_python():
|
||||||
info = sys.version_info
|
info = sys.version_info
|
||||||
@@ -49,6 +45,14 @@ def check_python():
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
def print_exception(e):
|
||||||
|
global verbose
|
||||||
|
logging.error(e)
|
||||||
|
if verbose > 0:
|
||||||
|
import traceback
|
||||||
|
traceback.print_exc()
|
||||||
|
|
||||||
|
|
||||||
def print_shadowsocks():
|
def print_shadowsocks():
|
||||||
version = ''
|
version = ''
|
||||||
try:
|
try:
|
||||||
@@ -56,7 +60,7 @@ def print_shadowsocks():
|
|||||||
version = pkg_resources.get_distribution('shadowsocks').version
|
version = pkg_resources.get_distribution('shadowsocks').version
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
print('shadowsocks %s' % version)
|
print('Shadowsocks %s' % version)
|
||||||
|
|
||||||
|
|
||||||
def find_config():
|
def find_config():
|
||||||
@@ -93,13 +97,13 @@ def check_config(config, is_local):
|
|||||||
|
|
||||||
if config.get('local_address', '') in [b'0.0.0.0']:
|
if config.get('local_address', '') in [b'0.0.0.0']:
|
||||||
logging.warn('warning: local set to listen on 0.0.0.0, it\'s not safe')
|
logging.warn('warning: local set to listen on 0.0.0.0, it\'s not safe')
|
||||||
if config.get('server', '') in [b'127.0.0.1', b'localhost']:
|
if config.get('server', '') in ['127.0.0.1', 'localhost']:
|
||||||
logging.warn('warning: server set to listen on %s:%s, are you sure?' %
|
logging.warn('warning: server set to listen on %s:%s, are you sure?' %
|
||||||
(to_str(config['server']), config['server_port']))
|
(to_str(config['server']), config['server_port']))
|
||||||
if (config.get('method', '') or '').lower() == b'table':
|
if (config.get('method', '') or '').lower() == 'table':
|
||||||
logging.warn('warning: table is not safe; please use a safer cipher, '
|
logging.warn('warning: table is not safe; please use a safer cipher, '
|
||||||
'like AES-256-CFB')
|
'like AES-256-CFB')
|
||||||
if (config.get('method', '') or '').lower() == b'rc4':
|
if (config.get('method', '') or '').lower() == 'rc4':
|
||||||
logging.warn('warning: RC4 is not safe; please use a safer cipher, '
|
logging.warn('warning: RC4 is not safe; please use a safer cipher, '
|
||||||
'like AES-256-CFB')
|
'like AES-256-CFB')
|
||||||
if config.get('timeout', 300) < 100:
|
if config.get('timeout', 300) < 100:
|
||||||
@@ -121,15 +125,18 @@ def check_config(config, is_local):
|
|||||||
|
|
||||||
|
|
||||||
def get_config(is_local):
|
def get_config(is_local):
|
||||||
|
global verbose
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO,
|
logging.basicConfig(level=logging.INFO,
|
||||||
format='%(levelname)-s: %(message)s')
|
format='%(levelname)-s: %(message)s')
|
||||||
if is_local:
|
if is_local:
|
||||||
shortopts = 'hd:s:b:p:k:l:m:c:t:vq'
|
shortopts = 'hd:s:b:p:k:l:m:c:t:vq'
|
||||||
longopts = ['help', 'fast-open', 'pid-file=', 'log-file=', 'user=']
|
longopts = ['help', 'fast-open', 'pid-file=', 'log-file=', 'user=',
|
||||||
|
'version']
|
||||||
else:
|
else:
|
||||||
shortopts = 'hd:s:p:k:m:c:t:vq'
|
shortopts = 'hd:s:p:k:m:c:t:vq'
|
||||||
longopts = ['help', 'fast-open', 'pid-file=', 'log-file=', 'workers=',
|
longopts = ['help', 'fast-open', 'pid-file=', 'log-file=', 'workers=',
|
||||||
'forbidden-ip=', 'user=']
|
'forbidden-ip=', 'user=', 'version']
|
||||||
try:
|
try:
|
||||||
config_path = find_config()
|
config_path = find_config()
|
||||||
optlist, args = getopt.getopt(sys.argv[1:], shortopts, longopts)
|
optlist, args = getopt.getopt(sys.argv[1:], shortopts, longopts)
|
||||||
@@ -160,11 +167,11 @@ def get_config(is_local):
|
|||||||
elif key == '-l':
|
elif key == '-l':
|
||||||
config['local_port'] = int(value)
|
config['local_port'] = int(value)
|
||||||
elif key == '-s':
|
elif key == '-s':
|
||||||
config['server'] = to_bytes(value)
|
config['server'] = to_str(value)
|
||||||
elif key == '-m':
|
elif key == '-m':
|
||||||
config['method'] = to_bytes(value)
|
config['method'] = to_str(value)
|
||||||
elif key == '-b':
|
elif key == '-b':
|
||||||
config['local_address'] = to_bytes(value)
|
config['local_address'] = to_str(value)
|
||||||
elif key == '-v':
|
elif key == '-v':
|
||||||
v_count += 1
|
v_count += 1
|
||||||
# '-vv' turns on more verbose mode
|
# '-vv' turns on more verbose mode
|
||||||
@@ -185,6 +192,9 @@ def get_config(is_local):
|
|||||||
else:
|
else:
|
||||||
print_server_help()
|
print_server_help()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
elif key == '--version':
|
||||||
|
print_shadowsocks()
|
||||||
|
sys.exit(0)
|
||||||
elif key == '-d':
|
elif key == '-d':
|
||||||
config['daemon'] = to_str(value)
|
config['daemon'] = to_str(value)
|
||||||
elif key == '--pid-file':
|
elif key == '--pid-file':
|
||||||
@@ -204,8 +214,8 @@ def get_config(is_local):
|
|||||||
print_help(is_local)
|
print_help(is_local)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
config['password'] = config.get('password', '')
|
config['password'] = to_bytes(config.get('password', b''))
|
||||||
config['method'] = config.get('method', b'aes-256-cfb')
|
config['method'] = to_str(config.get('method', 'aes-256-cfb'))
|
||||||
config['port_password'] = config.get('port_password', None)
|
config['port_password'] = config.get('port_password', None)
|
||||||
config['timeout'] = int(config.get('timeout', 300))
|
config['timeout'] = int(config.get('timeout', 300))
|
||||||
config['fast_open'] = config.get('fast_open', False)
|
config['fast_open'] = config.get('fast_open', False)
|
||||||
@@ -214,15 +224,17 @@ def get_config(is_local):
|
|||||||
config['log-file'] = config.get('log-file', '/var/log/shadowsocks.log')
|
config['log-file'] = config.get('log-file', '/var/log/shadowsocks.log')
|
||||||
config['workers'] = config.get('workers', 1)
|
config['workers'] = config.get('workers', 1)
|
||||||
config['verbose'] = config.get('verbose', False)
|
config['verbose'] = config.get('verbose', False)
|
||||||
config['local_address'] = config.get('local_address', '127.0.0.1')
|
config['local_address'] = to_str(config.get('local_address', '127.0.0.1'))
|
||||||
config['local_port'] = config.get('local_port', 1080)
|
config['local_port'] = config.get('local_port', 1080)
|
||||||
if is_local:
|
if is_local:
|
||||||
if config.get('server', None) is None:
|
if config.get('server', None) is None:
|
||||||
logging.error('server addr not specified')
|
logging.error('server addr not specified')
|
||||||
print_local_help()
|
print_local_help()
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
else:
|
||||||
|
config['server'] = to_str(config['server'])
|
||||||
else:
|
else:
|
||||||
config['server'] = config.get('server', '0.0.0.0')
|
config['server'] = to_str(config.get('server', '0.0.0.0'))
|
||||||
try:
|
try:
|
||||||
config['forbidden_ip'] = \
|
config['forbidden_ip'] = \
|
||||||
IPNetwork(config.get('forbidden_ip', '127.0.0.0/8,::1/128'))
|
IPNetwork(config.get('forbidden_ip', '127.0.0.0/8,::1/128'))
|
||||||
@@ -243,6 +255,7 @@ def get_config(is_local):
|
|||||||
level = logging.ERROR
|
level = logging.ERROR
|
||||||
else:
|
else:
|
||||||
level = logging.INFO
|
level = logging.INFO
|
||||||
|
verbose = config['verbose']
|
||||||
logging.basicConfig(level=level,
|
logging.basicConfig(level=level,
|
||||||
format='%(asctime)s %(levelname)-8s %(message)s',
|
format='%(asctime)s %(levelname)-8s %(message)s',
|
||||||
datefmt='%Y-%m-%d %H:%M:%S')
|
datefmt='%Y-%m-%d %H:%M:%S')
|
||||||
@@ -266,7 +279,6 @@ A fast tunnel proxy that helps you bypass firewalls.
|
|||||||
You can supply configurations via either config file or command line arguments.
|
You can supply configurations via either config file or command line arguments.
|
||||||
|
|
||||||
Proxy options:
|
Proxy options:
|
||||||
-h, --help show this help message and exit
|
|
||||||
-c CONFIG path to config file
|
-c CONFIG path to config file
|
||||||
-s SERVER_ADDR server address
|
-s SERVER_ADDR server address
|
||||||
-p SERVER_PORT server port, default: 8388
|
-p SERVER_PORT server port, default: 8388
|
||||||
@@ -278,12 +290,14 @@ Proxy options:
|
|||||||
--fast-open use TCP_FASTOPEN, requires Linux 3.7+
|
--fast-open use TCP_FASTOPEN, requires Linux 3.7+
|
||||||
|
|
||||||
General options:
|
General options:
|
||||||
|
-h, --help show this help message and exit
|
||||||
-d start/stop/restart daemon mode
|
-d start/stop/restart daemon mode
|
||||||
--pid-file PID_FILE pid file for daemon mode
|
--pid-file PID_FILE pid file for daemon mode
|
||||||
--log-file LOG_FILE log file for daemon mode
|
--log-file LOG_FILE log file for daemon mode
|
||||||
--user USER username to run as
|
--user USER username to run as
|
||||||
-v, -vv verbose mode
|
-v, -vv verbose mode
|
||||||
-q, -qq quiet mode, only show warnings/errors
|
-q, -qq quiet mode, only show warnings/errors
|
||||||
|
--version show version information
|
||||||
|
|
||||||
Online help: <https://github.com/shadowsocks/shadowsocks>
|
Online help: <https://github.com/shadowsocks/shadowsocks>
|
||||||
''')
|
''')
|
||||||
@@ -296,7 +310,6 @@ A fast tunnel proxy that helps you bypass firewalls.
|
|||||||
You can supply configurations via either config file or command line arguments.
|
You can supply configurations via either config file or command line arguments.
|
||||||
|
|
||||||
Proxy options:
|
Proxy options:
|
||||||
-h, --help show this help message and exit
|
|
||||||
-c CONFIG path to config file
|
-c CONFIG path to config file
|
||||||
-s SERVER_ADDR server address, default: 0.0.0.0
|
-s SERVER_ADDR server address, default: 0.0.0.0
|
||||||
-p SERVER_PORT server port, default: 8388
|
-p SERVER_PORT server port, default: 8388
|
||||||
@@ -308,12 +321,14 @@ Proxy options:
|
|||||||
--forbidden-ip IPLIST comma seperated IP list forbidden to connect
|
--forbidden-ip IPLIST comma seperated IP list forbidden to connect
|
||||||
|
|
||||||
General options:
|
General options:
|
||||||
|
-h, --help show this help message and exit
|
||||||
-d start/stop/restart daemon mode
|
-d start/stop/restart daemon mode
|
||||||
--pid-file PID_FILE pid file for daemon mode
|
--pid-file PID_FILE pid file for daemon mode
|
||||||
--log-file LOG_FILE log file for daemon mode
|
--log-file LOG_FILE log file for daemon mode
|
||||||
--user USER username to run as
|
--user USER username to run as
|
||||||
-v, -vv verbose mode
|
-v, -vv verbose mode
|
||||||
-q, -qq quiet mode, only show warnings/errors
|
-q, -qq quiet mode, only show warnings/errors
|
||||||
|
--version show version information
|
||||||
|
|
||||||
Online help: <https://github.com/shadowsocks/shadowsocks>
|
Online help: <https://github.com/shadowsocks/shadowsocks>
|
||||||
''')
|
''')
|
||||||
+22
-29
@@ -1,25 +1,19 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2015 clowwindy
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Copyright 2015 clowwindy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# all copies or substantial portions of the Software.
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
#
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# License for the specific language governing permissions and limitations
|
||||||
# SOFTWARE.
|
# under the License.
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, \
|
from __future__ import absolute_import, division, print_function, \
|
||||||
with_statement
|
with_statement
|
||||||
@@ -32,7 +26,7 @@ import logging
|
|||||||
import traceback
|
import traceback
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from shadowsocks import encrypt, eventloop, utils, common
|
from shadowsocks import encrypt, eventloop, shell, common
|
||||||
from shadowsocks.common import parse_header
|
from shadowsocks.common import parse_header
|
||||||
|
|
||||||
# we clear at most TIMEOUTS_CLEAN_SIZE timeouts each time
|
# we clear at most TIMEOUTS_CLEAN_SIZE timeouts each time
|
||||||
@@ -150,8 +144,9 @@ class TCPRelayHandler(object):
|
|||||||
server_port = self._config['server_port']
|
server_port = self._config['server_port']
|
||||||
if type(server_port) == list:
|
if type(server_port) == list:
|
||||||
server_port = random.choice(server_port)
|
server_port = random.choice(server_port)
|
||||||
|
if type(server) == list:
|
||||||
|
server = random.choice(server)
|
||||||
logging.debug('chosen server: %s:%d', server, server_port)
|
logging.debug('chosen server: %s:%d', server, server_port)
|
||||||
# TODO support multiple server IP
|
|
||||||
return server, server_port
|
return server, server_port
|
||||||
|
|
||||||
def _update_activity(self):
|
def _update_activity(self):
|
||||||
@@ -208,9 +203,7 @@ class TCPRelayHandler(object):
|
|||||||
errno.EWOULDBLOCK):
|
errno.EWOULDBLOCK):
|
||||||
uncomplete = True
|
uncomplete = True
|
||||||
else:
|
else:
|
||||||
logging.error(e)
|
shell.print_exception(e)
|
||||||
if self._config['verbose']:
|
|
||||||
traceback.print_exc()
|
|
||||||
self.destroy()
|
self.destroy()
|
||||||
return False
|
return False
|
||||||
if uncomplete:
|
if uncomplete:
|
||||||
@@ -264,7 +257,7 @@ class TCPRelayHandler(object):
|
|||||||
self._config['fast_open'] = False
|
self._config['fast_open'] = False
|
||||||
self.destroy()
|
self.destroy()
|
||||||
else:
|
else:
|
||||||
logging.error(e)
|
shell.print_exception(e)
|
||||||
if self._config['verbose']:
|
if self._config['verbose']:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
self.destroy()
|
self.destroy()
|
||||||
@@ -333,7 +326,7 @@ class TCPRelayHandler(object):
|
|||||||
addrs = socket.getaddrinfo(ip, port, 0, socket.SOCK_STREAM,
|
addrs = socket.getaddrinfo(ip, port, 0, socket.SOCK_STREAM,
|
||||||
socket.SOL_TCP)
|
socket.SOL_TCP)
|
||||||
if len(addrs) == 0:
|
if len(addrs) == 0:
|
||||||
raise Exception("getaddrinfo failed for %s:%d" % (ip, port))
|
raise Exception("getaddrinfo failed for %s:%d" % (ip, port))
|
||||||
af, socktype, proto, canonname, sa = addrs[0]
|
af, socktype, proto, canonname, sa = addrs[0]
|
||||||
if self._forbidden_iplist:
|
if self._forbidden_iplist:
|
||||||
if common.to_str(sa[0]) in self._forbidden_iplist:
|
if common.to_str(sa[0]) in self._forbidden_iplist:
|
||||||
@@ -388,7 +381,7 @@ class TCPRelayHandler(object):
|
|||||||
self._update_stream(STREAM_DOWN, WAIT_STATUS_READING)
|
self._update_stream(STREAM_DOWN, WAIT_STATUS_READING)
|
||||||
return
|
return
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(e)
|
shell.print_exception(e)
|
||||||
if self._config['verbose']:
|
if self._config['verbose']:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
self.destroy()
|
self.destroy()
|
||||||
@@ -450,7 +443,7 @@ class TCPRelayHandler(object):
|
|||||||
try:
|
try:
|
||||||
self._write_to_sock(data, self._local_sock)
|
self._write_to_sock(data, self._local_sock)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.error(e)
|
shell.print_exception(e)
|
||||||
if self._config['verbose']:
|
if self._config['verbose']:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
# TODO use logging when debug completed
|
# TODO use logging when debug completed
|
||||||
@@ -637,7 +630,7 @@ class TCPRelay(object):
|
|||||||
# we just need a sorted last_activity queue and it's faster than heapq
|
# we just need a sorted last_activity queue and it's faster than heapq
|
||||||
# in fact we can do O(1) insertion/remove so we invent our own
|
# in fact we can do O(1) insertion/remove so we invent our own
|
||||||
if self._timeouts:
|
if self._timeouts:
|
||||||
logging.log(utils.VERBOSE_LEVEL, 'sweeping timeouts')
|
logging.log(shell.VERBOSE_LEVEL, 'sweeping timeouts')
|
||||||
now = time.time()
|
now = time.time()
|
||||||
length = len(self._timeouts)
|
length = len(self._timeouts)
|
||||||
pos = self._timeout_offset
|
pos = self._timeout_offset
|
||||||
@@ -670,7 +663,7 @@ class TCPRelay(object):
|
|||||||
# handle events and dispatch to handlers
|
# handle events and dispatch to handlers
|
||||||
for sock, fd, event in events:
|
for sock, fd, event in events:
|
||||||
if sock:
|
if sock:
|
||||||
logging.log(utils.VERBOSE_LEVEL, 'fd %d %s', fd,
|
logging.log(shell.VERBOSE_LEVEL, 'fd %d %s', fd,
|
||||||
eventloop.EVENT_NAMES.get(event, event))
|
eventloop.EVENT_NAMES.get(event, event))
|
||||||
if sock == self._server_socket:
|
if sock == self._server_socket:
|
||||||
if event & eventloop.POLL_ERR:
|
if event & eventloop.POLL_ERR:
|
||||||
@@ -688,7 +681,7 @@ class TCPRelay(object):
|
|||||||
errno.EWOULDBLOCK):
|
errno.EWOULDBLOCK):
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
logging.error(e)
|
shell.print_exception(e)
|
||||||
if self._config['verbose']:
|
if self._config['verbose']:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
else:
|
else:
|
||||||
|
|||||||
+15
-20
@@ -1,25 +1,19 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2014 clowwindy
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Copyright 2015 clowwindy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# all copies or substantial portions of the Software.
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
#
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# License for the specific language governing permissions and limitations
|
||||||
# SOFTWARE.
|
# under the License.
|
||||||
|
|
||||||
# SOCKS5 UDP Request
|
# SOCKS5 UDP Request
|
||||||
# +----+------+------+----------+----------+----------+
|
# +----+------+------+----------+----------+----------+
|
||||||
@@ -75,7 +69,7 @@ import struct
|
|||||||
import errno
|
import errno
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from shadowsocks import encrypt, eventloop, lru_cache, common
|
from shadowsocks import encrypt, eventloop, lru_cache, common, shell
|
||||||
from shadowsocks.common import parse_header, pack_addr
|
from shadowsocks.common import parse_header, pack_addr
|
||||||
|
|
||||||
|
|
||||||
@@ -133,8 +127,9 @@ class UDPRelay(object):
|
|||||||
server_port = self._config['server_port']
|
server_port = self._config['server_port']
|
||||||
if type(server_port) == list:
|
if type(server_port) == list:
|
||||||
server_port = random.choice(server_port)
|
server_port = random.choice(server_port)
|
||||||
|
if type(server) == list:
|
||||||
|
server = random.choice(server)
|
||||||
logging.debug('chosen server: %s:%d', server, server_port)
|
logging.debug('chosen server: %s:%d', server, server_port)
|
||||||
# TODO support multiple server IP
|
|
||||||
return server, server_port
|
return server, server_port
|
||||||
|
|
||||||
def _close_client(self, client):
|
def _close_client(self, client):
|
||||||
@@ -213,7 +208,7 @@ class UDPRelay(object):
|
|||||||
if err in (errno.EINPROGRESS, errno.EAGAIN):
|
if err in (errno.EINPROGRESS, errno.EAGAIN):
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
logging.error(e)
|
shell.print_exception(e)
|
||||||
|
|
||||||
def _handle_client(self, sock):
|
def _handle_client(self, sock):
|
||||||
data, r_addr = sock.recvfrom(BUF_SIZE)
|
data, r_addr = sock.recvfrom(BUF_SIZE)
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"server":["127.0.0.1", "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
|
||||||
|
}
|
||||||
@@ -1,4 +1,18 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
#
|
||||||
|
# Copyright 2015 clowwindy
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
import tornado.ioloop
|
import tornado.ioloop
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ function run_test {
|
|||||||
python --version
|
python --version
|
||||||
coverage erase
|
coverage erase
|
||||||
mkdir tmp
|
mkdir tmp
|
||||||
run_test pep8 .
|
run_test pep8 --ignore=E402 .
|
||||||
run_test pyflakes .
|
run_test pyflakes .
|
||||||
run_test coverage run tests/nose_plugin.py -v
|
run_test coverage run tests/nose_plugin.py -v
|
||||||
run_test python setup.py sdist
|
run_test python setup.py sdist
|
||||||
@@ -41,6 +41,7 @@ run_test python tests/test.py --with-coverage -c tests/salsa20.json
|
|||||||
run_test python tests/test.py --with-coverage -c tests/chacha20.json
|
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/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
|
||||||
@@ -48,6 +49,9 @@ run_test python tests/test.py --with-coverage -b "-m rc4-md5 -k testrc4 -s 127.0
|
|||||||
run_test python tests/test.py --with-coverage -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 --workers 1" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -t 30 -qq -b 127.0.0.1"
|
run_test python tests/test.py --with-coverage -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 --workers 1" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -t 30 -qq -b 127.0.0.1"
|
||||||
run_test python tests/test.py --with-coverage --should-fail --url="http://127.0.0.1/" -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 --forbidden-ip=127.0.0.1,::1,8.8.8.8" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -t 30 -b 127.0.0.1"
|
run_test python tests/test.py --with-coverage --should-fail --url="http://127.0.0.1/" -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 --forbidden-ip=127.0.0.1,::1,8.8.8.8" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -t 30 -b 127.0.0.1"
|
||||||
|
|
||||||
|
# test if DNS works
|
||||||
|
run_test python tests/test.py --with-coverage -c tests/aes.json --url="https://clients1.google.com/generate_204"
|
||||||
|
|
||||||
# test localhost is in the forbidden list by default
|
# test localhost is in the forbidden list by default
|
||||||
run_test python tests/test.py --with-coverage --should-fail --tcp-only --url="http://127.0.0.1/" -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -t 30 -b 127.0.0.1"
|
run_test python tests/test.py --with-coverage --should-fail --tcp-only --url="http://127.0.0.1/" -b "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388" -a "-m aes-256-cfb -k testrc4 -s 127.0.0.1 -p 8388 -l 1081 -t 30 -b 127.0.0.1"
|
||||||
|
|
||||||
@@ -1,3 +1,19 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
#
|
||||||
|
# Copyright 2015 clowwindy
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
import nose
|
import nose
|
||||||
from nose.plugins.base import Plugin
|
from nose.plugins.base import Plugin
|
||||||
|
|
||||||
|
|||||||
+16
-18
@@ -1,25 +1,19 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright (c) 2014 clowwindy
|
|
||||||
#
|
#
|
||||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
# Copyright 2015 clowwindy
|
||||||
# of this software and associated documentation files (the "Software"), to deal
|
|
||||||
# in the Software without restriction, including without limitation the rights
|
|
||||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
# copies of the Software, and to permit persons to whom the Software is
|
|
||||||
# furnished to do so, subject to the following conditions:
|
|
||||||
#
|
#
|
||||||
# The above copyright notice and this permission notice shall be included in
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
# all copies or substantial portions of the Software.
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
#
|
#
|
||||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
#
|
||||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# License for the specific language governing permissions and limitations
|
||||||
# SOFTWARE.
|
# under the License.
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function, \
|
from __future__ import absolute_import, division, print_function, \
|
||||||
with_statement
|
with_statement
|
||||||
@@ -34,6 +28,8 @@ from subprocess import Popen, PIPE
|
|||||||
|
|
||||||
python = ['python']
|
python = ['python']
|
||||||
|
|
||||||
|
default_url = 'http://localhost/'
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description='test Shadowsocks')
|
parser = argparse.ArgumentParser(description='test Shadowsocks')
|
||||||
parser.add_argument('-c', '--client-conf', type=str, default=None)
|
parser.add_argument('-c', '--client-conf', type=str, default=None)
|
||||||
parser.add_argument('-s', '--server-conf', type=str, default=None)
|
parser.add_argument('-s', '--server-conf', type=str, default=None)
|
||||||
@@ -42,7 +38,7 @@ parser.add_argument('-b', '--server-args', type=str, default=None)
|
|||||||
parser.add_argument('--with-coverage', action='store_true', default=None)
|
parser.add_argument('--with-coverage', action='store_true', default=None)
|
||||||
parser.add_argument('--should-fail', action='store_true', default=None)
|
parser.add_argument('--should-fail', action='store_true', default=None)
|
||||||
parser.add_argument('--tcp-only', action='store_true', default=None)
|
parser.add_argument('--tcp-only', action='store_true', default=None)
|
||||||
parser.add_argument('--url', type=str, default='http://www.example.com/')
|
parser.add_argument('--url', type=str, default=default_url)
|
||||||
parser.add_argument('--dns', type=str, default='8.8.8.8')
|
parser.add_argument('--dns', type=str, default='8.8.8.8')
|
||||||
|
|
||||||
config = parser.parse_args()
|
config = parser.parse_args()
|
||||||
@@ -65,6 +61,8 @@ if config.client_args:
|
|||||||
server_args.extend(config.server_args.split())
|
server_args.extend(config.server_args.split())
|
||||||
else:
|
else:
|
||||||
server_args.extend(config.client_args.split())
|
server_args.extend(config.client_args.split())
|
||||||
|
if config.url == default_url:
|
||||||
|
server_args.extend(['--forbidden-ip', ''])
|
||||||
|
|
||||||
p1 = Popen(server_args, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
|
p1 = Popen(server_args, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
|
||||||
p2 = Popen(client_args, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
|
p2 = Popen(client_args, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True)
|
||||||
|
|||||||
@@ -6,6 +6,9 @@ PYTHON="coverage run -a -p"
|
|||||||
LOCAL="$PYTHON shadowsocks/local.py"
|
LOCAL="$PYTHON shadowsocks/local.py"
|
||||||
SERVER="$PYTHON shadowsocks/server.py"
|
SERVER="$PYTHON shadowsocks/server.py"
|
||||||
|
|
||||||
|
assert "$LOCAL --version 2>&1 | grep Shadowsocks | awk -F\" \" '{print \$1}'" "Shadowsocks"
|
||||||
|
assert "$SERVER --version 2>&1 | grep Shadowsocks | awk -F\" \" '{print \$1}'" "Shadowsocks"
|
||||||
|
|
||||||
assert "$LOCAL 2>&1 | grep ERROR" "ERROR: config not specified"
|
assert "$LOCAL 2>&1 | grep ERROR" "ERROR: config not specified"
|
||||||
assert "$LOCAL 2>&1 | grep usage | cut -d: -f1" "usage"
|
assert "$LOCAL 2>&1 | grep usage | cut -d: -f1" "usage"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user