mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-01 04:13:56 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
97c049ed0a
commit
0acff03804
14253 files changed
+3893239
No files matched your search
@@ -0,0 +1,16 @@
|
||||
#
|
||||
# Copyright (C) 2008-2014 The LuCI Team <luci@lists.subsignal.org>
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI page for PPTP VPN Server
|
||||
LUCI_DEPENDS:=+pptpd +kmod-mppe +ipset
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
添加如下代码到/feeds/luci.index
|
||||
|
||||
|
||||
Source-Makefile: feeds/luci/applications/luci-app-pptpd/Makefile
|
||||
Package: luci-app-pptpd
|
||||
Submenu: 3. Applications
|
||||
Version: x-1
|
||||
Depends: +libc +SSP_SUPPORT:libssp +USE_GLIBC:librt +USE_GLIBC:libpthread +pptpd +kmod-mppe +ipset
|
||||
Conflicts:
|
||||
Menu-Depends:
|
||||
Provides:
|
||||
Build-Depends: lua/host luci-base/host
|
||||
Section: luci
|
||||
Category: LuCI
|
||||
Title: LuCI page for PPTP VPN Server
|
||||
Maintainer:
|
||||
Source:
|
||||
Type: ipkg
|
||||
Description: LuCI page for PPTP VPN Server
|
||||
|
||||
@@
|
||||
@@ -0,0 +1,38 @@
|
||||
--[[
|
||||
LuCI - Lua Configuration Interface
|
||||
|
||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
Copyright 2014 HackPascal <hackpascal@gmail.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
$Id$
|
||||
]]--
|
||||
|
||||
module("luci.controller.pptpd", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/pptpd") then
|
||||
return
|
||||
end
|
||||
|
||||
entry({"admin", "services", "pptpd"},
|
||||
alias("admin", "services", "pptpd", "settings"),
|
||||
_("VPN Server"), 60)
|
||||
|
||||
entry({"admin", "services", "pptpd", "settings"},
|
||||
cbi("pptpd/settings"),
|
||||
_("General Settings"), 10).leaf = true
|
||||
|
||||
entry({"admin", "services", "pptpd", "users"},
|
||||
cbi("pptpd/users"),
|
||||
_("Users Manager"), 20).leaf = true
|
||||
|
||||
entry({"admin", "services", "pptpd", "online"},
|
||||
cbi("pptpd/online"),
|
||||
_("Online Users"), 30).leaf = true
|
||||
end
|
||||
@@ -0,0 +1,100 @@
|
||||
--[[
|
||||
LuCI - Lua Configuration Interface
|
||||
|
||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
Copyright 2014 HackPascal <hackpascal@gmail.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
$Id$
|
||||
]]--
|
||||
|
||||
local data = {}
|
||||
local ds = require "luci.dispatcher"
|
||||
local ps = luci.util.execi("/bin/busybox top -bn1 | grep '/usr/sbin/pppd'")
|
||||
for line in ps do
|
||||
local pid, ppid, speed, gateway, vip, cip = line:match(
|
||||
"^ *(%d+) +(%d+) +.+options%.pptpd +(%d+) +(%S.-%S)%:(%S.-%S) +.+ +(.+)"
|
||||
)
|
||||
|
||||
local idx = tonumber(pid)
|
||||
if idx then
|
||||
data["%02i.%s" % { idx, "online" }] = {
|
||||
['PID'] = pid,
|
||||
['PPID'] = ppid,
|
||||
['SPEED'] = speed,
|
||||
['GATEWAY'] = gateway,
|
||||
['VIP'] = vip,
|
||||
['CIP'] = cip,
|
||||
['BLACKLIST'] = 0
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
-- local ps = luci.util.execi("sed -n '/## pptpd-blacklist-/p' /etc/firewall.user")
|
||||
local ps = luci.util.execi("sed = /etc/firewall.user | sed 'N;s/\\n/:/'")
|
||||
for line in ps do
|
||||
local idx, ip = line:match(
|
||||
"^ *(%d+)%:.+%#%# pptpd%-blacklist%-(.+)"
|
||||
)
|
||||
|
||||
local idx = tonumber(idx)
|
||||
if idx then
|
||||
data["%02i.%s" % { idx, "blacklist" }] = {
|
||||
['PID'] = "-1",
|
||||
['PPID'] = "-1",
|
||||
['SPEED'] = "-1",
|
||||
['GATEWAY'] = "-",
|
||||
['VIP'] = "-",
|
||||
['CIP'] = ip,
|
||||
['BLACKLIST'] = 1
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
f = SimpleForm("processes")
|
||||
f.reset = false
|
||||
f.submit = false
|
||||
|
||||
t = f:section(Table, data, translate("Online Users"))
|
||||
t:option(DummyValue, "GATEWAY", translate("Server IP"))
|
||||
t:option(DummyValue, "VIP", translate("Client IP"))
|
||||
t:option(DummyValue, "CIP", translate("IP address"))
|
||||
|
||||
blacklist = t:option(Button, "_blacklist", translate("Blacklist"))
|
||||
function blacklist.render(self, section, scope)
|
||||
if self.map:get(section, "BLACKLIST")==0 then
|
||||
self.title = translate("Add to Blacklist")
|
||||
self.inputstyle = "remove"
|
||||
else
|
||||
self.title = translate("Remove from Blacklist")
|
||||
self.inputstyle = "apply"
|
||||
end
|
||||
|
||||
Button.render(self, section, scope)
|
||||
end
|
||||
function blacklist.write(self, section)
|
||||
local CIP = self.map:get(section, "CIP")
|
||||
if self.map:get(section, "BLACKLIST")==0 then
|
||||
luci.util.execi("echo 'iptables -A input_rule -s %s -p tcp --dport 1723 -j DROP ## pptpd-blacklist-%s' >> /etc/firewall.user" % { CIP, CIP })
|
||||
luci.util.execi("iptables -A input_rule -s %s -p tcp --dport 1723 -j DROP" % { CIP })
|
||||
null, self.tag_error[section] = luci.sys.process.signal(self.map:get(section, "PID"), 9)
|
||||
else
|
||||
luci.util.execi("sed -i -e '/## pptpd-blacklist-%s/d' /etc/firewall.user" % { CIP })
|
||||
luci.util.execi("iptables -D input_rule -s %s -p tcp --dport 1723 -j DROP" % { CIP })
|
||||
end
|
||||
luci.http.redirect(ds.build_url("admin/services/pptpd/online"))
|
||||
end
|
||||
|
||||
kill = t:option(Button, "_kill", translate("Forced offline"))
|
||||
kill.inputstyle = "reset"
|
||||
function kill.write(self, section)
|
||||
null, self.tag_error[section] = luci.sys.process.signal(self.map:get(section, "PID"), 9)
|
||||
luci.http.redirect(ds.build_url("admin/services/pptpd/online"))
|
||||
end
|
||||
|
||||
return f
|
||||
@@ -0,0 +1,63 @@
|
||||
--[[
|
||||
LuCI - Lua Configuration Interface
|
||||
|
||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
Copyright 2014 HackPascal <hackpascal@gmail.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
$Id$
|
||||
]]--
|
||||
|
||||
m = Map("pptpd")
|
||||
|
||||
s = m:section(TypedSection, "service", translate("General settings"))
|
||||
s.anonymous = true
|
||||
|
||||
o = s:option(Flag, "enabled", translate("Enable VPN Server"))
|
||||
o.rmempty = false
|
||||
function o.write(self, section, value)
|
||||
if value == "1" then
|
||||
luci.sys.init.enable("pptpd")
|
||||
luci.sys.call("/etc/init.d/pptpd start >/dev/null")
|
||||
else
|
||||
luci.sys.call("/etc/init.d/pptpd stop >/dev/null")
|
||||
luci.sys.init.disable("pptpd")
|
||||
end
|
||||
return Flag.write(self, section, value)
|
||||
end
|
||||
|
||||
o = s:option(Value, "localip", translate("Server IP"), translate("VPN Server IP address, it not required."))
|
||||
o.datatype = "ipaddr"
|
||||
o.placeholder = translate("10.0.0.1")
|
||||
o.rmempty = true
|
||||
o.default = ""
|
||||
|
||||
o = s:option(Value, "remoteip", translate("Client IP"), translate("VPN Client IP address, it not required."))
|
||||
o.placeholder = translate("10.0.0.2-254")
|
||||
o.rmempty = true
|
||||
o.default = ""
|
||||
|
||||
o = s:option(DynamicList, "dns", translate("DNS IP address"), translate("This will be sent to the client, it not required."))
|
||||
o.placeholder = translate("8.8.8.8")
|
||||
o.datatype = "ipaddr"
|
||||
--[[
|
||||
function o.write(self, section, value)
|
||||
luci.sys.call("echo xiaopiao $value >> /tmp/xiaopiao")
|
||||
end
|
||||
]]--
|
||||
|
||||
o = s:option(Flag, "mppe", translate("Enable MPPE Encryption"), translate("Allows 128-bit encrypted connection."))
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Flag, "nat", translate("Enable NAT Forward"), translate("Allows forwarding traffic."))
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Flag, "internet", translate("Enable remote service"), translate("Allows remote computers on the Internet to connect to VPN Server."))
|
||||
o.rmempty = false
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,49 @@
|
||||
--[[
|
||||
LuCI - Lua Configuration Interface
|
||||
|
||||
Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
Copyright 2014 HackPascal <hackpascal@gmail.com>
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
$Id$
|
||||
]]--
|
||||
|
||||
m = Map("pptpd")
|
||||
|
||||
s = m:section(TypedSection, "login", translate("Users Manager"))
|
||||
s.addremove = true
|
||||
s.anonymous = true
|
||||
s.template = "cbi/tblsection"
|
||||
|
||||
o = s:option(Flag, "enabled", translate("Enabled"))
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Value, "username", translate("User name"))
|
||||
o.placeholder = translate("User name")
|
||||
o.rmempty = true
|
||||
|
||||
o = s:option(Value, "password", translate("Password"))
|
||||
o.password = true
|
||||
o.rmempty = true
|
||||
|
||||
-- DummyValue
|
||||
o = s:option(Value, "ipaddress", translate("IP address"))
|
||||
o.placeholder = translate("Automatically")
|
||||
o.datatype = "ipaddr"
|
||||
-- o.value = translate("Automatically (No support)")
|
||||
o.rmempty = true
|
||||
function o.cfgvalue(self, section)
|
||||
value = self.map:get(section, "ipaddress")
|
||||
return value=="*" and "" or value
|
||||
end
|
||||
function o.remove(self, section)
|
||||
Value.write(self, section, "*")
|
||||
--luci.sys.call("/etc/init.d/pptpd restart >/dev/null")
|
||||
end
|
||||
|
||||
return m
|
||||
@@ -0,0 +1,87 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"PO-Revision-Date: 2015-05-13\n"
|
||||
"Last-Translator: ming1054<ming1054@163.com>\n"
|
||||
"Language-Team: none\n"
|
||||
"Language: zh_CN\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=1; plural=0;\n"
|
||||
"X-Generator: Pootle 2.0.6\n"
|
||||
|
||||
msgid "Users Manager"
|
||||
msgstr "用户管理"
|
||||
|
||||
msgid "Enabled"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "User name"
|
||||
msgstr "用户名"
|
||||
|
||||
msgid "Password"
|
||||
msgstr "密码"
|
||||
|
||||
msgid "IP address"
|
||||
msgstr "IP 地址"
|
||||
|
||||
msgid "Automatically"
|
||||
msgstr "自动分配"
|
||||
|
||||
msgid "General settings"
|
||||
msgstr "基本设置"
|
||||
|
||||
msgid "Enable VPN Server"
|
||||
msgstr "启用 VPN 服务器"
|
||||
|
||||
msgid "Server IP"
|
||||
msgstr "服务器 IP 地址"
|
||||
|
||||
msgid "VPN Server IP address, it not required."
|
||||
msgstr "VPN 服务器远程地址,留空将自动设置。"
|
||||
|
||||
msgid "Client IP"
|
||||
msgstr "客户端 IP 地址"
|
||||
|
||||
msgid "VPN Client IP address, it not required."
|
||||
msgstr "分配给客户端的 IP 地址范围,留空将自动设置。"
|
||||
|
||||
msgid "DNS IP address"
|
||||
msgstr "DNS IP 地址"
|
||||
|
||||
msgid "This will be sent to the client, it not required."
|
||||
msgstr "设置 VPN 服务器默认 DNS 服务器,该设置非必须。"
|
||||
|
||||
msgid "Enable MPPE Encryption"
|
||||
msgstr "启用MPPE 加密"
|
||||
|
||||
msgid "Allows 128-bit encrypted connection."
|
||||
msgstr "允许使用 128 位加密连接。"
|
||||
|
||||
msgid "Enable NAT Forward"
|
||||
msgstr "启用 NAT 转发"
|
||||
|
||||
msgid "Allows forwarding traffic."
|
||||
msgstr "允许转发流量"
|
||||
|
||||
msgid "Enable remote service"
|
||||
msgstr "启用远程服务"
|
||||
|
||||
msgid "Allows remote computers on the Internet to connect to VPN Server."
|
||||
msgstr "允许远程计算机通过互联网连接到此 VPN 服务器。"
|
||||
|
||||
msgid "Online Users"
|
||||
msgstr "在线用户"
|
||||
|
||||
msgid "Blacklist"
|
||||
msgstr "黑名单"
|
||||
|
||||
msgid "Add to Blacklist"
|
||||
msgstr "加入黑名单"
|
||||
|
||||
msgid "Remove from Blacklist"
|
||||
msgstr "从黑名单中移除"
|
||||
|
||||
msgid "Forced offline"
|
||||
msgstr "强制下线"
|
||||
Symlink
+1
@@ -0,0 +1 @@
|
||||
zh-cn
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
config service 'pptpd'
|
||||
option localip '10.0.0.1'
|
||||
option remoteip '10.0.0.2-254'
|
||||
option nat '1'
|
||||
option internet '1'
|
||||
list dns '114.114.114.114'
|
||||
option mppe '1'
|
||||
option enabled '0'
|
||||
|
||||
config login
|
||||
option enabled '1'
|
||||
option ipaddress '*'
|
||||
option username 'username'
|
||||
option password 'password'
|
||||
|
||||
Executable
+102
@@ -0,0 +1,102 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
|
||||
START=60
|
||||
BIN=/usr/sbin/pptpd
|
||||
DEFAULT=/etc/default/$BIN
|
||||
RUN_D=/var/run
|
||||
PID_F=$RUN_D/$BIN.pid
|
||||
CONFIG=/var/etc/pptpd.conf
|
||||
CHAP_SECRETS=/var/etc/chap-secrets
|
||||
|
||||
setup_dns() {
|
||||
[ -n "$1" ] || return 0
|
||||
echo ms-dns $1>>/etc/ppp/options.pptpd
|
||||
}
|
||||
setup_login() {
|
||||
local section="$1"
|
||||
|
||||
## Code by VPN Server ##
|
||||
config_get enabled "$section" enabled
|
||||
[ "$enabled" -eq 0 ] && return 0
|
||||
|
||||
config_get ipaddress "$section" ipaddress
|
||||
[ -n "$ipaddress" ] || local ipaddress = "*"
|
||||
## Code by VPN Server ##
|
||||
|
||||
config_get username "$section" username
|
||||
config_get password "$section" password
|
||||
[ -n "$username" ] || return 0
|
||||
[ -n "$password" ] || return 0
|
||||
|
||||
echo "$username * $password $ipaddress" >> $CHAP_SECRETS
|
||||
## echo "$username pptp-server $password *" >> $CHAP_SECRETS
|
||||
}
|
||||
|
||||
setup_config() {
|
||||
local section="$1"
|
||||
|
||||
config_get enabled "$section" enabled
|
||||
[ "$enabled" -eq 0 ] && return 1
|
||||
|
||||
mkdir -p /var/etc
|
||||
cp /etc/pptpd.conf $CONFIG
|
||||
|
||||
config_get localip "$section" localip
|
||||
config_get remoteip "$section" remoteip
|
||||
[ -n "$localip" ] && echo "localip $localip" >> $CONFIG
|
||||
[ -n "$remoteip" ] && echo "remoteip $remoteip" >> $CONFIG
|
||||
|
||||
## Code by VPN Server ##
|
||||
config_get nat "$section" nat
|
||||
config_get internet "$section" internet
|
||||
echo Update firewall ...
|
||||
sed -i -e "/## luci-app-pptpd/d" /etc/firewall.user
|
||||
if [ "$nat" -eq 1 ]; then
|
||||
echo "iptables -A forwarding_rule -s ${localip%.*}.0/24 -j ACCEPT ## luci-app-pptpd" >> /etc/firewall.user
|
||||
echo Update NAT rule ...
|
||||
fi
|
||||
if [ "$internet" -eq 1 ]; then
|
||||
echo "iptables -A input_rule -i ppp+ -p tcp -m tcp --dport 1723 -j ACCEPT ## luci-app-pptpd" >> /etc/firewall.user
|
||||
echo "iptables -A input_rule -i ppp+ -p gre -j ACCEPT ## luci-app-pptpd" >> /etc/firewall.user
|
||||
echo Update input rule ...
|
||||
fi
|
||||
fw3 restart
|
||||
config_get mppe "$section" mppe
|
||||
sed -i -e 's/#*mppe/mppe/g' /etc/ppp/options.pptpd
|
||||
if [ "$mppe" -eq 0 ]; then
|
||||
sed -i -e 's/mppe/#mppe/g' /etc/ppp/options.pptpd
|
||||
fi
|
||||
sed -i -e '/ms-dns/d' /etc/ppp/options.pptpd
|
||||
config_list_foreach "pptpd" "dns" setup_dns
|
||||
## Code by VPN Server ##
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
start_pptpd() {
|
||||
[ -f $DEFAULT ] && . $DEFAULT
|
||||
mkdir -p $RUN_D
|
||||
for m in arc4 sha1_generic slhc crc-ccitt ppp_generic ppp_async ppp_mppe; do
|
||||
insmod $m >/dev/null 2>&1
|
||||
done
|
||||
ln -sfn $CHAP_SECRETS /etc/ppp/chap-secrets
|
||||
service_start $BIN $OPTIONS -c $CONFIG
|
||||
}
|
||||
|
||||
start() {
|
||||
config_load pptpd
|
||||
setup_config pptpd || return
|
||||
rm -f $CHAP_SECRETS
|
||||
config_foreach setup_login login
|
||||
start_pptpd
|
||||
}
|
||||
|
||||
stop() {
|
||||
service_stop $BIN
|
||||
|
||||
## Code by VPN Server ##
|
||||
sed -i -e "/## luci-app-pptpd/d" /etc/firewall.user
|
||||
fw3 restart
|
||||
## Code by VPN Server ##
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
#debug
|
||||
#logfile /tmp/pptp-server.log
|
||||
auth
|
||||
name "pptp-server"
|
||||
lcp-echo-failure 3
|
||||
lcp-echo-interval 60
|
||||
default-asyncmap
|
||||
mtu 1482
|
||||
mru 1482
|
||||
nobsdcomp
|
||||
nodeflate
|
||||
proxyarp
|
||||
#nomppc
|
||||
#mppe required,no40,no56,stateless
|
||||
require-mschap-v2
|
||||
refuse-chap
|
||||
refuse-mschap
|
||||
refuse-eap
|
||||
refuse-pap
|
||||
#plugin radius.so
|
||||
#radius-config-file /etc/radius.conf
|
||||
ms-dns 114.114.114.114
|
||||
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
[ ! -f "/usr/share/ucitrack/luci-app-pptpd.json" ] && {
|
||||
cat > /usr/share/ucitrack/luci-app-pptpd.json << EEOF
|
||||
{
|
||||
"config": "pptpd",
|
||||
"init": "pptpd"
|
||||
}
|
||||
EEOF
|
||||
}
|
||||
|
||||
chmod +x /etc/init.d/pptpd
|
||||
rm -f /tmp/luci-indexcahe
|
||||
exit 0
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-pptpd": {
|
||||
"description": "Grant UCI access for luci-app-pptpd",
|
||||
"read": {
|
||||
"uci": [ "pptpd" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "pptpd" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"config": "pptpd",
|
||||
"init": "pptpd"
|
||||
}
|
||||
Reference in new issue
Block a user