完成了除了流量统计的部分

This commit is contained in:
jysperm
2014-08-19 03:23:22 +08:00
parent 30929e9242
commit 0b264c2aac
6 changed files with 41 additions and 13 deletions

View File

@@ -110,14 +110,23 @@
# ShadowSocks
add-apt-repository 'deb http://shadowsocks.org/debian wheezy main'
apt-get install shadowsocks
apt-get install python-pip python-m2crypto supervisor
pip install shadowsocks
vi /etc/default/supervisor
ulimit -n 51200
service supervisor restart
### Runtime
# Golang
apt-get install golang golang-go.tools
# Python
apt-get install python python3 python-pip python3-pip python-dev python3-dev
pip install django tornado markdown python-memcached web.py mongo uwsgi virtualenv virtualenvwrapper flask gevent jinja2 requests
# Node.js
npm install forever coffee-script gulp mocha harp bower -g

View File

@@ -7,7 +7,7 @@
margin-right: 10px;
}
img {
img.pull-left {
width: 58px;
height: 58px;
}

View File

@@ -1,6 +1,7 @@
child_process = require 'child_process'
path = require 'path'
jade = require 'jade'
fs = require 'fs'
plugin = require '../../core/plugin'
@@ -20,12 +21,18 @@ generatePort = (callback) ->
module.exports =
enable: (account, callback) ->
generatePort (port) ->
password = mAccount.randomSalt()[0...10]
mAccount.update _id: account._id,
$set:
'attribute.plugin.shadowsocks':
port: port
password: mAccount.randomSalt()
password: password
, ->
account.attribute.plugin.shadowsocks =
port: port
password: password
module.exports.restart account, ->
callback()
@@ -34,16 +41,24 @@ module.exports =
$unset:
'attribute.plugin.shadowsocks': true
, ->
#TODO kill process
callback()
# TODO delete iptables
child_process.exec "sudo rm /etc/supervisor/conf.d/#{account.username}.conf", ->
child_process.exec 'sudo supervisorctl reload', ->
callback()
restart: (account, callback) ->
config_content = _.template (fs.readFileSync path.join(__dirname, 'template/config.conf')).toString(), account.attribute.plugin.shadowsocks
plugin.writeConfig "/etc/shadowsocks/#{account.username}.conf", config_content, ->
# kill process
child_process.exec "nohup ss-server -c /etc/shadowsocks/#{account.username}.conf &", ->
callback()
# TODO iptables
plugin.writeConfig "/etc/shadowsocks/#{account.username}.json", config_content, ->
config_content = _.template (fs.readFileSync path.join(__dirname, 'template/supervisor.conf')).toString(),
account: account
plugin.writeConfig "/etc/supervisor/conf.d/#{account.username}.conf", config_content, ->
child_process.exec 'sudo supervisorctl reload', ->
callback()
widget: (account, callback) ->
jade.renderFile path.join(__dirname, 'view/widget.jade'),

View File

@@ -1,6 +1,6 @@
{
"server": "0.0.0.0",
"server_port": "<%= port %>",
"server_port": <%= port %>,
"local_port": 1080,
"password": "<%= password %>",
"timeout": 60,

View File

@@ -0,0 +1,4 @@
[program:shadowsocks-<%= account.username %>]
command=ssserver -c /etc/shadowsocks/<%= account.username %>.json
autorestart=true
user=nobody

View File

@@ -6,10 +6,10 @@ header ShadowSocks
.panel-body
.input-group(style='margin-bottom: 20px;')
span.input-group-addon 端口
input.form-control(type='text', value='14261', disabled)
input.form-control(type='text', value=account.attribute.plugin.shadowsocks.port, disabled)
.input-group
span.input-group-addon 密码
input.form-control(type='test', value='zppeLxbSfyNR2YwL', disabled)
input.form-control(type='text', value=account.attribute.plugin.shadowsocks.password, disabled)
span.input-group-btn
button.btn.btn-default(type='button') 重置