Skip to main content

GitHub tag GitHub GitHub last commit

Test shadowsocks-manager codecov GitHub issues GitHub pull requests

shadowsocks-manager

A web-based Shadowsocks management tool.

Features:

  • Central user management
  • Heartbeat on Shadowsocks ports(users)
  • Shadowsocks multi-user API
  • Shadowsocks node cluster
  • Statistic for network traffic usage
  • Scheduled jobs
  • name.com API
  • Auto-creating DNS records
  • Production deployment ready
  • How's the Shadowsocks supported:
    • libev edition:
      • Full functional.
      • No builtin service manager, you need to install it and start the service by yourself.
    • python edition:
      • Lacks the collection of traffic statistics.
      • Lacks the ability to test user port creation status.
      • Pre-installed, and have a builtin service manager.

Code in Python, base on Django, Django REST framework, Celery, and SQLite.

The development status can be found at: project home.

Node List: Home › Shadowsocks › Shadowsocks Nodes

Node's Shadowsocks Manager: Home › Shadowsocks › Shadowsocks Nodes

1. Requirements

2. Install

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. With aws-cfn-vpn, you can deploy the entire solution with a few commands.

2.1. Dependencies

Assume you have installed the Docker on your host.

2.2. Manual installation

# create a docker network
docker network create ssm-network

# run memcached, used by django cache
docker run -d -p 11211:11211 --network ssm-network --name ssm-memcached memcached

# run rabbitmq, used by celery
docker run -d -p 5672:5672 --network ssm-network --name ssm-rabbitmq rabbitmq

# create a directory to store the data, it will be mounted to the container
mkdir -p ~/ssm-volume

# run the shadowsocks-manager
docker run -d -p 80:80 --network ssm-network -v ~/ssm-volume:/var/local/ssm --name ssm alexzhangs/shadowsocks-manager \
           -e SSM_SECRET_KEY=yourkey -e SSM_DEBUG=False -e SSM_MEMCACHED_HOST=ssm-memcached -e SSM_RABBITMQ_HOST=ssm-rabbitmq \
           -u admin -p yourpassword -M admin@yourdomain.com

2.3. Install with script

git clone https://github.com/alexzhangs/shadowsocks-manager
bash shadowsocks-manager/install.sh -u admin -p yourpassword -M admin@yourdomain.com

2.4. Verify the installation

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.

Use:

http://<your_server_ip>/admin
or 
http://localhost/admin

If goes well, then congratulations! The installation has succeeded.

3. Using shadowsocks-manager

  1. Shadowsocks server

    First, you need to have a Shadowsocks server with the multi-user API enabled.

    About how to install and configure Shadowsocks server in AWS, refer to the repo aws-ec2-shadowsocks-libev

    After the server is installed and started, there should be a running process named ss-manager. Write down the IP address and the port that the ss-manager is listening on, and also the public IP address of the server, the encryption method that Shadowsocks is using, they are going to be used in the next step.

  2. Add Shadowsocks server to shadowsocks-manager

    Add the Shadowsocks server as a Node of shadowsocks-manager from web admin console: Home › Shadowsocks › Shadowsocks Nodes.

  3. Create users(ports) and assign Shadowsocks Node

    Create users from web admin console: Home › Shadowsocks › Shadowsocks Accounts and assign the existing nodes to them.

    After a few seconds, the created user ports should be available to your Shadowsocks client.

  4. The builtin local service manager for Shadowsocks python edition

    There's a builtin local service manager available for the Shadowsocks python edition.

    The python edition is pre-installed with shadowsocks-manager. With the service manager, you can start&stop the local service daemon on-the-fly. Check it out from the web admin console Home › Shadowsocks › Shadowsocks Nodes, under the SHADOWSOCKS MANAGERS tab.

    However the traffice statistics and user port creation status features are not available for the python edition.

4. Sendmail (Optional)

sendmail is used to send account notification Email, it should be configured on the same server with shadowsocks-manager.

About how to configure sendmail client to use AWS SES as SMTP server on AWS EC2 instance, refer to repo aws-ec2-ses.

On macOS, refer to repo macos-aws-ses.

NOTE: This dependency needs the manual setup anyway, it is not handled by any installation script.

5. Differences from the alternation: shadowsocks/shadowsocks-manager

This repo Do's:

  • Serve as a nonprofit business model.
  • Have central user management for multi nodes.
  • Collect traffic statistic that can be viewed by account, node, and period.
  • Show the existence and accessibility of ports in the admin.
  • Handle the DNS records if using Name.com as nameserver.

This repo Don'ts:

  • Handle self-serviced user registration.
  • Handle bill or payment.
  • Need to run an additional agent on each Shadowsocks server.

6. Some differences between the Shadowsocks Python edition (2.8.2) and libev edition

Version status for the Shadowsocks Python edition:

Although the Shadowsocks Python edition supports the multi-user API, but it doesn't fit this project, here's why:

  • 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.
  • They are having different service process names and CLI interfaces which introduces the complexity of installation.
  • The Python edition lacks the list commands. A pull request was opened years ago but never merged.
  • 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.
  • The Python edition's ping command returns a simple string pong rather than a list of ports.
  • 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.

So either you get some change on your own or stick with the libev edition.

Update for Shadowsocks Python edition on 2024-04

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.

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.

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. After the fix, the pre-installed Python edition will be changed from the pypi version to my fork.

7. Known Issues

  1. DNS records matching for Node may not be accurate on macOS. For unknown reason sometimes DNS query returns only one IP address while multiple IP addresses were configured for the domain.

  2. The Shadowsocks Python edition's ssserver won't start on macOS. The error message is like:

    $ ssserver -k passw0rd
    WARNING: /Users/***/.pyenv/versions/3.12.0/envs/ssm-3.12/bin/python3.12 is loading libcrypto in an unsafe way
    Abort trap: 6
    

    Solution: Link the homebrew openssl library to the system library.

    sudo ln -s /opt/homebrew/opt/openssl/lib/libcrypto.dylib /usr/local/lib/
    sudo ln -s /opt/homebrew/opt/openssl/lib/libssl.dylib /usr/local/lib/
    
  3. Install the project with pip under Python 2.7 get error:

    pip install -e .
    

    Error message:

    ...
    Collecting pyyaml
    Downloading PyYAML-5.4.1.tar.gz (175 kB)
        |████████████████████████████████| 175 kB 392 kB/s 
    Installing build dependencies ... done
    Getting requirements to build wheel ... error
    ERROR: Command errored out with exit status 1:
    ...
        raise AttributeError, attr
    AttributeError: cython_sources
    ...
    

    Solution:

    pip install --no-build-isolation -e .
    

8. Development

  1. Install the dependencies

    # run memcached, used by django cache
    docker run -d -p 11211:11211 --name ssm-memcached memcached
    
    # run rabbitmq, used by celery
    docker run -d -p 5672:5672 --name ssm-rabbitmq rabbitmq
    
  2. Link the project code in your workspace to the Python environment

    cd shadowsocks-manager
    pip install -e .
    
  3. Configure the shadowsocks-manager

    ssm-setup -c -m -l -u admin -p yourpassword
    
  4. Run the development server

    ssm-dev-start
    
  5. Stop the development server

    ssm-dev-stop
    
  6. Test the Django code

    ssm-test -t
    
  7. Test the Django code with coverage

    pip install coverage
    ssm-test -c
    
  8. Upload the coverage report to codecov

    Make sure the CODECOV_TOKEN is exported in the environment before uploading.

    pip install codecov-cli
    ssm-test -u
    
  9. Test the Github workflows locally

    brew install act
    act -j test
    
  10. Build the pypi package

    pip install build
    
    # build source distribution, equivalent to `python setup.py sdist`
    python -m build -s
    
    # build binary distribution for py3, equivalent to `python setup.py bdist_wheel`
    python3 -m build -w
    
    # build binary distribution for py2
    python2 -m build -w
    
  11. Upload the pypi package

    Set the ~/.pypirc file with the API token from the TestPyPI and PyPI before uploading.

    pip install twine
    
    # upload the package to the test pypi
    python -m twine upload --repository testpypi dist/*
    
    # upload the package to the live pypi
    python -m twine upload dist/*
    
  12. Test the pypi package

    # install the package from the test pypi
    # --no-deps is used to skip installing dependencies for the test pypi
    pip install -i https://test.pypi.org/simple/ --no-deps shadowsocks-manager
    
    # install the package from the live pypi
    # --no-binary is used to force building the package from the source
    # --use-pep517 is used together to make sure the PEP 517 is tested
    pip install --no-binary --use-pep517 shadowsocks-manager
    
  13. Build the docker image

    docker build -t alexzhangs/shadowsocks-manager .
    

9. Troubleshooting

  1. Check the logs

    # supervisor
    cat /var/log/supervisor/supervisord.log
    
    # uWSGI
    cat /var/log/ssm-uwsgi.log
    
    # Celery
    cat /var/log/ssm-cerlery*
    
  2. Check the services

    # nginx
    service nginx {status|start|stop|reload}
    
    # supervisor
    service supervisord {status|start|stop|restart}
    supervisorctl reload
    supervisorctl start all
    
    # uWSGI
    supervisorctl start ssm-uwsgi
    
    # Celery
    supervisorctl start ssm-celery-worker
    supervisorctl start ssm-celery-beat
    
  3. Check the listening ports (Linux)

    # TCP
    netstat -tan
    
    # UDP
    netstat -uan
    

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

shadowsocks_manager-0.1.1.tar.gz (54.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

shadowsocks_manager-0.1.1-py3-none-any.whl (72.5 kB view details)

Uploaded Python 3

shadowsocks_manager-0.1.1-py2-none-any.whl (72.5 kB view details)

Uploaded Python 2

File details

Details for the file shadowsocks_manager-0.1.1.tar.gz.

File metadata

  • Download URL: shadowsocks_manager-0.1.1.tar.gz
  • Upload date:
  • Size: 54.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.0

File hashes

Hashes for shadowsocks_manager-0.1.1.tar.gz
Algorithm Hash digest
SHA256 84a25ab757b7b3d224a174bb4482d72cbc7b0903e2bc50f1d430d8c5e1114f9b
MD5 ef2f070f4fb84ef5d199d5ce5150becf
BLAKE2b-256 aed95b452a18db105c548040dec3999b08467be37b093c8a6df9346412e4b426

See more details on using hashes here.

File details

Details for the file shadowsocks_manager-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for shadowsocks_manager-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 88d970aab8080be5d9a76b414b5328c4762e668790fcdf30a8aaeb14389700f9
MD5 31033a42ceb3f34369335b216894eb83
BLAKE2b-256 25dfcad0cb5f8789a240f821917e34c783d4710d1512ac6bf9b99156c9a4702e

See more details on using hashes here.

File details

Details for the file shadowsocks_manager-0.1.1-py2-none-any.whl.

File metadata

File hashes

Hashes for shadowsocks_manager-0.1.1-py2-none-any.whl
Algorithm Hash digest
SHA256 6a4d3cb3943db2a1bd6ace78d58cb9a78a335f603830e7f92215391dcfc664f9
MD5 c55ecc9caeb99d7372c8dfa2a3e40cd1
BLAKE2b-256 60c58f06acaaf11bf2cca8722812f7563349c26ad40f7144293e60f89f6fe0a3

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.25

2 files

0.1.24

2 files

0.1.23

2 files

0.1.22

2 files

0.1.21

2 files

0.1.20

2 files

0.1.19

2 files

0.1.18

2 files

0.1.17

2 files

0.1.16

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

This release

0.1.1 This release

3 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page