update 2026-08-07 08:51:09

This commit is contained in:
action committed 2026-08-07 08:51:09 +08:00
1 parent d9d5e43e0e
commit b99c98d91e
16 files changed
+281 -70

No files matched your search

+2 -2
View File
@@ -1,4 +1,4 @@
# Copyright (C) 2018-2021 Lienol <lawlienol@gmail.com>
# Copyright (C) 2018-2026 Lienol <lawlienol@gmail.com>
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
@@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-ipsec-server
PKG_VERSION:=20260801
PKG_VERSION:=20260807
PKG_RELEASE:=2
PKG_MAINTAINER:=Lienol <lawlienol@gmail.com>
@@ -11,10 +11,7 @@ function index()
entry({"admin", "vpn", "ipsec-server", "settings"}, cbi("ipsec-server/settings"), _("General Settings"), 10).leaf = true
entry({"admin", "vpn", "ipsec-server", "users"}, cbi("ipsec-server/users"), _("Users Manager"), 20).leaf = true
entry({"admin", "vpn", "ipsec-server", "l2tp_user"}, cbi("ipsec-server/l2tp_user")).leaf = true
local uci = require "luci.model.uci".cursor()
if uci:get("luci-app-ipsec-server", "ipsec", "type") == "L2TP" then
entry({"admin", "vpn", "ipsec-server", "online"}, cbi("ipsec-server/online"), _("L2TP Online Users"), 30).leaf = true
end
entry({"admin", "vpn", "ipsec-server", "online"}, cbi("ipsec-server/online"), _("Online Users"), 30).leaf = true
entry({"admin", "vpn", "ipsec-server", "status"}, call("act_status")).leaf = true
end
@@ -1,26 +1,123 @@
local o = require "luci.dispatcher"
local d = require "luci.dispatcher"
local fs = require "nixio.fs"
local jsonc = require "luci.jsonc"
local sys = require "luci.sys"
local util = require "luci.util"
local uci = require "luci.model.uci".cursor()
local sessions = {}
local session_path = "/var/etc/xl2tpd/session"
if fs.access(session_path) then
for filename in fs.dir(session_path) do
local session_file = session_path .. "/" .. filename
local file = io.open(session_file, "r")
local t = jsonc.parse(file:read("*a"))
if t then
t.session_file = session_file
sessions[#sessions + 1] = t
f = SimpleForm("processes")
f.reset = false
f.submit = false
local firewall_user_path = "/etc/firewall.user"
if uci:get("luci-app-ipsec-server", "ipsec", "type") ~= "L2TP" then
local sessions = {}
local status_dump = io.popen('ipsec status 2>&1 | grep "ESTABLISHED"')
if status_dump then
local line
for line in status_dump:lines() do
local line = string.split(line, ",")
local s1 = string.split(line[1], " ")
local type_count = s1[1]
local user = line[2]
local user_split = string.split(user, "...")
if #user_split == 2 then
local leftid = string.match(user_split[1], "%[(.-)%]")
local username = string.match(user_split[2], "%[(.-)%]")
local remote_ip = string.split(user_split[2], "[")[1]
local a = {}
for i, v in ipairs(s1) do
if i > 2 then
a[#a + 1] = v
end
end
local login_time = table.concat(a, " ")
sessions[#sessions + 1] = {
username = username,
remote_ip = remote_ip,
login_time = login_time
}
end
end
file:close()
end
for i, v in ipairs(sessions) do
local ip = util.exec("ipsec leases 2>/dev/null | grep 'online' | grep '%s' | awk '{print $1}'" % { v.username })
v.ip = ip
end
t = f:section(Table, sessions, translate("Online Users"))
t:option(DummyValue, "username", translate("Username") .. "/" .. translate("Identifier"))
t:option(DummyValue, "ip", translate("Client IP"))
t:option(DummyValue, "login_time", translate("Login Time"))
t:option(DummyValue, "remote_ip", translate("IP address"))
add_blacklist = t:option(Button, "add_blacklist", translate("Blacklist"))
function add_blacklist.render(e, t, a)
e.title = translate("Add to Blacklist")
e.inputstyle = "remove"
Button.render(e, t, a)
end
function add_blacklist.write(t, s)
local e = t.map:get(s, "remote_ip")
util.execi("echo 'iptables -I INPUT -s %s -p udp -m multiport --dports 500,4500 -j DROP ## ipsec-blacklist-%s' >> %s" % {e, e, firewall_user_path})
util.execi("iptables -I INPUT -s %s -p udp -m multiport --dports 500,4500 -j DROP" % {e})
luci.http.redirect(d.build_url("admin/vpn/ipsec-server/online"))
end
else
local l2tp_sessions = {}
local l2tp_session_path = "/var/etc/xl2tpd/session"
if fs.access(l2tp_session_path) then
for filename in fs.dir(l2tp_session_path) do
local session_file = l2tp_session_path .. "/" .. filename
local file = io.open(session_file, "r")
local t = jsonc.parse(file:read("*a"))
if t then
t.session_file = session_file
l2tp_sessions[#l2tp_sessions + 1] = t
end
file:close()
end
end
t = f:section(Table, l2tp_sessions, translate("L2TP Online Users"))
t:option(DummyValue, "username", translate("Username"))
t:option(DummyValue, "interface", translate("Interface"))
t:option(DummyValue, "ip", translate("Client IP"))
t:option(DummyValue, "remote_ip", translate("IP address"))
t:option(DummyValue, "login_time", translate("Login Time"))
_blacklist = t:option(Button, "_blacklist", translate("Blacklist"))
function _blacklist.render(e, t, a)
e.title = translate("Add to Blacklist")
e.inputstyle = "remove"
Button.render(e, t, a)
end
function _blacklist.write(t, s)
local e = t.map:get(s, "remote_ip")
util.execi("echo 'iptables -I INPUT -s %s -p udp -m multiport --dports 500,4500,1701 -j DROP ## xl2tpd-blacklist-%s' >> %s" % {e, e, firewall_user_path})
util.execi("iptables -I INPUT -s %s -p udp -m multiport --dports 500,4500,1701 -j DROP" % {e})
util.execi("rm -f " .. t.map:get(s, "session_file"))
null, t.tag_error[s] = sys.process.signal(t.map:get(s, "pid"), 9)
luci.http.redirect(d.build_url("admin/vpn/ipsec-server/online"))
end
_kill = t:option(Button, "_kill", translate("Forced offline"))
_kill.inputstyle = "remove"
function _kill.write(t, s)
util.execi("rm -f " .. t.map:get(s, "session_file"))
null, t.tag_error[t] = sys.process.signal(t.map:get(s, "pid"), 9)
luci.http.redirect(d.build_url("admin/vpn/ipsec-server/online"))
end
end
local blacklist = {}
local firewall_user_path = "/etc/firewall.user"
if fs.access(firewall_user_path) then
for line in io.lines(firewall_user_path) do
local m = line:match('ipsec%-blacklist%-([^\n]+)')
if m then
local t = {}
t.ip = m
blacklist[#blacklist + 1] = t
end
local m = line:match('xl2tpd%-blacklist%-([^\n]+)')
if m then
local t = {}
@@ -30,54 +127,22 @@ if fs.access(firewall_user_path) then
end
end
f = SimpleForm("processes")
f.reset = false
f.submit = false
t = f:section(Table, sessions, translate("L2TP Online Users"))
t:option(DummyValue, "username", translate("Username"))
t:option(DummyValue, "interface", translate("Interface"))
t:option(DummyValue, "ip", translate("Client IP"))
t:option(DummyValue, "remote_ip", translate("IP address"))
t:option(DummyValue, "login_time", translate("Login Time"))
_blacklist = t:option(Button, "_blacklist", translate("Blacklist"))
function _blacklist.render(e, t, a)
e.title = translate("Add to Blacklist")
e.inputstyle = "remove"
Button.render(e, t, a)
end
function _blacklist.write(t, s)
local e = t.map:get(s, "remote_ip")
luci.util.execi("echo 'iptables -I INPUT -s %s -p udp -m multiport --dports 500,4500,1701 -j DROP ## xl2tpd-blacklist-%s' >> /etc/firewall.user" % {e, e})
luci.util.execi("iptables -I INPUT -s %s -p udp -m multiport --dports 500,4500,1701 -j DROP" % {e})
luci.util.execi("rm -f " .. t.map:get(s, "session_file"))
null, t.tag_error[s] = luci.sys.process.signal(t.map:get(s, "pid"), 9)
luci.http.redirect(o.build_url("admin/vpn/ipsec-server/online"))
end
_kill = t:option(Button, "_kill", translate("Forced offline"))
_kill.inputstyle = "remove"
function _kill.write(t, s)
luci.util.execi("rm -f " .. t.map:get(s, "session_file"))
null, t.tag_error[t] = luci.sys.process.signal(t.map:get(s, "pid"), 9)
luci.http.redirect(o.build_url("admin/vpn/ipsec-server/online"))
end
t = f:section(Table, blacklist, translate("Blacklist"))
t:option(DummyValue, "ip", translate("IP address"))
_blacklist2 = t:option(Button, "_blacklist2", translate("Blacklist"))
function _blacklist2.render(e, t, a)
remove_blacklist = t:option(Button, "remove_blacklist", translate("Blacklist"))
function remove_blacklist.render(e, t, a)
e.title = translate("Remove from Blacklist")
e.inputstyle = "apply"
Button.render(e, t, a)
end
function _blacklist2.write(t, s)
function remove_blacklist.write(t, s)
local e = t.map:get(s, "ip")
luci.util.execi("sed -i -e '/## xl2tpd-blacklist-%s/d' /etc/firewall.user" % {e})
luci.util.execi("iptables -D INPUT -s %s -p udp -m multiport --dports 500,4500,1701 -j DROP" % {e})
luci.http.redirect(o.build_url("admin/vpn/ipsec-server/online"))
util.execi("sed -i -e '/## ipsec-blacklist-%s/d' %s" % {e, firewall_user_path})
util.execi("sed -i -e '/## xl2tpd-blacklist-%s/d' %s" % {e, firewall_user_path})
util.execi("iptables -D INPUT -s %s -p udp -m multiport --dports 500,4500 -j DROP 2>/dev/null" % {e})
util.execi("iptables -D INPUT -s %s -p udp -m multiport --dports 500,4500,1701 -j DROP 2>/dev/null" % {e})
luci.http.redirect(d.build_url("admin/vpn/ipsec-server/online"))
end
return f
+36 -5
View File
@@ -1,15 +1,46 @@
# Copyright (C) 2018-2022 Lienol <lawlienol@gmail.com>
# Copyright (C) 2018-2026 Lienol <lawlienol@gmail.com>
#
# This is free software, licensed under the GNU General Public License v3.
#
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for KodExplorer
LUCI_DEPENDS:=+nginx-ssl +unzip +zoneinfo-asia +php8 +php8-fastcgi +php8-fpm +php8-mod-curl +php8-mod-dom +php8-mod-gd +php8-mod-iconv +php8-mod-mbstring +php8-mod-opcache +php8-mod-session +php8-mod-zip +php8-mod-sqlite3 +php8-mod-pdo +php8-mod-pdo-sqlite +php8-mod-pdo-mysql +php8-mod-xml +php8-mod-xmlreader +php8-mod-xmlwriter
LUCI_PKGARCH:=all
PKG_NAME:=luci-app-kodexplorer
PKG_VERSION:=20220109
PKG_RELEASE:=2
PKG_RELEASE:=3
LUCI_TITLE:=LuCI support for KodExplorer
LUCI_PKGARCH:=all
define Package/$(PKG_NAME)/config
config PACKAGE_$(PKG_NAME)_depends
depends on PACKAGE_$(PKG_NAME)
bool
default y
select PACKAGE_nginx-ssl
select PACKAGE_unzip
select PACKAGE_zoneinfo-asia
select PACKAGE_php8
select PACKAGE_php8-fastcgi
select PACKAGE_php8-fpm
select PACKAGE_php8-mod-curl
select PACKAGE_php8-mod-dom
select PACKAGE_php8-mod-gd
select PACKAGE_php8-mod-iconv
select PACKAGE_php8-mod-mbstring
select PACKAGE_php8-mod-opcache
select PACKAGE_php8-mod-pdo
select PACKAGE_php8-mod-pdo-mysql
select PACKAGE_php8-mod-pdo-sqlite
select PACKAGE_php8-mod-session
select PACKAGE_php8-mod-sqlite3
select PACKAGE_php8-mod-xml
select PACKAGE_php8-mod-xmlreader
select PACKAGE_php8-mod-xmlwriter
select PACKAGE_php8-mod-zip
endef
include $(TOPDIR)/feeds/luci/luci.mk