From 2e741239b9dceda0fd8a2aba28c9742a009383a4 Mon Sep 17 00:00:00 2001 From: LEAN-ESX Date: Fri, 25 Oct 2019 07:49:47 -0700 Subject: [PATCH] luci-app-softethervpn: add package --- package/lean/luci-app-softethervpn/Makefile | 18 ++++++++ .../luasrc/controller/softethervpn.lua | 18 ++++++++ .../luasrc/model/cbi/softethervpn.lua | 14 ++++++ .../luasrc/view/softethervpn/index.htm | 18 ++++++++ .../luasrc/view/softethervpn/status.htm | 3 ++ .../po/zh-cn/softethervpn.po | 23 ++++++++++ .../root/etc/config/softethervpn | 4 ++ .../root/etc/init.d/softethervpn | 45 +++++++++++++++++++ .../etc/uci-defaults/luci-app-softethervpn | 25 +++++++++++ .../usr/share/softethervpn/firewall.include | 22 +++++++++ 10 files changed, 190 insertions(+) create mode 100644 package/lean/luci-app-softethervpn/Makefile create mode 100644 package/lean/luci-app-softethervpn/luasrc/controller/softethervpn.lua create mode 100644 package/lean/luci-app-softethervpn/luasrc/model/cbi/softethervpn.lua create mode 100644 package/lean/luci-app-softethervpn/luasrc/view/softethervpn/index.htm create mode 100644 package/lean/luci-app-softethervpn/luasrc/view/softethervpn/status.htm create mode 100644 package/lean/luci-app-softethervpn/po/zh-cn/softethervpn.po create mode 100644 package/lean/luci-app-softethervpn/root/etc/config/softethervpn create mode 100755 package/lean/luci-app-softethervpn/root/etc/init.d/softethervpn create mode 100755 package/lean/luci-app-softethervpn/root/etc/uci-defaults/luci-app-softethervpn create mode 100755 package/lean/luci-app-softethervpn/root/usr/share/softethervpn/firewall.include diff --git a/package/lean/luci-app-softethervpn/Makefile b/package/lean/luci-app-softethervpn/Makefile new file mode 100644 index 000000000..12f9c4a65 --- /dev/null +++ b/package/lean/luci-app-softethervpn/Makefile @@ -0,0 +1,18 @@ +# Copyright (C) 2018-2019 Lienol +# +# This is free software, licensed under the Apache License, Version 2.0 . +# + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=LuCI support for SoftEtherVPN +LUCI_DEPENDS:=+zlib +libpthread +librt +libreadline +libncurses +libiconv-full +kmod-tun +libopenssl +softethervpn-bridge +softethervpn-client +softethervpn-server +LUCI_PKGARCH:=all +PKG_VERSION:=1.0 +PKG_RELEASE:=2 + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature + + diff --git a/package/lean/luci-app-softethervpn/luasrc/controller/softethervpn.lua b/package/lean/luci-app-softethervpn/luasrc/controller/softethervpn.lua new file mode 100644 index 000000000..d4ec9bc88 --- /dev/null +++ b/package/lean/luci-app-softethervpn/luasrc/controller/softethervpn.lua @@ -0,0 +1,18 @@ +module("luci.controller.softethervpn",package.seeall) + +function index() + if not nixio.fs.access("/etc/config/softethervpn")then + return + end + + entry({"admin","vpn"}, firstchild(), "VPN", 45).dependent = false + entry({"admin","vpn","softethervpn"},cbi("softethervpn"),_("SoftEther VPN"),50).dependent=true + entry({"admin","vpn","softethervpn","status"},call("status")).leaf=true +end + +function status() + local e={} + e.status=luci.sys.call("pidof %s >/dev/null"%"vpnserver")==0 + luci.http.prepare_content("application/json") + luci.http.write_json(e) +end diff --git a/package/lean/luci-app-softethervpn/luasrc/model/cbi/softethervpn.lua b/package/lean/luci-app-softethervpn/luasrc/model/cbi/softethervpn.lua new file mode 100644 index 000000000..1c0054c29 --- /dev/null +++ b/package/lean/luci-app-softethervpn/luasrc/model/cbi/softethervpn.lua @@ -0,0 +1,14 @@ +local s=require"luci.sys" +local m,s,o +m=Map("softethervpn",translate("SoftEther VPN")) +m.description = translate("SoftEther VPN is an open source, cross-platform, multi-protocol virtual private network solution developed by university of tsukuba graduate student Daiyuu Nobori for master's thesis.
can easily set up OpenVPN, IPsec, L2TP, ms-sstp, L2TPv3 and EtherIP servers on the router using the console.") +m.template="softethervpn/index" +s=m:section(TypedSection,"softether") +s.anonymous=true +o=s:option(DummyValue,"softethervpn_status",translate("Current Condition")) +o.template="softethervpn/status" +o.value=translate("Collecting data...") +o=s:option(Flag,"enable",translate("Enabled")) +o.rmempty=false +o=s:option(DummyValue,"moreinfo",translate("控制台下载:
Windows-x86_x64-intel.exe

macos-x86-32bit.pkg
")) +return m diff --git a/package/lean/luci-app-softethervpn/luasrc/view/softethervpn/index.htm b/package/lean/luci-app-softethervpn/luasrc/view/softethervpn/index.htm new file mode 100644 index 000000000..273f604ea --- /dev/null +++ b/package/lean/luci-app-softethervpn/luasrc/view/softethervpn/index.htm @@ -0,0 +1,18 @@ +<%# + Copyright (C) 2018-2019 Lienol + Licensed to the public under the Apache License 2.0. +-%> + +<% include("cbi/map") %> + diff --git a/package/lean/luci-app-softethervpn/luasrc/view/softethervpn/status.htm b/package/lean/luci-app-softethervpn/luasrc/view/softethervpn/status.htm new file mode 100644 index 000000000..055b112ec --- /dev/null +++ b/package/lean/luci-app-softethervpn/luasrc/view/softethervpn/status.htm @@ -0,0 +1,3 @@ +<%+cbi/valueheader%> +<%=pcdata(self:cfgvalue(section) or self.default or "")%> +<%+cbi/valuefooter%> diff --git a/package/lean/luci-app-softethervpn/po/zh-cn/softethervpn.po b/package/lean/luci-app-softethervpn/po/zh-cn/softethervpn.po new file mode 100644 index 000000000..8d17b1507 --- /dev/null +++ b/package/lean/luci-app-softethervpn/po/zh-cn/softethervpn.po @@ -0,0 +1,23 @@ +msgid "SoftEther VPN" +msgstr "SoftEther VPN 服务器" + +msgid "SoftEther VPN is an open source, cross-platform, multi-protocol virtual private network solution developed by university of tsukuba graduate student Daiyuu Nobori for master's thesis.
can easily set up OpenVPN, IPsec, L2TP, ms-sstp, L2TPv3 and EtherIP servers on the router using the console." +msgstr "SoftEther VPN是由筑波大学研究生Daiyuu Nobori因硕士论文开发的开源,跨平台,多重协定的虚拟私人网路方案。
使用控制台可以轻松在路由器上搭建OpenVPN, IPsec, L2TP, MS-SSTP, L2TPv3 和 EtherIP服务器。" + +msgid "PPTP VPN Server status" +msgstr "PPTP VPN 服务器运行状态" + +msgid "Current Condition" +msgstr "当前状态" + +msgid "Enabled" +msgstr "启用" + +msgid "Open L2TP/IPSec firewall" +msgstr "开启L2TP/IPSec防火墙" + +msgid "Open the MS-SSTP firewall" +msgstr "开启MS-SSTP防火墙" + +msgid "Open the OpenVPN firewall" +msgstr "开启OpenVPN防火墙" \ No newline at end of file diff --git a/package/lean/luci-app-softethervpn/root/etc/config/softethervpn b/package/lean/luci-app-softethervpn/root/etc/config/softethervpn new file mode 100644 index 000000000..90732c533 --- /dev/null +++ b/package/lean/luci-app-softethervpn/root/etc/config/softethervpn @@ -0,0 +1,4 @@ + +config softether + option enable '0' + diff --git a/package/lean/luci-app-softethervpn/root/etc/init.d/softethervpn b/package/lean/luci-app-softethervpn/root/etc/init.d/softethervpn new file mode 100755 index 000000000..d724d5b8c --- /dev/null +++ b/package/lean/luci-app-softethervpn/root/etc/init.d/softethervpn @@ -0,0 +1,45 @@ +#!/bin/sh /etc/rc.common +# +# Copyright (C) 2015 OpenWrt-dist +# Copyright (C) 2016 Chen RuiWei +# Copyright (C) 2018-2019 Lienol +# +# This is free software, licensed under the GNU General Public License v3. +# See /LICENSE for more information. +# + +START=99 +STOP=10 + +CONFIG=softethervpn + +get_config() +{ + config_get_bool enable $1 enable 0 +} + +uci_get_by_type() { + local index=0 + if [ -n $4 ]; then + index=$4 + fi + local ret=$(uci get $CONFIG.@$1[$index].$2 2>/dev/null) + echo ${ret:=$3} +} + +start() +{ + config_load softethervpn + config_foreach get_config softether + [ $enable -ne 1 ] && exit 0 + logger -t 'softethervpn' "Starting softether vpnserver service." + /usr/bin/env LANG=en_US.UTF-8 /usr/libexec/softethervpn/vpnserver start > /dev/null 2>&1 + fw3 reload +} + +stop() +{ + logger -t 'softethervpn' "Stopping softether vpnserver service." + /usr/bin/env LANG=en_US.UTF-8 /usr/libexec/softethervpn/vpnserver stop > /dev/null 2>&1 + fw3 reload +} diff --git a/package/lean/luci-app-softethervpn/root/etc/uci-defaults/luci-app-softethervpn b/package/lean/luci-app-softethervpn/root/etc/uci-defaults/luci-app-softethervpn new file mode 100755 index 000000000..1f6e2bdf4 --- /dev/null +++ b/package/lean/luci-app-softethervpn/root/etc/uci-defaults/luci-app-softethervpn @@ -0,0 +1,25 @@ +#!/bin/sh + +uci -q batch <<-EOF >/dev/null + delete firewall.softethervpn + set firewall.softethervpn=include + set firewall.softethervpn.type=script + set firewall.softethervpn.path=/usr/share/softethervpn/firewall.include + set firewall.softethervpn.reload=1 +EOF + +uci -q batch <<-EOF >/dev/null + delete ucitrack.@softethervpn[-1] + add ucitrack softethervpn + set ucitrack.@softethervpn[-1].init=softethervpn + commit ucitrack +EOF + +/etc/init.d/softethervpnbridge disable && /etc/init.d/softethervpnbridge stop +/etc/init.d/softethervpnclient disable && /etc/init.d/softethervpnclient stop +/etc/init.d/softethervpnserver disable && /etc/init.d/softethervpnserver stop + +chmod a+x /usr/share/softethervpn/* >/dev/null 2>&1 + +rm -f /tmp/luci-indexcache +exit 0 diff --git a/package/lean/luci-app-softethervpn/root/usr/share/softethervpn/firewall.include b/package/lean/luci-app-softethervpn/root/usr/share/softethervpn/firewall.include new file mode 100755 index 000000000..3c2fd6dfe --- /dev/null +++ b/package/lean/luci-app-softethervpn/root/usr/share/softethervpn/firewall.include @@ -0,0 +1,22 @@ +#!/bin/sh + +openvpnport=$(cat /usr/libexec/softethervpn/vpn_server.config 2>/dev/null|grep OpenVPN_UdpPortList | awk -F " " '{print $3}') +[ -z "$openvpnport" ] && openvpnport=1194 +iptables -D INPUT -p udp -m multiport --dports 500,1701,4500 -m comment --comment "Rule For SoftEther VPN Server" -j ACCEPT 2>/dev/null +[ -n "$openvpnport" ] && iptables -D INPUT -p udp --dport $openvpnport -m comment --comment "Rule For SoftEther VPN Server" -j ACCEPT 2>/dev/null +[ -n "$openvpnport" ] && iptables -D INPUT -p tcp --dport $openvpnport -m comment --comment "Rule For SoftEther VPN Server" -j ACCEPT 2>/dev/null +iptables -D INPUT -p tcp --dport 443 -m comment --comment "Rule For SoftEther VPN Server" -j ACCEPT 2>/dev/null +iptables -D INPUT -p tcp --dport 5555 -m comment --comment "Rule For SoftEther VPN Server" -j ACCEPT 2>/dev/null +iptables -D INPUT -p tcp --dport 8888 -m comment --comment "Rule For SoftEther VPN Server" -j ACCEPT 2>/dev/null +iptables -D INPUT -p tcp --dport 992 -m comment --comment "Rule For SoftEther VPN Server" -j ACCEPT 2>/dev/null + +enable=$(uci get softethervpn.@softether[0].enable) +if [ $enable -eq 1 ]; then + iptables -I INPUT -p udp -m multiport --dports 500,1701,4500 -m comment --comment "Rule For SoftEther VPN Server" -j ACCEPT 2>/dev/null + iptables -I INPUT -p udp --dport $openvpnport -m comment --comment "Rule For SoftEther VPN Server" -j ACCEPT + iptables -I INPUT -p tcp --dport $openvpnport -m comment --comment "Rule For SoftEther VPN Server" -j ACCEPT + iptables -I INPUT -p tcp --dport 443 -m comment --comment "Rule For SoftEther VPN Server" -j ACCEPT + iptables -I INPUT -p tcp --dport 5555 -m comment --comment "Rule For SoftEther VPN Server" -j ACCEPT + iptables -I INPUT -p tcp --dport 8888 -m comment --comment "Rule For SoftEther VPN Server" -j ACCEPT + iptables -I INPUT -p tcp --dport 992 -m comment --comment "Rule For SoftEther VPN Server" -j ACCEPT +fi