mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
net/shadowsocks: add ss-local, split services (#528)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
PLUGIN_NAME= shadowsocks
|
||||
PLUGIN_VERSION= 0.1
|
||||
PLUGIN_VERSION= 0.2
|
||||
PLUGIN_COMMENT= Secure socks5 proxy
|
||||
PLUGIN_DEPENDS= shadowsocks-libev
|
||||
PLUGIN_MAINTAINER= m.muenz@gmail.com
|
||||
|
||||
@@ -45,5 +45,18 @@ function shadowsocks_services()
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($config['OPNsense']['shadowsocks']['local']['enabled']) && $config['OPNsense']['shadowsocks']['local']['enabled'] == 1) {
|
||||
$services[] = array(
|
||||
'description' => gettext('shadowsockslocal daemon'),
|
||||
'configd' => array(
|
||||
'restart' => array('shadowsockslocal restart'),
|
||||
'start' => array('shadowsockslocal start'),
|
||||
'stop' => array('shadowsockslocal stop'),
|
||||
),
|
||||
'name' => 'shadowsockslocal',
|
||||
'pidfile' => '/var/run/ss-local.pid'
|
||||
);
|
||||
}
|
||||
|
||||
return $services;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
# $FreeBSD$
|
||||
|
||||
# PROVIDE: ss-local
|
||||
# REQUIRE: LOGIN cleanvar
|
||||
# KEYWORD: shutdown
|
||||
|
||||
# Add the following lines to /etc/rc.conf to enable shadowsocks-libev:
|
||||
# ss_local_enable (bool): Set to "NO" by default.
|
||||
# Set to "YES" to enable ss-local.
|
||||
# ss_local_config (path): Shadowsocks config file.
|
||||
# Defaults to "/usr/local/etc/shadowsocks-libev/local.json"
|
||||
|
||||
|
||||
. /etc/rc.subr
|
||||
|
||||
name="ss_local"
|
||||
rcvar=ss_local_enable
|
||||
|
||||
|
||||
load_rc_config $name
|
||||
|
||||
: ${ss_local_enable:="NO"}
|
||||
: ${ss_local_config="/usr/local/etc/shadowsocks-libev/local.json"}
|
||||
|
||||
command="/usr/local/bin/ss-local"
|
||||
pidfile="/var/run/ss-local.pid"
|
||||
required_files="${ss_local_config}"
|
||||
|
||||
command_args="-f $pidfile -c $ss_local_config"
|
||||
|
||||
run_rc_command "$1"
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2018 Michael Muenz
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace OPNsense\Shadowsocks\Api;
|
||||
|
||||
use OPNsense\Base\ApiMutableModelControllerBase;
|
||||
|
||||
class LocalController extends ApiMutableModelControllerBase
|
||||
{
|
||||
static protected $internalModelClass = '\OPNsense\Shadowsocks\Local';
|
||||
static protected $internalModelName = 'local';
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2018 Michael Muenz
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace OPNsense\Shadowsocks\Api;
|
||||
|
||||
use OPNsense\Base\ApiMutableServiceControllerBase;
|
||||
|
||||
class LocalserviceController extends ApiMutableServiceControllerBase
|
||||
{
|
||||
static protected $internalServiceClass = '\OPNsense\Shadowsocks\Local';
|
||||
static protected $internalServiceTemplate = 'OPNsense/Shadowsocks';
|
||||
static protected $internalServiceEnabled = 'enabled';
|
||||
static protected $internalServiceName = 'shadowsockslocal';
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2018 Michael Muenz
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace OPNsense\Shadowsocks;
|
||||
|
||||
class LocalController extends \OPNsense\Base\IndexController
|
||||
{
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->localForm = $this->getForm("local");
|
||||
$this->view->pick('OPNsense/Shadowsocks/local');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>local.enabled</id>
|
||||
<label>Enable ShadowSocks Local</label>
|
||||
<type>checkbox</type>
|
||||
<help>This will activate the ShadowSocks Local instance. This lets you tunnel your application to a public ShadowSocks server.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>local.serveraddress</id>
|
||||
<label>Server Address</label>
|
||||
<type>text</type>
|
||||
<help>IP address or hostname of the remote ShadowSocks server.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>local.serverport</id>
|
||||
<label>Server Port</label>
|
||||
<type>text</type>
|
||||
<help>Port of the remote server.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>local.localport</id>
|
||||
<label>Local Port</label>
|
||||
<type>text</type>
|
||||
<help>The local port of the daemon, default is fine.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>local.password</id>
|
||||
<label>Password</label>
|
||||
<type>text</type>
|
||||
<help>Password to authenticate against the server.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>local.cipher</id>
|
||||
<label>Cipher</label>
|
||||
<type>dropdown</type>
|
||||
<help>Choose the cipher to use for encryption.</help>
|
||||
</field>
|
||||
</form>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Copyright (C) 2018 Michael Muenz
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
namespace OPNsense\Shadowsocks;
|
||||
|
||||
use OPNsense\Base\BaseModel;
|
||||
|
||||
class Local extends BaseModel
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
<model>
|
||||
<mount>//OPNsense/shadowsocks/local</mount>
|
||||
<description>Shadowsocks configuration</description>
|
||||
<version>1.0.0</version>
|
||||
<items>
|
||||
<enabled type="BooleanField">
|
||||
<default>0</default>
|
||||
<Required>Y</Required>
|
||||
</enabled>
|
||||
<serveraddress type="HostnameField">
|
||||
<default>127.0.0.1</default>
|
||||
<Required>Y</Required>
|
||||
<ValidationMessage>Please provide a valid hostname or IP address.</ValidationMessage>
|
||||
</serveraddress>
|
||||
<serverport type="IntegerField">
|
||||
<default>8388</default>
|
||||
<Required>Y</Required>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<MaximumValue>65535</MaximumValue>
|
||||
<ValidationMessage>Please provide a valid port number between 1 and 65535.</ValidationMessage>
|
||||
</serverport>
|
||||
<localport type="IntegerField">
|
||||
<default>1080</default>
|
||||
<Required>Y</Required>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<MaximumValue>65535</MaximumValue>
|
||||
<ValidationMessage>Please provide a valid port number between 1 and 65535.</ValidationMessage>
|
||||
</localport>
|
||||
<password type="TextField">
|
||||
<default>password</default>
|
||||
<Required>N</Required>
|
||||
</password>
|
||||
<cipher type="OptionField">
|
||||
<default>AES-256-CFB</default>
|
||||
<Required>Y</Required>
|
||||
<OptionValues>
|
||||
<aes-256-cfb>AES-256-CFB</aes-256-cfb>
|
||||
<aes-256-gcm>AES-256-GCM</aes-256-gcm>
|
||||
<aes-256-ctr>AES-256-CTR</aes-256-ctr>
|
||||
<aes-192-cfb>AES-192-CFB</aes-192-cfb>
|
||||
<aes-192-gcm>AES-192-GCM</aes-192-gcm>
|
||||
<aes-192-ctr>AES-192-CTR</aes-192-ctr>
|
||||
<aes-128-cfb>AES-128-CFB</aes-128-cfb>
|
||||
<aes-128-gcm>AES-128-GCM</aes-128-gcm>
|
||||
<aes-128-ctr>AES-128-CTR</aes-128-ctr>
|
||||
<chacha20-ietf-poly1305>ChaCha20-IETF-Poly1305</chacha20-ietf-poly1305>
|
||||
</OptionValues>
|
||||
</cipher>
|
||||
</items>
|
||||
</model>
|
||||
@@ -1,5 +1,8 @@
|
||||
<menu>
|
||||
<Services>
|
||||
<ShadowSocks cssClass="fa fa-eye-slash" url="/ui/shadowsocks/general/index" />
|
||||
<ShadowSocks cssClass="fa fa-eye-slash">
|
||||
<General url="/ui/shadowsocks/general/index" order="10"/>
|
||||
<Local url="/ui/shadowsocks/local/index" order="20"/>
|
||||
</ShadowSocks>
|
||||
</Services>
|
||||
</menu>
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
{#
|
||||
|
||||
OPNsense® is Copyright © 2014 – 2018 by Deciso B.V.
|
||||
This file is Copyright © 2018 by Michael Muenz
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#}
|
||||
<div class="content-box" style="padding-bottom: 1.5em;">
|
||||
{{ partial("layout_partials/base_form",['fields':localForm,'id':'frm_local_settings'])}}
|
||||
<div class="col-md-12">
|
||||
<hr />
|
||||
<button class="btn btn-primary" id="saveAct" type="button"><b>{{ lang._('Save') }}</b> <i id="saveAct_progress"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
var data_get_map = {'frm_local_settings':"/api/shadowsocks/local/get"};
|
||||
mapDataToFormUI(data_get_map).done(function(data){
|
||||
formatTokenizersUI();
|
||||
$('.selectpicker').selectpicker('refresh');
|
||||
});
|
||||
ajaxCall(url="/api/shadowsocks/localservice/status", sendData={}, callback=function(data,status) {
|
||||
updateServiceStatusUI(data['status']);
|
||||
});
|
||||
|
||||
// link save button to API set action
|
||||
$("#saveAct").click(function(){
|
||||
saveFormToEndpoint(url="/api/shadowsocks/local/set", formid='frm_local_settings',callback_ok=function(){
|
||||
$("#saveAct_progress").addClass("fa fa-spinner fa-pulse");
|
||||
ajaxCall(url="/api/shadowsocks/localservice/reconfigure", sendData={}, callback=function(data,status) {
|
||||
ajaxCall(url="/api/shadowsocks/localservice/status", sendData={}, callback=function(data,status) {
|
||||
updateServiceStatusUI(data['status']);
|
||||
});
|
||||
$("#saveAct_progress").removeClass("fa fa-spinner fa-pulse");
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -21,3 +21,27 @@ command:/usr/local/etc/rc.d/shadowsocks_libev status;exit 0
|
||||
parameters:
|
||||
type:script_output
|
||||
message:request Shadowsocks status
|
||||
|
||||
[start-local]
|
||||
command:/usr/local/etc/rc.d/opnsense-ss-local start
|
||||
parameters:
|
||||
type:script
|
||||
message:starting Shadowsocks Local
|
||||
|
||||
[stop-local]
|
||||
command:/usr/local/etc/rc.d/opnsense-ss-local stop
|
||||
parameters:
|
||||
type:script
|
||||
message:stopping Shadowsocks Local
|
||||
|
||||
[restart-local]
|
||||
command:/usr/local/etc/rc.d/opnsense-ss-local restart
|
||||
parameters:
|
||||
type:script
|
||||
message:restarting Shadowsocks Local
|
||||
|
||||
[status-local]
|
||||
command:/usr/local/etc/rc.d/opnsense-ss-local status;exit 0
|
||||
parameters:
|
||||
type:script_output
|
||||
message:request Shadowsocks Local status
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
[start]
|
||||
command:/usr/local/etc/rc.d/opnsense-ss-local start
|
||||
parameters:
|
||||
type:script
|
||||
message:starting Shadowsocks Local
|
||||
|
||||
[stop]
|
||||
command:/usr/local/etc/rc.d/opnsense-ss-local stop
|
||||
parameters:
|
||||
type:script
|
||||
message:stopping Shadowsocks Local
|
||||
|
||||
[restart]
|
||||
command:/usr/local/etc/rc.d/opnsense-ss-local restart
|
||||
parameters:
|
||||
type:script
|
||||
message:restarting Shadowsocks Local
|
||||
|
||||
[status]
|
||||
command:/usr/local/etc/rc.d/opnsense-ss-local status;exit 0
|
||||
parameters:
|
||||
type:script_output
|
||||
message:request Shadowsocks Local status
|
||||
@@ -1,2 +1,4 @@
|
||||
shadowsocks_libev:/etc/rc.conf.d/shadowsocks_libev
|
||||
shadowsocks.conf:/usr/local/etc/shadowsocks-libev/config.json
|
||||
ss_local:/etc/rc.conf.d/ss_local
|
||||
ss_local.conf:/usr/local/etc/shadowsocks-libev/local.json
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{% if helpers.exists('OPNsense.shadowsocks.local.enabled') and OPNsense.shadowsocks.local.enabled == '1' %}
|
||||
ss_local_enable="YES"
|
||||
ss_local_flags=""
|
||||
{% else %}
|
||||
ss_local_enable="NO"
|
||||
{% endif %}
|
||||
@@ -0,0 +1,10 @@
|
||||
{% if helpers.exists('OPNsense.shadowsocks.local.enabled') and OPNsense.shadowsocks.local.enabled == '1' %}
|
||||
{
|
||||
"server":"{{ OPNsense.shadowsocks.local.serveraddress }}",
|
||||
"server_port":{{ OPNsense.shadowsocks.local.serverport }},
|
||||
"local_port":{{ OPNsense.shadowsocks.local.localport }},
|
||||
"password":"{{ OPNsense.shadowsocks.local.password }}",
|
||||
"timeout":60,
|
||||
"method":"{{ OPNsense.shadowsocks.local.cipher }}"
|
||||
}
|
||||
{% endif %}
|
||||
Reference in New Issue
Block a user