mirror of
https://github.com/HackPlan/RootPanel.git
synced 2026-03-26 07:44:10 +08:00
fixbugs in shadowsocks
This commit is contained in:
@@ -11,7 +11,6 @@ linux = require './linux'
|
||||
monitor = require './monitor'
|
||||
|
||||
exports.registerHook 'view.layout.menu_bar',
|
||||
always_notice: true
|
||||
href: '/public/monitor/'
|
||||
t_body: 'plugins.linux.server_monitor'
|
||||
|
||||
|
||||
@@ -25,7 +25,3 @@ mixin displayProgressBar(now, limit, unit)
|
||||
td= t('widget.storage')
|
||||
td
|
||||
mixin displayProgressBar(usage.storage, limit.storage, 'M')
|
||||
tr
|
||||
td= t('widget.month_transfer')
|
||||
td
|
||||
mixin displayProgressBar(0, limit.transfer, 'G')
|
||||
|
||||
@@ -16,6 +16,10 @@ exports.registerHook 'view.layout.menu_bar',
|
||||
target: '_blank'
|
||||
t_body: 'plugins.rpvhost.official_blog'
|
||||
|
||||
if config.plugins.rpvhost.green_style
|
||||
exports.registerHook 'view.layout.styles',
|
||||
path: '/plugin/rpvhost/style/green.css'
|
||||
|
||||
exports.registerHook 'billing.payment_methods',
|
||||
widget_generator: (req, callback) ->
|
||||
exports.render 'payment_method', req, {}, callback
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
"all": {
|
||||
"name": "All Service (Default)",
|
||||
"description": "Storage 520MB, Memory: 27MB, Traffic of month: 37GB"
|
||||
},
|
||||
"shadowsocks": {
|
||||
"name": "ShadowSocks",
|
||||
"description": "Billing by usage, 0.6 CNY / G"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
"all": {
|
||||
"name": "所有服务(默认)",
|
||||
"description": "磁盘: 520MB, 内存: 27MB, 流量: 37GB"
|
||||
},
|
||||
"shadowsocks": {
|
||||
"name": "ShadowSocks",
|
||||
"description": "按量付费,0.6 CNY / G"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
15
plugin/rpvhost/static/style/green.less
Normal file
15
plugin/rpvhost/static/style/green.less
Normal file
@@ -0,0 +1,15 @@
|
||||
body {
|
||||
> header {
|
||||
background: #1c9b47;
|
||||
|
||||
nav.navbar-inverse {
|
||||
background: #1c9b47;
|
||||
}
|
||||
|
||||
.navbar-inverse {
|
||||
.navbar-nav > .active > a, .navbar-nav > .open > a, .navbar-nav > .active > a:hover, .navbar-nav > .active > a:focus {
|
||||
background: #18813f !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
{_, fs} = app.libs
|
||||
{pluggable, config, utils} = app
|
||||
|
||||
exports = module.exports = class ShadowSocksPlugin extends pluggable.Plugin
|
||||
@@ -8,7 +9,8 @@ exports = module.exports = class ShadowSocksPlugin extends pluggable.Plugin
|
||||
shadowsocks = require './shadowsocks'
|
||||
|
||||
exports.registerHook 'plugin.wiki.pages',
|
||||
t_category: 'shadowsocks'
|
||||
always_notice: true
|
||||
t_category: 'plugins.shadowsocks.'
|
||||
t_title: 'README.md'
|
||||
language: 'zh_CN'
|
||||
content_markdown: fs.readFileSync("#{__dirname}/wiki/README.md").toString()
|
||||
@@ -19,15 +21,13 @@ exports.registerHook 'view.panel.scripts',
|
||||
exports.registerHook 'view.panel.styles',
|
||||
path: '/plugin/shadowsocks/style/panel.css'
|
||||
|
||||
if config.plugins.shadowsocks.green_style
|
||||
exports.registerHook 'view.layout.styles',
|
||||
path: '/plugin/shadowsocks/style/layout.css'
|
||||
|
||||
exports.registerHook 'view.panel.widgets',
|
||||
generator: (req, callback) ->
|
||||
price_gb = config.plugins.shadowsocks.price_bucket * (1000 * 1000 * 1000 / config.plugins.shadowsocks.billing_bucket)
|
||||
|
||||
shadowsocks.accountUsage req.account, (result) ->
|
||||
_.extend result,
|
||||
transfer_remainder: account.billing.balance / config.plugins.shadowsocks.price_bucket / (1000 * 1000 * 1000 / config.plugins.shadowsocks.billing_bucket)
|
||||
transfer_remainder: req.account.billing.balance / price_gb
|
||||
|
||||
exports.render 'widget', req, result, callback
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{_, child_process, async, fs} = app.libs
|
||||
{logger, utils} = app
|
||||
{logger, utils, config} = app
|
||||
{Account, Financials} = app.models
|
||||
|
||||
supervisor = require '../supervisor/supervisor'
|
||||
@@ -113,7 +113,7 @@ exports.initAccount = (account, callback) ->
|
||||
callback()
|
||||
|
||||
exports.deleteAccount = (account, callback) ->
|
||||
queryIptablesInfo (iptables_info) ->
|
||||
exports.queryIptablesInfo (iptables_info) ->
|
||||
{port, method} = account.pluggable.shadowsocks
|
||||
|
||||
billing_traffic = iptables_info[port].bytes - account.pluggable.shadowsocks.last_traffic_value
|
||||
@@ -198,10 +198,10 @@ exports.updateConfigure = (account, callback) ->
|
||||
shadowsocks_config_file = "/etc/shadowsocks/#{method}.json"
|
||||
|
||||
fs.readFile shadowsocks_config_file, (err, content) ->
|
||||
config = JSON.parse content
|
||||
config.port_password[port] = password
|
||||
configure = JSON.parse content
|
||||
configure.port_password[port] = password
|
||||
|
||||
ShadowsocksPlugin.writeConfigFile shadowsocks_config_file, JSON.stringify(config), {mode: 0o755}, ->
|
||||
ShadowsocksPlugin.writeConfigFile shadowsocks_config_file, JSON.stringify(configure), {mode: 0o755}, ->
|
||||
callback()
|
||||
|
||||
(callback) ->
|
||||
@@ -227,14 +227,14 @@ exports.deleteAccountConfigure = (account, callback) ->
|
||||
shadowsocks_config_file = "/etc/shadowsocks/#{method}.json"
|
||||
|
||||
fs.readFile shadowsocks_config_file, (err, content) ->
|
||||
config = JSON.parse content
|
||||
delete config.port_password[port]
|
||||
configure = JSON.parse content
|
||||
delete configure.port_password[port]
|
||||
|
||||
fs.writeFile shadowsocks_config_file, JSON.stringify(config), ->
|
||||
fs.writeFile shadowsocks_config_file, JSON.stringify(configure), ->
|
||||
callback()
|
||||
|
||||
exports.monitoring = ->
|
||||
queryIptablesInfo (iptables_info) ->
|
||||
exports.queryIptablesInfo (iptables_info) ->
|
||||
async.each _.values(iptables_info), (item, callback) ->
|
||||
{port, bytes} = item
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
body {
|
||||
> header {
|
||||
background: #1c9b47;
|
||||
|
||||
nav.navbar-inverse {
|
||||
background: #1c9b47;
|
||||
}
|
||||
|
||||
.navbar-inverse {
|
||||
.navbar-nav > .active > a, .navbar-nav > .active > a:hover, .navbar-nav > .active > a:focus {
|
||||
background: #18813f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
#widget-shadowsocks {
|
||||
.widget-shadowsocks {
|
||||
.input-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
@@ -1,32 +1,33 @@
|
||||
header= t('')
|
||||
.col-md-6
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
h3.panel-title= t('remote_access')
|
||||
.panel-body
|
||||
.input-group
|
||||
span.input-group-addon= t('remote_port')
|
||||
p.form-control-static= account.pluggable.shadowsocks.port
|
||||
.input-group
|
||||
span.input-group-addon= t('account.password')
|
||||
p.form-control-static= account.pluggable.shadowsocks.password
|
||||
span.input-group-btn
|
||||
button.btn.btn-default.action-reset-password(type='button')= t('reset')
|
||||
.row.widget-shadowsocks
|
||||
header= t('')
|
||||
.col-md-6
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
h3.panel-title= t('remote_access')
|
||||
.panel-body
|
||||
.input-group
|
||||
span.input-group-addon= t('remote_port')
|
||||
input.form-control(type='text', value=account.pluggable.shadowsocks.port, disabled)
|
||||
.input-group
|
||||
span.input-group-addon= t('account.password')
|
||||
input.form-control(type='text', value=account.pluggable.shadowsocks.password, disabled)
|
||||
span.input-group-btn
|
||||
button.btn.btn-default.action-reset-password(type='button')= t('reset')
|
||||
|
||||
.col-md-6
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
h3.panel-title= t('transfer')
|
||||
.panel-body
|
||||
p= t('transfer_remainder', {traffic: transfer_remainder.toFixed(1)})
|
||||
table.table.table-hover
|
||||
tbody
|
||||
tr
|
||||
td #{(traffic_24hours / 1000).toFixed(1)}G
|
||||
td= t('24hours_ago')
|
||||
tr
|
||||
td #{(traffic_7days / 1000).toFixed(1)}G
|
||||
td= t('7days_ago')
|
||||
tr
|
||||
td #{(traffic_30days / 1000).toFixed(1)}G
|
||||
td= t('30days_ago')
|
||||
.col-md-6
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
h3.panel-title= t('transfer')
|
||||
.panel-body
|
||||
p= t('transfer_remainder', {traffic: transfer_remainder.toFixed(1)})
|
||||
table.table.table-hover
|
||||
tbody
|
||||
tr
|
||||
td #{(traffic_24hours / 1000).toFixed(1)}G
|
||||
td= t('24hours_ago')
|
||||
tr
|
||||
td #{(traffic_7days / 1000).toFixed(1)}G
|
||||
td= t('7days_ago')
|
||||
tr
|
||||
td #{(traffic_30days / 1000).toFixed(1)}G
|
||||
td= t('30days_ago')
|
||||
|
||||
@@ -32,6 +32,9 @@ exports.registerServiceHook 'disable',
|
||||
filter: (req, callback) ->
|
||||
supervisor.removePrograms req.account, ->
|
||||
supervisor.updateProgram req.account, null, ->
|
||||
callback()
|
||||
req.account.update
|
||||
$unset:
|
||||
'pluggable.supervisor': true
|
||||
, callback
|
||||
|
||||
app.express.use '/plugin/supervisor', require './router'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{fs, path} = app.libs
|
||||
{pluggable} = app
|
||||
{pluggable, config} = app
|
||||
|
||||
exports = module.exports = class WikiPlugin extends pluggable.Plugin
|
||||
@NAME: 'wiki'
|
||||
@@ -9,14 +9,15 @@ exports.registerHook 'view.layout.menu_bar',
|
||||
href: '/wiki/'
|
||||
t_body: 'plugins.wiki.'
|
||||
|
||||
wiki_path = "#{__dirname}/../../WIKI"
|
||||
unless config.plugins.wiki.disable_default_wiki
|
||||
wiki_path = "#{__dirname}/../../WIKI"
|
||||
|
||||
for category_name in fs.readdirSync(wiki_path)
|
||||
for file_name in fs.readdirSync("#{wiki_path}/#{category_name}")
|
||||
exports.registerHook 'plugin.wiki.pages',
|
||||
t_category: category_name
|
||||
t_title: file_name
|
||||
language: 'zh_CN'
|
||||
content_markdown: fs.readFileSync("#{wiki_path}/#{category_name}/#{file_name}").toString()
|
||||
for category_name in fs.readdirSync(wiki_path)
|
||||
for file_name in fs.readdirSync("#{wiki_path}/#{category_name}")
|
||||
exports.registerHook 'plugin.wiki.pages',
|
||||
t_category: category_name
|
||||
t_title: file_name
|
||||
language: 'zh_CN'
|
||||
content_markdown: fs.readFileSync("#{wiki_path}/#{category_name}/#{file_name}").toString()
|
||||
|
||||
app.express.use '/wiki', require './wiki'
|
||||
|
||||
@@ -62,15 +62,17 @@ module.exports =
|
||||
bitcoin:
|
||||
coinbase_api_key: 'coinbase-simple-api-key'
|
||||
|
||||
wiki:
|
||||
disable_default_wiki: true
|
||||
|
||||
rpvhost:
|
||||
index_page: false
|
||||
green_style: true
|
||||
taobao_item_id: '41040606505'
|
||||
|
||||
shadowsocks:
|
||||
green_style: true
|
||||
|
||||
available_ciphers: ['aes-256-cfb', 'rc4-md5']
|
||||
|
||||
billing_bucket: 100 * 1024 * 1024
|
||||
billing_bucket: 100 * 1000 * 1000
|
||||
monitor_cycle: 5 * 60 * 1000
|
||||
price_bucket: 0.06
|
||||
|
||||
Reference in New Issue
Block a user