Skip to content

Commit

Permalink
Merge pull request #13 from alexzhangs/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzhangs authored Apr 29, 2024
2 parents d7d7897 + 2f875df commit 10806a1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ Assume you have installed the [Docker](https://www.docker.com/) on your host.
docker network create ssm-network

# run memcached, used by django cache
docker run -d -p 11211:11211 --network ssm-network --name ssm-memcached memcached
docker run -d --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
docker run -d --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
Expand Down
17 changes: 15 additions & 2 deletions shadowsocks_manager/shadowsocksz/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,8 @@ def logfile(self, original=False):
@classmethod
def lift_pip_shadowsocks(cls):
"""
Workaround for the package naming conflict between the Django app `shadowsocks` and the pip package `shadowsocks`.
Workaround for the package naming conflict between the Django app `shadowsocks` and the Shadowsocks
python editon installed with pip package `shadowsocks`.
Lower the searching priority of the Django project app home dir in sys.path.
"""
import shadowsocks
Expand Down Expand Up @@ -879,6 +880,14 @@ def lift_pip_shadowsocks(cls):
# unimport the package
del sys.modules['shadowsocks']

@classmethod
def random_password(cls, length=16):
"""
Return a random password string.
"""
import random, string
return ''.join(random.choices(string.ascii_letters + string.digits, k=length))

def call(self, command, *args, **kwargs):
"""
Call Shadowsocks server command by subprocess.Popen().
Expand Down Expand Up @@ -954,7 +963,11 @@ def start(self):
'--log-file', self.logfile(),
'-d', 'start',
'--manager-address', '{}:{}'.format(self.manager._ip, self.manager.port), # the options order matters
'-k', 'passw0rd',
# The shadowsocks python edition does not support to run the manager without a server port.
# So, the server port is set to 65500, which is not supposed to be used by any client.
# And the password is set to a random string, which is not supposed to be known by any client.
'-p 65500',
'-k', self.random_password(),
'-m', self.manager.encrypt,
'-t', str(self.manager.timeout),
'--fast-open', str(self.manager.fastopen),
Expand Down

0 comments on commit 10806a1

Please sign in to comment.