shadowsocks-manager 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. shadowsocks_manager-0.1.1/LICENSE +21 -0
  2. shadowsocks_manager-0.1.1/PKG-INFO +475 -0
  3. shadowsocks_manager-0.1.1/README.md +410 -0
  4. shadowsocks_manager-0.1.1/bin/ssm-dev-start +34 -0
  5. shadowsocks_manager-0.1.1/bin/ssm-dev-stop +20 -0
  6. shadowsocks_manager-0.1.1/bin/ssm-setup +221 -0
  7. shadowsocks_manager-0.1.1/bin/ssm-test +113 -0
  8. shadowsocks_manager-0.1.1/pyproject.toml +3 -0
  9. shadowsocks_manager-0.1.1/setup.cfg +107 -0
  10. shadowsocks_manager-0.1.1/setup.py +5 -0
  11. shadowsocks_manager-0.1.1/shadowsocks_manager/__init__.py +0 -0
  12. shadowsocks_manager-0.1.1/shadowsocks_manager/__main__.py +45 -0
  13. shadowsocks_manager-0.1.1/shadowsocks_manager/args_formatter/__init__.py +74 -0
  14. shadowsocks_manager-0.1.1/shadowsocks_manager/args_formatter/tests.py +42 -0
  15. shadowsocks_manager-0.1.1/shadowsocks_manager/domain/__init__.py +0 -0
  16. shadowsocks_manager-0.1.1/shadowsocks_manager/domain/admin.py +78 -0
  17. shadowsocks_manager-0.1.1/shadowsocks_manager/domain/apps.py +10 -0
  18. shadowsocks_manager-0.1.1/shadowsocks_manager/domain/migrations/0001_initial.py +79 -0
  19. shadowsocks_manager-0.1.1/shadowsocks_manager/domain/migrations/__init__.py +0 -0
  20. shadowsocks_manager-0.1.1/shadowsocks_manager/domain/models.py +265 -0
  21. shadowsocks_manager-0.1.1/shadowsocks_manager/domain/serializers.py +25 -0
  22. shadowsocks_manager-0.1.1/shadowsocks_manager/domain/tests.py +138 -0
  23. shadowsocks_manager-0.1.1/shadowsocks_manager/domain/urls.py +18 -0
  24. shadowsocks_manager-0.1.1/shadowsocks_manager/domain/views.py +38 -0
  25. shadowsocks_manager-0.1.1/shadowsocks_manager/dynamicmethod/__init__.py +0 -0
  26. shadowsocks_manager-0.1.1/shadowsocks_manager/dynamicmethod/admin.py +8 -0
  27. shadowsocks_manager-0.1.1/shadowsocks_manager/dynamicmethod/apps.py +10 -0
  28. shadowsocks_manager-0.1.1/shadowsocks_manager/dynamicmethod/migrations/__init__.py +0 -0
  29. shadowsocks_manager-0.1.1/shadowsocks_manager/dynamicmethod/models.py +96 -0
  30. shadowsocks_manager-0.1.1/shadowsocks_manager/dynamicmethod/tests.py +8 -0
  31. shadowsocks_manager-0.1.1/shadowsocks_manager/dynamicmethod/views.py +8 -0
  32. shadowsocks_manager-0.1.1/shadowsocks_manager/manage.py +29 -0
  33. shadowsocks_manager-0.1.1/shadowsocks_manager/notification/__init__.py +0 -0
  34. shadowsocks_manager-0.1.1/shadowsocks_manager/notification/admin.py +18 -0
  35. shadowsocks_manager-0.1.1/shadowsocks_manager/notification/apps.py +10 -0
  36. shadowsocks_manager-0.1.1/shadowsocks_manager/notification/migrations/0001_initial.py +40 -0
  37. shadowsocks_manager-0.1.1/shadowsocks_manager/notification/migrations/__init__.py +0 -0
  38. shadowsocks_manager-0.1.1/shadowsocks_manager/notification/models.py +66 -0
  39. shadowsocks_manager-0.1.1/shadowsocks_manager/notification/serializers.py +13 -0
  40. shadowsocks_manager-0.1.1/shadowsocks_manager/notification/tests.py +93 -0
  41. shadowsocks_manager-0.1.1/shadowsocks_manager/notification/urls.py +16 -0
  42. shadowsocks_manager-0.1.1/shadowsocks_manager/notification/views.py +19 -0
  43. shadowsocks_manager-0.1.1/shadowsocks_manager/retry/__init__.py +68 -0
  44. shadowsocks_manager-0.1.1/shadowsocks_manager/retry/tests.py +42 -0
  45. shadowsocks_manager-0.1.1/shadowsocks_manager/shadowsocks_manager/__init__.py +6 -0
  46. shadowsocks_manager-0.1.1/shadowsocks_manager/shadowsocks_manager/celery.py +27 -0
  47. shadowsocks_manager-0.1.1/shadowsocks_manager/shadowsocks_manager/settings.py +217 -0
  48. shadowsocks_manager-0.1.1/shadowsocks_manager/shadowsocks_manager/urls.py +31 -0
  49. shadowsocks_manager-0.1.1/shadowsocks_manager/shadowsocks_manager/wsgi.py +19 -0
  50. shadowsocks_manager-0.1.1/shadowsocks_manager/shadowsocksz/__init__.py +0 -0
  51. shadowsocks_manager-0.1.1/shadowsocks_manager/shadowsocksz/admin.py +188 -0
  52. shadowsocks_manager-0.1.1/shadowsocks_manager/shadowsocksz/apps.py +10 -0
  53. shadowsocks_manager-0.1.1/shadowsocks_manager/shadowsocksz/management/__init__.py +0 -0
  54. shadowsocks_manager-0.1.1/shadowsocks_manager/shadowsocksz/management/commands/__init__.py +0 -0
  55. shadowsocks_manager-0.1.1/shadowsocks_manager/shadowsocksz/management/commands/shadowsocks_config.py +24 -0
  56. shadowsocks_manager-0.1.1/shadowsocks_manager/shadowsocksz/migrations/0001_initial.py +114 -0
  57. shadowsocks_manager-0.1.1/shadowsocks_manager/shadowsocksz/migrations/__init__.py +0 -0
  58. shadowsocks_manager-0.1.1/shadowsocks_manager/shadowsocksz/models.py +1024 -0
  59. shadowsocks_manager-0.1.1/shadowsocks_manager/shadowsocksz/serializers.py +41 -0
  60. shadowsocks_manager-0.1.1/shadowsocks_manager/shadowsocksz/tasks.py +21 -0
  61. shadowsocks_manager-0.1.1/shadowsocks_manager/shadowsocksz/tests.py +470 -0
  62. shadowsocks_manager-0.1.1/shadowsocks_manager/shadowsocksz/urls.py +20 -0
  63. shadowsocks_manager-0.1.1/shadowsocks_manager/shadowsocksz/views.py +53 -0
  64. shadowsocks_manager-0.1.1/shadowsocks_manager/singleton/__init__.py +0 -0
  65. shadowsocks_manager-0.1.1/shadowsocks_manager/singleton/admin.py +8 -0
  66. shadowsocks_manager-0.1.1/shadowsocks_manager/singleton/apps.py +10 -0
  67. shadowsocks_manager-0.1.1/shadowsocks_manager/singleton/migrations/__init__.py +0 -0
  68. shadowsocks_manager-0.1.1/shadowsocks_manager/singleton/models.py +46 -0
  69. shadowsocks_manager-0.1.1/shadowsocks_manager/singleton/tests.py +8 -0
  70. shadowsocks_manager-0.1.1/shadowsocks_manager/singleton/views.py +8 -0
  71. shadowsocks_manager-0.1.1/shadowsocks_manager/statistic/__init__.py +0 -0
  72. shadowsocks_manager-0.1.1/shadowsocks_manager/statistic/admin.py +78 -0
  73. shadowsocks_manager-0.1.1/shadowsocks_manager/statistic/apps.py +10 -0
  74. shadowsocks_manager-0.1.1/shadowsocks_manager/statistic/migrations/0001_initial.py +57 -0
  75. shadowsocks_manager-0.1.1/shadowsocks_manager/statistic/migrations/0002_auto_20210313_1419.py +19 -0
  76. shadowsocks_manager-0.1.1/shadowsocks_manager/statistic/migrations/__init__.py +0 -0
  77. shadowsocks_manager-0.1.1/shadowsocks_manager/statistic/models.py +308 -0
  78. shadowsocks_manager-0.1.1/shadowsocks_manager/statistic/serializers.py +19 -0
  79. shadowsocks_manager-0.1.1/shadowsocks_manager/statistic/tasks.py +17 -0
  80. shadowsocks_manager-0.1.1/shadowsocks_manager/statistic/tests.py +99 -0
  81. shadowsocks_manager-0.1.1/shadowsocks_manager/statistic/urls.py +16 -0
  82. shadowsocks_manager-0.1.1/shadowsocks_manager/statistic/views.py +26 -0
  83. shadowsocks_manager-0.1.1/shadowsocks_manager/utils/__init__.py +0 -0
  84. shadowsocks_manager-0.1.1/shadowsocks_manager/utils/celery.py +28 -0
  85. shadowsocks_manager-0.1.1/shadowsocks_manager/utils/createsuperuser.py +57 -0
  86. shadowsocks_manager-0.1.1/shadowsocks_manager/utils/dotenv.py +70 -0
  87. shadowsocks_manager-0.1.1/shadowsocks_manager/utils/manage.py +29 -0
  88. shadowsocks_manager-0.1.1/shadowsocks_manager/utils/uwsgi.py +27 -0
  89. shadowsocks_manager-0.1.1/shadowsocks_manager.egg-info/PKG-INFO +475 -0
  90. shadowsocks_manager-0.1.1/shadowsocks_manager.egg-info/SOURCES.txt +93 -0
  91. shadowsocks_manager-0.1.1/shadowsocks_manager.egg-info/dependency_links.txt +1 -0
  92. shadowsocks_manager-0.1.1/shadowsocks_manager.egg-info/entry_points.txt +7 -0
  93. shadowsocks_manager-0.1.1/shadowsocks_manager.egg-info/requires.txt +39 -0
  94. shadowsocks_manager-0.1.1/shadowsocks_manager.egg-info/top_level.txt +1 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Alex Zhang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,475 @@
1
+ Metadata-Version: 2.1
2
+ Name: shadowsocks-manager
3
+ Version: 0.1.1
4
+ Summary: A shadowsocks manager for multi-user and traffic statistics
5
+ Home-page: https://github.com/alexzhangs/shadowsocks-manager
6
+ Author: Alex
7
+ Author-email: alexzhangs@gmail.com
8
+ License: MIT
9
+ Keywords: shadowsocks,manager,django,web,statistics,cluster,celery,uwsgi,pypi,docker,github-actions
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Environment :: Web Environment
12
+ Classifier: Framework :: Django
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: MacOS
16
+ Classifier: Operating System :: POSIX :: Linux
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 2
19
+ Classifier: Programming Language :: Python :: 2.7
20
+ Classifier: Programming Language :: Python :: 3
21
+ Classifier: Programming Language :: Python :: 3.7
22
+ Classifier: Programming Language :: Python :: 3.8
23
+ Classifier: Programming Language :: Python :: 3.9
24
+ Classifier: Programming Language :: Python :: 3.10
25
+ Classifier: Programming Language :: Python :: 3.11
26
+ Classifier: Programming Language :: Python :: 3.12
27
+ Classifier: Topic :: Internet :: Proxy Servers
28
+ Classifier: Topic :: Internet :: WWW/HTTP
29
+ Classifier: Topic :: Internet :: WWW/HTTP :: WSGI :: Application
30
+ Classifier: Topic :: Security :: Cryptography
31
+ Classifier: Topic :: System :: Networking :: Firewalls
32
+ Classifier: Topic :: System :: Systems Administration
33
+ Requires-Python: >=2.7
34
+ Description-Content-Type: text/markdown
35
+ License-File: LICENSE
36
+ Requires-Dist: future
37
+ Requires-Dist: six
38
+ Requires-Dist: boto3
39
+ Requires-Dist: celery
40
+ Requires-Dist: Django<4
41
+ Requires-Dist: django-allowedsites-dynamic
42
+ Requires-Dist: django-cache-lock
43
+ Requires-Dist: django-celery-beat==1.6.0; python_version <= "2.7"
44
+ Requires-Dist: django-celery-beat<2.6.0; python_version < "3.8"
45
+ Requires-Dist: django-celery-beat; python_version >= "3.8"
46
+ Requires-Dist: django-celery-results==2.0.1; python_version <= "2.7"
47
+ Requires-Dist: django-celery-results; python_version > "2.7"
48
+ Requires-Dist: django-enumfield<3.0; python_version <= "2.7"
49
+ Requires-Dist: django-enumfield; python_version > "2.7"
50
+ Requires-Dist: django-filter~=1.1; python_version <= "2.7"
51
+ Requires-Dist: django-filter; python_version > "2.7"
52
+ Requires-Dist: django-import-export
53
+ Requires-Dist: djangorestframework
54
+ Requires-Dist: docopt
55
+ Requires-Dist: ipaddress; python_version < "3.3"
56
+ Requires-Dist: psutil
57
+ Requires-Dist: python-crontab==2.6.0; python_version <= "2.7"
58
+ Requires-Dist: python-crontab; python_version > "2.7"
59
+ Requires-Dist: python-decouple
60
+ Requires-Dist: python-memcached==1.59
61
+ Requires-Dist: pytz
62
+ Requires-Dist: requests
63
+ Requires-Dist: shadowsocks-alexforks
64
+ Requires-Dist: uWSGI
65
+
66
+ [![GitHub tag](https://img.shields.io/github/v/tag/alexzhangs/shadowsocks-manager?sort=date)](https://github.com/alexzhangs/shadowsocks-manager/tags)
67
+ [![GitHub](https://img.shields.io/github/license/alexzhangs/shadowsocks-manager.svg?style=flat-square)](https://github.com/alexzhangs/shadowsocks-manager/)
68
+ [![GitHub last commit](https://img.shields.io/github/last-commit/alexzhangs/shadowsocks-manager.svg?style=flat-square)](https://github.com/alexzhangs/shadowsocks-manager/commits/master)
69
+
70
+ [![Test shadowsocks-manager](https://github.com/alexzhangs/shadowsocks-manager/actions/workflows/main.yml/badge.svg)](https://github.com/alexzhangs/shadowsocks-manager/actions/workflows/main.yml)
71
+ [![codecov](https://codecov.io/gh/alexzhangs/shadowsocks-manager/graph/badge.svg?token=KTI3TNRKAV)](https://codecov.io/gh/alexzhangs/shadowsocks-manager)
72
+ [![GitHub issues](https://img.shields.io/github/issues/alexzhangs/shadowsocks-manager.svg?style=flat-square)](https://github.com/alexzhangs/shadowsocks-manager/issues)
73
+ [![GitHub pull requests](https://img.shields.io/github/issues-pr/alexzhangs/shadowsocks-manager.svg?style=flat-square)](https://github.com/alexzhangs/shadowsocks-manager/pulls)
74
+
75
+ # shadowsocks-manager
76
+
77
+ A web-based Shadowsocks management tool.
78
+
79
+ Features:
80
+
81
+ * Central user management
82
+ * Heartbeat on Shadowsocks ports(users)
83
+ * Shadowsocks multi-user API
84
+ * Shadowsocks node cluster
85
+ * Statistic for network traffic usage
86
+ * Scheduled jobs
87
+ * name.com API
88
+ * Auto-creating DNS records
89
+ * Production deployment ready
90
+ * How's the Shadowsocks supported:
91
+ * libev edition:
92
+ * Full functional.
93
+ * No builtin service manager, you need to install it and start the service by yourself.
94
+ * python edition:
95
+ * Lacks the collection of traffic statistics.
96
+ * Lacks the ability to test user port creation status.
97
+ * Pre-installed, and have a builtin service manager.
98
+
99
+ Code in Python, base on Django, Django REST framework, Celery, and SQLite.
100
+
101
+ The development status can be found at: [project home](https://github.com/alexzhangs/shadowsocks-manager/projects/1).
102
+
103
+ Node List:
104
+ ![Home › Shadowsocks › Shadowsocks Nodes](/assets/images/shadowsocks-node-list.png)
105
+
106
+ Node's Shadowsocks Manager:
107
+ ![Home › Shadowsocks › Shadowsocks Nodes](/assets/images/shadowsocks-node-ssmanager.png)
108
+
109
+
110
+ ## 1. Requirements
111
+
112
+ * Python 2.7, Python 3.x
113
+ * Django 1.11.x, Django 3.x
114
+ * macOS Big Sur
115
+ * [AWS Amazon Linux AMI](https://aws.amazon.com/amazon-linux-ami/)
116
+ * [AWS Amazon Linux 2 AMI](https://aws.amazon.com/amazon-linux-2/)
117
+ * [Shadowsocks-libev 3.2.0 for Linux (multi-user API is required)](https://github.com/shadowsocks/shadowsocks-libev)
118
+
119
+
120
+ ## 2. Install
121
+
122
+ This project is a part of an entire VPN solution, which includes the Shadowsocks server and Shadowsocks manager. The Shadowsocks server serves the traffic, the Shadowsocks manager serves the users and the traffic statistics. The solution is designed to be deployed in the AWS cloud. If you are looking for such a solution, you can refer to the repo [aws-cfn-vpn](https://github.com/alexzhangs/aws-cfn-vpn). With `aws-cfn-vpn`, you can deploy the entire solution with a few commands.
123
+
124
+ ### 2.1. Dependencies
125
+
126
+ Assume you have installed the [Docker](https://www.docker.com/) on your host.
127
+
128
+ ### 2.2. Manual installation
129
+
130
+ ```sh
131
+ # create a docker network
132
+ docker network create ssm-network
133
+
134
+ # run memcached, used by django cache
135
+ docker run -d -p 11211:11211 --network ssm-network --name ssm-memcached memcached
136
+
137
+ # run rabbitmq, used by celery
138
+ docker run -d -p 5672:5672 --network ssm-network --name ssm-rabbitmq rabbitmq
139
+
140
+ # create a directory to store the data, it will be mounted to the container
141
+ mkdir -p ~/ssm-volume
142
+
143
+ # run the shadowsocks-manager
144
+ docker run -d -p 80:80 --network ssm-network -v ~/ssm-volume:/var/local/ssm --name ssm alexzhangs/shadowsocks-manager \
145
+ -e SSM_SECRET_KEY=yourkey -e SSM_DEBUG=False -e SSM_MEMCACHED_HOST=ssm-memcached -e SSM_RABBITMQ_HOST=ssm-rabbitmq \
146
+ -u admin -p yourpassword -M admin@yourdomain.com
147
+ ```
148
+
149
+ ### 2.3. Install with script
150
+
151
+ ```sh
152
+ git clone https://github.com/alexzhangs/shadowsocks-manager
153
+ bash shadowsocks-manager/install.sh -u admin -p yourpassword -M admin@yourdomain.com
154
+ ```
155
+
156
+ ### 2.4. Verify the installation
157
+
158
+ If all go smoothly, the shadowsocks-manager services should have been all started. Open the web admin console in a web browser, and log on with the admin user.
159
+
160
+ Use:
161
+ ```
162
+ http://<your_server_ip>/admin
163
+ or
164
+ http://localhost/admin
165
+ ```
166
+
167
+ If goes well, then congratulations! The installation has succeeded.
168
+
169
+
170
+ ## 3. Using shadowsocks-manager
171
+
172
+ 1. Shadowsocks server
173
+
174
+ First, you need to have a Shadowsocks server with the multi-user API
175
+ enabled.
176
+
177
+ About how to install and configure Shadowsocks server in AWS, refer
178
+ to the repo
179
+ [aws-ec2-shadowsocks-libev](https://github.com/alexzhangs/aws-ec2-shadowsocks-libev)
180
+
181
+ After the server is installed and started, there should be a
182
+ running process named `ss-manager`. Write down the IP address and
183
+ the port that the `ss-manager` is listening on, and also the public IP
184
+ address of the server, the encryption method that Shadowsocks is using,
185
+ they are going to be used in the next step.
186
+
187
+ 1. Add Shadowsocks server to shadowsocks-manager
188
+
189
+ Add the Shadowsocks server as a Node of shadowsocks-manager from
190
+ web admin console: `Home › Shadowsocks › Shadowsocks Nodes`.
191
+
192
+ 1. Create users(ports) and assign Shadowsocks Node
193
+
194
+ Create users from web admin console: `Home › Shadowsocks ›
195
+ Shadowsocks Accounts` and assign the existing nodes to them.
196
+
197
+ After a few seconds, the created user ports should be available to your
198
+ Shadowsocks client.
199
+
200
+ 1. The builtin local service manager for Shadowsocks python edition
201
+
202
+ There's a builtin local service manager available for the Shadowsocks `python edition`.
203
+
204
+ The `python edition` is pre-installed with `shadowsocks-manager`. With the service manager, you can start&stop
205
+ the local service daemon on-the-fly. Check it out from the web admin console `Home › Shadowsocks › Shadowsocks Nodes`,
206
+ under the `SHADOWSOCKS MANAGERS` tab.
207
+
208
+ However the `traffice statistics` and `user port creation status` features are not available for the
209
+ `python edition`.
210
+
211
+
212
+ ## 4. Sendmail (Optional)
213
+
214
+ `sendmail` is used to send account notification Email, it should
215
+ be configured on the same server with shadowsocks-manager.
216
+
217
+ About how to configure `sendmail` client to use AWS SES as SMTP server on AWS EC2 instance, refer to repo
218
+ [aws-ec2-ses](https://github.com/alexzhangs/aws-ec2-ses).
219
+
220
+ On macOS, refer to repo
221
+ [macos-aws-ses](https://github.com/alexzhangs/macos-aws-ses).
222
+
223
+ NOTE: This dependency needs the manual setup anyway, it is not handled by any installation script.
224
+
225
+
226
+ ## 5. Differences from the alternation: [shadowsocks/shadowsocks-manager](https://github.com/shadowsocks/shadowsocks-manager)
227
+
228
+ **This repo Do's:**
229
+
230
+ * Serve as a nonprofit business model.
231
+ * Have central user management for multi nodes.
232
+ * Collect traffic statistic that can be viewed by account, node, and period.
233
+ * Show the existence and accessibility of ports in the admin.
234
+ * Handle the DNS records if using Name.com as nameserver.
235
+
236
+ **This repo Don'ts:**
237
+
238
+ * Handle self-serviced user registration.
239
+ * Handle bill or payment.
240
+ * Need to run an additional agent on each Shadowsocks server.
241
+
242
+
243
+ ## 6. Some differences between the Shadowsocks Python edition (2.8.2) and libev edition
244
+
245
+ Version status for the Shadowsocks Python edition:
246
+ * pypi: [2.8.2](https://pypi.org/project/shadowsocks/)
247
+ * github: [3.0.0](https://github.com/shadowsocks/shadowsocks/tree/master)
248
+
249
+ Although the Shadowsocks Python edition
250
+ supports the multi-user API, but it doesn't fit this project, here's why:
251
+
252
+ * The python edition code and doc seem to be out of maintenance due to some reason. If you really need this you probably need to fork it and make your own.
253
+ * They are having different service process names and CLI interfaces which introduces the complexity of installation.
254
+ * The Python edition lacks the `list` commands. A pull request was opened years ago but never merged.
255
+ * The Python edition's `stat` command has a very different way to use, I didn't figure the usage syntax out by looking into the code.
256
+ * The Python edition's `ping` command returns a simple string `pong` rather than a list of ports.
257
+ * The Python edition's `ping` command has to be sent as the syntax: `ping:{}` in order to work if tested with `nc`. It caused by the tailing newline: `ping\n`.
258
+
259
+ So either you get some change on your own or stick with the libev edition.
260
+
261
+ ### Update for Shadowsocks Python edition on 2024-04
262
+
263
+ Both the pypi version (2.8.2) and the github master branch (3.0.0) failed to start `ssserver` due to the upstream and dependency changes.
264
+
265
+ Since the Python edition is pre-installed in this project, mainly for running test cases, I have to make a patch to make it work.
266
+
267
+ The fix based on github master branch 3.0.0, and would be minimal, just to make the `ssserver` start without any error, no more features added.
268
+ After the fix, the pre-installed Python edition will be changed from the pypi version to [my fork](https://github.com/alexforks/shadowsocks/tree/master).
269
+
270
+
271
+ ## 7. Known Issues
272
+
273
+ 1. DNS records matching for Node may not be accurate on macOS.
274
+ For unknown reason sometimes DNS query returns only one IP address
275
+ while multiple IP addresses were configured for the domain.
276
+
277
+ 1. The Shadowsocks Python edition's ssserver won't start on macOS.
278
+ The error message is like:
279
+ ```
280
+ $ ssserver -k passw0rd
281
+ WARNING: /Users/***/.pyenv/versions/3.12.0/envs/ssm-3.12/bin/python3.12 is loading libcrypto in an unsafe way
282
+ Abort trap: 6
283
+ ```
284
+
285
+ Solution:
286
+ Link the homebrew openssl library to the system library.
287
+ ```sh
288
+ sudo ln -s /opt/homebrew/opt/openssl/lib/libcrypto.dylib /usr/local/lib/
289
+ sudo ln -s /opt/homebrew/opt/openssl/lib/libssl.dylib /usr/local/lib/
290
+ ```
291
+
292
+ 1. Install the project with pip under Python 2.7 get error:
293
+ ```
294
+ pip install -e .
295
+ ```
296
+
297
+ Error message:
298
+ ```
299
+ ...
300
+ Collecting pyyaml
301
+ Downloading PyYAML-5.4.1.tar.gz (175 kB)
302
+ |████████████████████████████████| 175 kB 392 kB/s
303
+ Installing build dependencies ... done
304
+ Getting requirements to build wheel ... error
305
+ ERROR: Command errored out with exit status 1:
306
+ ...
307
+ raise AttributeError, attr
308
+ AttributeError: cython_sources
309
+ ...
310
+ ```
311
+
312
+ Solution:
313
+ ```sh
314
+ pip install --no-build-isolation -e .
315
+ ```
316
+
317
+
318
+ ## 8. Development
319
+
320
+ 1. Install the dependencies
321
+
322
+ ```sh
323
+ # run memcached, used by django cache
324
+ docker run -d -p 11211:11211 --name ssm-memcached memcached
325
+
326
+ # run rabbitmq, used by celery
327
+ docker run -d -p 5672:5672 --name ssm-rabbitmq rabbitmq
328
+ ```
329
+
330
+ 1. Link the project code in your workspace to the Python environment
331
+
332
+ ```sh
333
+ cd shadowsocks-manager
334
+ pip install -e .
335
+ ```
336
+
337
+ 1. Configure the shadowsocks-manager
338
+
339
+ ```sh
340
+ ssm-setup -c -m -l -u admin -p yourpassword
341
+ ```
342
+
343
+ 1. Run the development server
344
+
345
+ ```sh
346
+ ssm-dev-start
347
+ ```
348
+
349
+ 1. Stop the development server
350
+
351
+ ```sh
352
+ ssm-dev-stop
353
+ ```
354
+
355
+ 1. Test the Django code
356
+
357
+ ```sh
358
+ ssm-test -t
359
+ ```
360
+
361
+ 1. Test the Django code with coverage
362
+
363
+ ```sh
364
+ pip install coverage
365
+ ssm-test -c
366
+ ```
367
+
368
+ 1. Upload the coverage report to codecov
369
+
370
+ Make sure the `CODECOV_TOKEN` is exported in the environment before uploading.
371
+
372
+ ```sh
373
+ pip install codecov-cli
374
+ ssm-test -u
375
+ ```
376
+
377
+ 1. Test the Github workflows locally
378
+
379
+ ```sh
380
+ brew install act
381
+ act -j test
382
+ ```
383
+
384
+ 1. Build the pypi package
385
+
386
+ ```sh
387
+ pip install build
388
+
389
+ # build source distribution, equivalent to `python setup.py sdist`
390
+ python -m build -s
391
+
392
+ # build binary distribution for py3, equivalent to `python setup.py bdist_wheel`
393
+ python3 -m build -w
394
+
395
+ # build binary distribution for py2
396
+ python2 -m build -w
397
+ ```
398
+
399
+ 1. Upload the pypi package
400
+
401
+ Set the ~/.pypirc file with the API token from the TestPyPI and PyPI before uploading.
402
+
403
+ ```sh
404
+ pip install twine
405
+
406
+ # upload the package to the test pypi
407
+ python -m twine upload --repository testpypi dist/*
408
+
409
+ # upload the package to the live pypi
410
+ python -m twine upload dist/*
411
+ ```
412
+
413
+ 1. Test the pypi package
414
+
415
+ ```sh
416
+ # install the package from the test pypi
417
+ # --no-deps is used to skip installing dependencies for the test pypi
418
+ pip install -i https://test.pypi.org/simple/ --no-deps shadowsocks-manager
419
+
420
+ # install the package from the live pypi
421
+ # --no-binary is used to force building the package from the source
422
+ # --use-pep517 is used together to make sure the PEP 517 is tested
423
+ pip install --no-binary --use-pep517 shadowsocks-manager
424
+ ```
425
+
426
+ 1. Build the docker image
427
+
428
+ ```sh
429
+ docker build -t alexzhangs/shadowsocks-manager .
430
+ ```
431
+
432
+
433
+ ## 9. Troubleshooting
434
+
435
+ 1. Check the logs
436
+
437
+ ```
438
+ # supervisor
439
+ cat /var/log/supervisor/supervisord.log
440
+
441
+ # uWSGI
442
+ cat /var/log/ssm-uwsgi.log
443
+
444
+ # Celery
445
+ cat /var/log/ssm-cerlery*
446
+ ```
447
+
448
+ 1. Check the services
449
+
450
+ ```
451
+ # nginx
452
+ service nginx {status|start|stop|reload}
453
+
454
+ # supervisor
455
+ service supervisord {status|start|stop|restart}
456
+ supervisorctl reload
457
+ supervisorctl start all
458
+
459
+ # uWSGI
460
+ supervisorctl start ssm-uwsgi
461
+
462
+ # Celery
463
+ supervisorctl start ssm-celery-worker
464
+ supervisorctl start ssm-celery-beat
465
+ ```
466
+
467
+ 1. Check the listening ports (Linux)
468
+
469
+ ```
470
+ # TCP
471
+ netstat -tan
472
+
473
+ # UDP
474
+ netstat -uan
475
+ ```