mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-05-13 09:06:32 +08:00
some test of shadowsocks
This commit is contained in:
@@ -1,15 +1,15 @@
|
||||
# RootPanel
|
||||
RootPanel 是一个 PaaS 开发框架,提供了用户系统、计费和订单系统、工单系统,允许通过开发插件的方式来支持各种网络服务的管理和销售,默认实现了一些插件来支持例如虚拟主机,ShadowSocks, 用户也可以简单地自行编写插件来拓展 RootPanel 的功能。
|
||||
RootPanel 是一个 PaaS 开发框架,提供了用户系统、计费和订单系统、工单系统,允许通过开发插件的方式来支持各种网络服务的管理和销售,默认实现了一些插件来支持例如虚拟主机,ShadowSocks 等常见服务,用户也可以简单地自行编写插件来拓展 RootPanel 的功能。
|
||||
|
||||
RootPanel 具有良好的设计,高度的可定制性,支持多语言和多时区,以及非常高的单元测试覆盖率。
|
||||
|
||||
## 安装
|
||||
|
||||
稳定版本 [](https://travis-ci.org/jysperm/RootPanel):
|
||||
稳定版本 [](https://travis-ci.org/jysperm/RootPanel)
|
||||
|
||||
git clone -b stable https://github.com/jysperm/RootPanel.git
|
||||
|
||||
开发版本 [](https://travis-ci.org/jysperm/RootPanel):
|
||||
开发版本 [](https://travis-ci.org/jysperm/RootPanel)
|
||||
|
||||
git clone https://github.com/jysperm/RootPanel.git
|
||||
|
||||
|
||||
@@ -177,9 +177,12 @@ exports.Plugin = class Plugin
|
||||
fs.readFile template_path, (err, template_file) ->
|
||||
callback _.template(template_file.toString()) view_data
|
||||
|
||||
@writeConfigFile: (filename, content, callback) ->
|
||||
@writeConfigFile: (filename, content, options, callback) ->
|
||||
unless callback
|
||||
[options, callback] = [{}, options]
|
||||
|
||||
tmp.file
|
||||
mode: 0o750
|
||||
mode: options.mode ? 0o750
|
||||
, (err, filepath, fd) ->
|
||||
logger.error err if err
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ describe 'router/account', ->
|
||||
password = null
|
||||
|
||||
before ->
|
||||
require '../../../app'
|
||||
{utils} = app
|
||||
agent = supertest.agent app.express
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
supervisor = require '../supervisor/supervisor'
|
||||
|
||||
ShadowsocksPlugin = require './index'
|
||||
|
||||
BILLING_BUCKET = config.plugins.shadowsocks.billing_bucket
|
||||
|
||||
exports.initSupervisor = (callback) ->
|
||||
@@ -11,19 +13,21 @@ exports.initSupervisor = (callback) ->
|
||||
async.each config.plugins.shadowsocks.available_ciphers, (method, callback) ->
|
||||
program_name = "shadowsocks-#{method}"
|
||||
|
||||
if program_name in _.keys program_status
|
||||
if program_name in _.pluck program_status, 'name'
|
||||
return callback()
|
||||
|
||||
shadowsocks_config_file = "/etc/shadowsocks/#{method}.json"
|
||||
configure = exports.generateConfigure [],
|
||||
method: method
|
||||
|
||||
fs.writeFile shadowsocks_config_file, configure, ->
|
||||
ShadowsocksPlugin.writeConfigFile shadowsocks_config_file, configure, {mode: 0o755}, ->
|
||||
supervisor.writeConfig {username: 'nobody'},
|
||||
program_name: program_name
|
||||
command: "ssserver -c #{shadowsocks_config_file}"
|
||||
name: program_name
|
||||
autostart: true
|
||||
autorestart: true
|
||||
stdout_logfile: false
|
||||
, ->
|
||||
supervisor.updateProgram {}, {program_name: program_name}, ->
|
||||
callback()
|
||||
@@ -45,7 +49,7 @@ exports.generateConfigure = (users, options = {}) ->
|
||||
|
||||
return JSON.stringify configure
|
||||
|
||||
exports.generatePort = (port) ->
|
||||
exports.generatePort = (callback) ->
|
||||
port = 10000 + Math.floor Math.random() * 10000
|
||||
|
||||
Account.findOne
|
||||
@@ -197,7 +201,7 @@ exports.updateConfigure = (account, callback) ->
|
||||
config = JSON.parse content
|
||||
config.port_password[port] = password
|
||||
|
||||
fs.writeFile shadowsocks_config_file, JSON.stringify(config), ->
|
||||
ShadowsocksPlugin.writeConfigFile shadowsocks_config_file, JSON.stringify(config), {mode: 0o755}, ->
|
||||
callback()
|
||||
|
||||
(callback) ->
|
||||
|
||||
55
plugin/shadowsocks/test/shadowsocks.test.coffee
Normal file
55
plugin/shadowsocks/test/shadowsocks.test.coffee
Normal file
@@ -0,0 +1,55 @@
|
||||
describe 'plugin/shadowsocks', ->
|
||||
agent = null
|
||||
utils = null
|
||||
config = null
|
||||
Account = null
|
||||
|
||||
csrf_token = null
|
||||
account_id = null
|
||||
|
||||
before ->
|
||||
{utils, config} = app
|
||||
{Account} = app.models
|
||||
agent = supertest.agent app.express
|
||||
|
||||
config.plans.shadowsocks =
|
||||
t_name: 'shadowsocks'
|
||||
t_description: 'shadowsocks'
|
||||
|
||||
services: ['shadowsocks']
|
||||
|
||||
describe 'router', ->
|
||||
it 'POST register', (done) ->
|
||||
agent.get '/account/session_info'
|
||||
.end (err, res) ->
|
||||
csrf_token = res.body.csrf_token
|
||||
|
||||
agent.post '/account/register'
|
||||
.send
|
||||
csrf_token: csrf_token
|
||||
username: "test#{utils.randomString(20).toLowerCase()}"
|
||||
email: "#{utils.randomString 20}@gmail.com"
|
||||
password: utils.randomString 20
|
||||
.end (err, res) ->
|
||||
account_id = res.body.id
|
||||
created_objects.accounts.push ObjectId account_id
|
||||
|
||||
Account.findByIdAndUpdate account_id,
|
||||
$set:
|
||||
'billing.balance': 10
|
||||
, ->
|
||||
done err
|
||||
|
||||
it 'POST join_plan', (done) ->
|
||||
agent.post '/billing/join_plan'
|
||||
.send
|
||||
csrf_token: csrf_token
|
||||
plan: 'shadowsocks'
|
||||
.expect 200
|
||||
.end done
|
||||
|
||||
it 'POST reset_password'
|
||||
|
||||
it 'POST switch_method'
|
||||
|
||||
it 'POST leave_plan'
|
||||
@@ -4,7 +4,9 @@ autostart = <%= program.autostart.toString() %>
|
||||
autorestart = <%= program.autorestart %>
|
||||
user = <%= account.username %>
|
||||
redirect_stderr = true
|
||||
<% if (program.stdout_logfile !== false) { %>
|
||||
stdout_logfile = /home/<%= account.username %>/supervisor-<%= program.name %>.log
|
||||
<% } %>
|
||||
<% if(program.directory) { %>
|
||||
directory = <%= program.directory %>
|
||||
<% } %>
|
||||
|
||||
@@ -43,9 +43,6 @@ module.exports =
|
||||
t_name: 'plans.test.name'
|
||||
t_description: 'plans.test.description'
|
||||
|
||||
billing_by_usage:
|
||||
auto_leave: 7 * 24 * 3600 * 1000
|
||||
|
||||
services: []
|
||||
resources: {}
|
||||
|
||||
|
||||
@@ -28,13 +28,10 @@ module.exports =
|
||||
billing_cycle: 10 * 60 * 1000
|
||||
|
||||
plans:
|
||||
all:
|
||||
shadowsocks:
|
||||
t_name: 'plugins.rpvhost.plans.shadowsocks.name'
|
||||
t_description: 'plugins.rpvhost.plans.shadowsocks.description'
|
||||
|
||||
billing_by_usage:
|
||||
auto_leave: 14 * 24 * 3600 * 1000
|
||||
|
||||
services: ['shadowsocks']
|
||||
|
||||
mongodb:
|
||||
|
||||
Reference in New Issue
Block a user