基于 mengskysama 的多用户分支 用django admin定义了极其简单的管理界面
除了增加django网站外,基本没有动前面分支代码,除了:
- 将数据库操作从原来的cymysql方式改为django内置的model方式,因此数据库设置从原来的config.py中转移至django的settings.py文件;
- 默认数据库为sqlite,使用其他数据库在settings.py中修改
- 增加enable字段判断,从而在网页中修改字段值后能停止相应的服务
- virtual env
virtualenv env
source env/bin/active
- packages
apt-get install swig
pip install -i http://pypi.douban.com/simple/ -r requirement.txt
或
apt-get install python-m2crypto
pip install -i http://pypi.douban.com/simple/ Django==1.6.8
- run django
cd webfrontend
./manage.py syncdb
根据提示创建管理用户
./manage runserver
- run shadowsocks
cd shadowsocks
python server.py
访问:
- 使用mysql或其他作为数据库新建
如使用mysql,安装MySQL-python包(posgresql安装psycopg2包)
在安装步骤3之前修改settings.py文件中数据库部分
在数据库中创建数据库,不用创建表
- 使用已有数据库
一般是mysql,表用原来的shadowsocks.sql创建
除了安装MySQL-python和修改settings.py外
修改webfrontend/shadowsocks/models.py文件
将以下三行的注释去掉
class Meta:
managed = False
db_table = 'user'
- 配置
settings.py中
DEFAULT_THRESHOLD配置项设置默认的流量阀值
1.share shadowsocks server
2.create multi server by shadowsocks
3.manage server (transfer / account)
install MySQL 5.x.x
pip install cymysql
create a database named shadowsocks
import shadowsocks.sql
into shadowsocks
edit Config.py Example:
#Config
MYSQL_HOST = 'mdss.mengsky.net'
MYSQL_PORT = 3306
MYSQL_USER = 'ss'
MYSQL_PASS = 'ss'
MYSQL_DB = 'shadowsocks'
MANAGE_PASS = 'ss233333333'
#if you want manage in other server you should set this value to global ip
MANAGE_BIND_IP = '127.0.0.1'
#make sure this port is idle
MANAGE_PORT = 23333
TestRun cd shadowsocks
python server.py
if no exception server will startup. you will see such like Example:
db start server at port [%s] pass [%s]
passwd
server pass
port
server port
t
last keepalive time
u
upload transfer
d
download transer
transfer_enable
if u + d > transfer_enable this server will be stop (db_transfer.py del_server_out_of_bound_safe)
Manage server work in UDP at MANAGE_BIND_IP
MANAGE_PORT
use MANAGE_PASS:port:passwd:0
to del a server at port port
use MANAGE_PASS:port:passwd:1
to run a server at port port
password is passwd
Python Eg:
udpsock.sendto('MANAGE_PASS:65535:123456:1', (MANAGE_BIND_IP, MANAGE_PORT))
PHP Eg:
$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
$msg = 'MANAGE_PASS:65535:123456:1';
$len = strlen($msg);
socket_sendto($sock, $msg, $len, 0, MANAGE_BIND_IP, MANAGE_PORT);
socket_close($sock);
If error such like 2014-09-18 09:02:37 ERROR [Errno 24] Too many open files
edit /etc/security/limits.conf
Add:
* soft nofile 8192
* hard nofile 65535
A fast tunnel proxy that helps you bypass firewalls.
You'll have a client on your local machine, and install a server on a remote server.
apt-get install python-pip python-m2crypto
pip install shadowsocks
Or simply apt-get install shadowsocks
if you have Debian sid in your
source list.
yum install m2crypto python-setuptools
easy_install pip
pip install shadowsocks
On your server create a config file /etc/shadowsocks.json
.
Example:
{
"server":"my_server_ip",
"server_port":8388,
"local_address": "127.0.0.1",
"local_port":1080,
"password":"mypassword",
"timeout":300,
"method":"aes-256-cfb",
"fast_open": false,
"workers": 1
}
Explanation of the fields:
Name | Explanation |
---|---|
server | the address your server listens |
server_port | server port |
local_address | the address your local listens |
local_port | local port |
password | password used for encryption |
timeout | in seconds |
method | default: "aes-256-cfb", see Encryption |
fast_open | use TCP_FASTOPEN, true / false |
workers | number of workers, available on Unix/Linux |
Run ssserver -c /etc/shadowsocks.json
on your server. To run it in the
background, use Supervisor.
On your client machine, use the same configuration as your server, and start your client.
If you use Chrome, it's recommended to use SwitchySharp. Change the proxy settings to
protocol: socks5
hostname: 127.0.0.1
port: your local_port
If you can't install SwitchySharp, you can launch Chrome with the following arguments to force Chrome to use the proxy:
Chrome.exe --proxy-server="socks5://127.0.0.1:1080" --host-resolver-rules="MAP * 0.0.0.0 , EXCLUDE localhost"
If you can't even download Chrome, find a friend to download a Chrome Standalone installer for you.
You can use args to override settings from config.json
.
sslocal -s server_name -p server_port -l local_port -k password -m bf-cfb
ssserver -p server_port -k password -m bf-cfb --workers 2
ssserver -c /etc/shadowsocks/config.json
List all available args with -h
.
https://github.com/clowwindy/shadowsocks/wiki
MIT