Compare commits

12 Commits

Author SHA1 Message Date
dichgrem
ab8ad31186 fix:actions 2026-01-22 12:45:27 +08:00
dichgrem
8bb7e7ce8b feat:adjustable_time 2026-01-22 10:54:35 +08:00
dichgrem
467c942b81 chore:misc 2026-01-18 15:08:00 +08:00
dichgrem
3878369ed3 fix:xss&&crontab
update:actions
2026-01-11 13:56:01 +08:00
dichgrem
fa3b2954cd add:mirror_workflow 2025-10-31 10:56:57 +08:00
dichgrem
c056ca8a4b style:format 2025-10-20 15:51:17 +08:00
dichgrem
69ff02fdbb style:readme 2025-10-20 12:51:30 +08:00
dichgrem
e4d1f1b108 feat:mips_actions 2025-10-20 12:38:00 +08:00
dichgrem
ef45a9414b fix:save_logic
chore:add_guide
2025-10-20 10:13:15 +08:00
dichgrem
cd7f41d7a7 feat:add_workflow 2025-10-16 21:35:19 +08:00
dichgrem
e1e0f03143 style:readme 2025-10-16 19:54:33 +08:00
dichgrem
9dd9806fd8 fix:username 2025-09-24 10:43:44 +08:00
21 changed files with 391 additions and 500 deletions

167
.github/workflows/build-zzz.yml vendored Normal file
View File

@@ -0,0 +1,167 @@
name: Build luci-app-zzz
on:
workflow_dispatch:
inputs:
ramips:
description: 'ramips'
required: false
type: boolean
default: true
filogic:
description: 'filogic'
required: false
type: boolean
default: true
x86_64:
description: 'x86_64'
required: false
type: boolean
default: true
jobs:
matrix-setup:
runs-on: ubuntu-latest
outputs:
architectures: ${{ steps.set-matrix.outputs.architectures }}
steps:
- name: Set matrix
id: set-matrix
run: |
ARCHS='['
if [ "${{ inputs.ramips }}" == "true" ]; then
ARCHS=$ARCHS'"ramips",'
fi
if [ "${{ inputs.filogic }}" == "true" ]; then
ARCHS=$ARCHS'"filogic",'
fi
if [ "${{ inputs.x86_64 }}" == "true" ]; then
ARCHS=$ARCHS'"x86_64",'
fi
ARCHS=${ARCHS%,}
ARCHS=$ARCHS']'
echo "architectures=$ARCHS" >> $GITHUB_OUTPUT
echo "Selected architectures: $ARCHS"
build:
needs: matrix-setup
if: needs.matrix-setup.outputs.architectures != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sdk: ${{ fromJson(needs.matrix-setup.outputs.architectures) }}
env:
RAMIPS_URL: https://downloads.immortalwrt.org/releases/24.10.3/targets/ramips/mt7621/immortalwrt-sdk-24.10.3-ramips-mt7621_gcc-13.3.0_musl.Linux-x86_64.tar.zst
FILOGIC_URL: https://downloads.immortalwrt.org/releases/24.10.3/targets/mediatek/filogic/immortalwrt-sdk-24.10.3-mediatek-filogic_gcc-13.3.0_musl.Linux-x86_64.tar.zst
X86_URL: https://downloads.immortalwrt.org/releases/24.10.3/targets/x86/64/immortalwrt-sdk-24.10.3-x86-64_gcc-13.3.0_musl.Linux-x86_64.tar.zst
WORK_ROOT: ${{ github.workspace }}/imwrt-sdk
CACHE_DIR: ${{ github.workspace }}/cache
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache SDK
uses: actions/cache@v4
id: sdk-cache
with:
path: ${{ env.WORK_ROOT }}
key: ${{ matrix.sdk }}-sdk-24.10.3
enableCrossOsArchive: true
- name: Install dependencies
if: steps.sdk-cache.outputs.cache-hit != 'true'
run: |
sudo apt-get update -qq
sudo apt-get install -y -qq build-essential git wget python3 rsync zstd g++ make libncurses-dev
- name: Set SDK variables
run: |
if [ "${{ matrix.sdk }}" == "ramips" ]; then
echo "SDK_URL=${{ env.RAMIPS_URL }}" >> $GITHUB_ENV
echo "PACKAGE_ARCH=ramips" >> $GITHUB_ENV
elif [ "${{ matrix.sdk }}" == "filogic" ]; then
echo "SDK_URL=${{ env.FILOGIC_URL }}" >> $GITHUB_ENV
echo "PACKAGE_ARCH=aarch64_cortex-a53" >> $GITHUB_ENV
else
echo "SDK_URL=${{ env.X86_URL }}" >> $GITHUB_ENV
echo "PACKAGE_ARCH=x86_64" >> $GITHUB_ENV
fi
- name: Show build target
run: |
echo "👉 正在编译 ${{ matrix.sdk }} 架构 (${{ env.PACKAGE_ARCH }})"
- name: Download & extract SDK
if: steps.sdk-cache.outputs.cache-hit != 'true'
run: |
set -euo pipefail
mkdir -p "$WORK_ROOT"
cd "$WORK_ROOT"
SDK_TAR="$(basename "$SDK_URL")"
echo "下载SDK: $SDK_TAR"
wget -q --show-progress "$SDK_URL" -O "$SDK_TAR"
echo "解压SDK..."
tar --use-compress-program="zstd -q -d" -xf "$SDK_TAR"
SDK_ROOT="$(find . -maxdepth 1 -type d -name 'immortalwrt-sdk*' | head -n 1)"
SDK_ROOT="$(cd "$SDK_ROOT" && pwd)"
echo "SDK_ROOT=$SDK_ROOT" >> $GITHUB_ENV
- name: Set SDK_ROOT from cache
if: steps.sdk-cache.outputs.cache-hit == 'true'
run: |
SDK_ROOT="$(find "$WORK_ROOT" -maxdepth 1 -type d -name 'immortalwrt-sdk*' | head -n 1)"
SDK_ROOT="$(cd "$SDK_ROOT" && pwd)"
echo "SDK_ROOT=$SDK_ROOT" >> $GITHUB_ENV
echo "使用缓存的SDK: $SDK_ROOT"
- name: Setup feeds
run: |
set -euo pipefail
cd "$SDK_ROOT"
echo "添加 zzz feed"
sed -i '/^src-git zzz/d' feeds.conf.default 2>/dev/null || true
echo "src-git zzz https://github.com/Dichgrem/luci-app-zzz.git" >> feeds.conf.default
echo "更新 feeds"
./scripts/feeds update -a
./scripts/feeds update luci
./scripts/feeds update zzz
echo "安装 feeds"
./scripts/feeds install -a -p luci
./scripts/feeds install luci-app-zzz zzz
- name: Build packages
run: |
set -euo pipefail
cd "$SDK_ROOT"
make defconfig
echo "编译 luci-app-zzz 和 zzz"
make package/luci-app-zzz/compile V=s
make package/zzz/compile V=s
- name: Collect packages
run: |
set -euo pipefail
OUT="$GITHUB_WORKSPACE/output"
mkdir -p "$OUT"
echo "所有编译的 ipk 文件:"
find "$SDK_ROOT/bin/packages" -name "*.ipk" -type f
echo ""
echo "复制 zzz 和 luci-app-zzz 包:"
find "$SDK_ROOT/bin/packages" \( -name "zzz_*.ipk" -o -name "luci-app-zzz_*.ipk" \) -type f -exec cp {} "$OUT"/ \;
echo "输出目录内容:"
ls -lah "$OUT"
- name: Upload packages
uses: actions/upload-artifact@v4
with:
name: packages-${{ matrix.sdk }}
path: output/*.ipk
if-no-files-found: error

View File

@@ -1,45 +1,56 @@
# luci-app-nyn # luci-app-zzz
**luci-app-nyn** is a Front-end interface in openwrt for nyn - the modern 802.1x standard authentication client. **luci-app-zzz** is a Front-end interface in openwrt for zzz - the modern 802.1x standard authentication client.
<p align="center"> <p align="center">
<img src="https://github.com/Dichgrem/luci-app-nyn/blob/main/screenshot.png" width="400"> <img src="https://github.com/Dichgrem/luci-app-zzz/blob/main/screenshot.png" width="400">
</p> </p>
> Attention ! The nyn project is archived and it is recommended to use the c language version of zzz instead of it ! In order to commemorate nyn, the name of this project is not modified. ## How to use
- Step 0: Make sure you have an ``openwrt router``, ``download the ipk`` in Releases in this project, and ``upload and install`` it in the system-package of the Luci background.
- Step 1Fill in the user name: Student ID@operator. For example, ``212306666@cucc``, China Unicom is cucc, mobile is cmcc, and telecom is ctcc.
- Step 2: Fill in the password. The ``initial password`` is the last six digits of the ID card by default. It can be modified in the official client.
- Step 3: Select your network card; generally speaking, you can use ``ip addr`` to view the network card that has been assigned an IP, such as eth1.
- Step 4: ``Start the service`` and observe whether you can access the Internet, and then enable ``scheduled startup``; because the campus network will be closed from 12:00 to 7:00 the next day.
- Finallyenjoy it!
## How to build ## How to build
- First clone this repository to the package directory of the openwrt you want to compile: - First clone this repository to the package directory of the openwrt you want to compile:
``` ```
cd ./package ## Add feed
git clone https://github.com/Dichgrem/luci-app-nyn.git echo "src-git zzz https://github.com/Dichgrem/luci-app-zzz.git" >> feeds.conf.default
## Update and install feed
./scripts/feeds update
./scripts/feeds install luci-app-zzz zzz
``` ```
- Then select ``Network->nyn`` and ``LuCI->Applications->luci-app-nyn`` in make menuconfig and change them to "M" state; - Then select ``Network->zzz`` and ``LuCI->Applications->luci-app-zzz`` in make menuconfig and change them to "M" state;
- Finally, run - Finally, run
``` ```
make package/luci-app-nyn/clean V=s make package/luci-app-zzz/clean V=s
make package/luci-app-nyn/compile V=s make package/luci-app-zzz/compile V=s
``` ```
and and
``` ```
make package/nyn/clean V=s make package/zzz/clean V=s
make package/nyn/compile V=s make package/zzz/compile V=s
``` ```
to start build. to start build.
- You can use this command to find the compiled ipk: - You can use this command to find the compiled ipk:
``` ```
find bin/ -name "nyn*.ipk" find bin/ -name "zzz*.ipk"
bin/packages/x86_64/base/nyn_1.0.0-r1_x86_64.ipk bin/packages/x86_64/base/zzz_1.0.0-r1_x86_64.ipk
find bin/ -name "luci-app-nyn*.ipk" find bin/ -name "luci-app-zzz*.ipk"
bin/packages/x86_64/base/luci-app-nyn_0_all.ipk bin/packages/x86_64/base/luci-app-zzz_0_all.ipk
``` ```
## Acknowledgements ## Acknowledgements
- [diredocks/zzz](https://github.com/diredocks/zzz)
- [diredocks/nyn](https://github.com/diredocks/nyn) - [diredocks/nyn](https://github.com/diredocks/nyn)
- [bitdust/njit8021xclient](https://github.com/bitdust/njit8021xclient) - [bitdust/njit8021xclient](https://github.com/bitdust/njit8021xclient)

View File

@@ -1,9 +0,0 @@
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for NYN 802.1x Authentication Client
LUCI_DEPENDS:=+nyn +luci-base
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@@ -1,73 +0,0 @@
-- /usr/lib/lua/luci/controller/nyn.lua
module("luci.controller.nyn", package.seeall)
function index()
if not nixio.fs.access("/etc/config/nyn") then
return
end
-- Menu
entry({"admin", "network", "nyn"}, cbi("nyn"), "NyN", 60).dependent = false
-- Settings
entry({"admin", "network", "nyn", "service_control"}, call("service_control")).leaf = true
-- Status API
entry({"admin", "network", "nyn", "get_status"}, call("act_status")).leaf = true
end
function service_control()
local sys = require "luci.sys"
local action = luci.http.formvalue("action")
local result = { success = false, message = "" }
if action then
local cmd = ""
if action == "start" then
cmd = "/etc/rc.d/S99nyn start"
elseif action == "stop" then
cmd = "/etc/rc.d/S99nyn stop"
elseif action == "restart" then
cmd = "/etc/rc.d/S99nyn stop && sleep 2 && /etc/rc.d/S99nyn start"
end
if cmd ~= "" then
local ret = sys.call(cmd)
if ret == 0 then
result.success = true
result.message = action .. " 成功"
else
result.success = false
result.message = action .. " 失败"
end
end
end
luci.http.prepare_content("application/json")
luci.http.write_json(result)
end
function act_status()
local sys = require "luci.sys"
local util = require "luci.util"
local status = {}
-- Get status
status.running = (sys.call("pgrep -f nyn >/dev/null") == 0)
-- Get process info
if status.running then
status.process_info = util.trim(sys.exec("ps | grep -v grep | grep nyn"))
end
-- Get log
local log_file = "/tmp/nyn.log"
if nixio.fs.access(log_file) then
status.log = util.trim(sys.exec("tail -20 " .. log_file))
else
status.log = util.trim(sys.exec("logread | grep nyn | tail -10"))
end
luci.http.prepare_content("application/json")
luci.http.write_json(status)
end

View File

@@ -1,117 +0,0 @@
-- /usr/lib/lua/luci/model/cbi/nyn.lua
local m, s, o
local sys = require "luci.sys"
-- control
local start_action = luci.http.formvalue("cbid.nyn.auth.start_service")
local stop_action = luci.http.formvalue("cbid.nyn.auth.stop_service")
local restart_action = luci.http.formvalue("cbid.nyn.auth.restart_service")
if start_action then
sys.call("/etc/rc.d/S99nyn start")
elseif stop_action then
sys.call("/etc/rc.d/S99nyn stop")
elseif restart_action then
sys.call("/etc/rc.d/S99nyn stop; sleep 2; /etc/rc.d/S99nyn start")
end
m = Map("nyn", "NYN 802.1x 认证客户端",
"配置使用 NYN 客户端进行网络访问的 802.1x 认证")
-- Authentication Settings
s = m:section(TypedSection, "auth", "认证设置")
s.anonymous = true
s.addremove = false
-- Service Status
o = s:option(DummyValue, "_status", "当前状态")
o.rawhtml = true
o.cfgvalue = function()
local sys = require "luci.sys"
local running = sys.call("pgrep nyn >/dev/null") == 0
if running then
return "<span style='color:green;font-weight:bold'>✔ 正在运行中</span>"
else
return "<span style='color:red;font-weight:bold'>✘ 未运行</span>"
end
end
-- control buttons
control_buttons = s:option(DummyValue, "_control", "服务控制")
control_buttons.rawhtml = true
control_buttons.cfgvalue = function()
return [[
<div style="display: flex; gap: 10px; align-items: center; flex-wrap: wrap;">
<input type="submit" class="cbi-button cbi-button-apply"
name="cbid.nyn.auth.start_service" value="启动服务" />
<input type="submit" class="cbi-button cbi-button-remove"
name="cbid.nyn.auth.stop_service" value="停止服务" />
<input type="submit" class="cbi-button cbi-button-reload"
name="cbid.nyn.auth.restart_service" value="重启服务" />
</div>
]]
end
-- Username
o = s:option(Value, "user", "用户名", "802.1x 认证用户名")
o.password = true
o.rmempty = false
-- Password
o = s:option(Value, "password", "密码", "802.1x 认证密码")
o.password = true
o.rmempty = false
-- Network Device
o = s:option(ListValue, "device", "网络接口", "用于认证的网络接口")
o.rmempty = false
o:value("eth0", "eth0")
o:value("eth1", "eth1")
o:value("wan", "WAN")
-- Add network interface
local interfaces = sys.net.devices()
for _, iface in ipairs(interfaces) do
if iface ~= "lo" then
o:value(iface, iface)
end
end
-- Auto start
auto_start = s:option(Flag, "auto_start", "启用定时启动")
auto_start.description = "启用后将在每周一至周五的 7:00 自动启动服务"
auto_start.rmempty = false
-- Get Status
auto_start.cfgvalue = function(self, section)
local has_cron = sys.call("crontab -l 2>/dev/null | grep 'S99nyn' >/dev/null") == 0
return has_cron and "1" or "0"
end
-- Crontab
auto_start.write = function(self, section, value)
if value == "1" then
-- 启用定时任务:每周一至周五 7:00 启动
sys.call("(crontab -l 2>/dev/null | grep -v 'S99nyn' | grep -v '# nyn auto') | crontab - 2>/dev/null")
sys.call("(crontab -l 2>/dev/null; echo '0 7 * * 1,2,3,4,5 /etc/rc.d/S99nyn start # nyn auto start') | crontab -")
sys.call("/etc/init.d/cron enable && /etc/init.d/cron restart")
else
-- 禁用定时任务
sys.call("(crontab -l 2>/dev/null | grep -v 'S99nyn' | grep -v '# nyn auto') | crontab - 2>/dev/null")
sys.call("/etc/init.d/cron restart")
end
end
-- Crontab Status
timer_status_display = s:option(DummyValue, "_timer_status_display", "定时任务状态")
timer_status_display.rawhtml = true
timer_status_display.cfgvalue = function()
local cron_output = sys.exec("crontab -l 2>/dev/null | grep 'S99nyn' || echo '未设置'")
if cron_output:match("S99nyn") then
return "<span style='color:green;font-weight:bold'>✔ 已启用 (每周一至周五 7:00 自动启动)</span>"
else
return "<span style='color:red;font-weight:bold'>✘ 未启用</span>"
end
end
return m

View File

@@ -1,7 +1,9 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for NYN 802.1x Authentication Client LUCI_TITLE:=LuCI support for ZZZ 802.1x Authentication Client
LUCI_DEPENDS:=+zzz +luci-base LUCI_DEPENDS:=+zzz +luci-base
PKG_VERSION:=2.0.1
PKG_RELEASE:=1
include $(TOPDIR)/feeds/luci/luci.mk include $(TOPDIR)/feeds/luci/luci.mk

View File

@@ -2,72 +2,78 @@
module("luci.controller.zzz", package.seeall) module("luci.controller.zzz", package.seeall)
function index() function index()
if not nixio.fs.access("/etc/config/zzz") then if not nixio.fs.access("/etc/config/zzz") then
return return
end end
-- Menu -- Menu
entry({"admin", "network", "zzz"}, cbi("zzz"), "ZZZ", 60).dependent = false entry({ "admin", "network", "zzz" }, cbi("zzz"), "ZZZ", 60).dependent = false
-- Settings -- Settings
entry({"admin", "network", "zzz", "service_control"}, call("service_control")).leaf = true entry({ "admin", "network", "zzz", "service_control" }, call("service_control")).leaf = true
-- Status API -- Status API
entry({"admin", "network", "zzz", "get_status"}, call("act_status")).leaf = true entry({ "admin", "network", "zzz", "get_status" }, call("act_status")).leaf = true
end end
function service_control() function service_control()
local sys = require "luci.sys" local sys = require("luci.sys")
local action = luci.http.formvalue("action") local util = require("luci.util")
local result = { success = false, message = "" } local action = luci.http.formvalue("action")
local result = { success = false, message = "" }
if action then local valid_actions = { start = true, stop = true, restart = true }
local cmd = ""
if action == "start" then
cmd = "/etc/rc.d/S99zzz start"
elseif action == "stop" then
cmd = "/etc/rc.d/S99zzz stop"
elseif action == "restart" then
cmd = "/etc/rc.d/S99zzz stop && sleep 2 && /etc/rc.d/S99zzz start"
end
if cmd ~= "" then if action and valid_actions[action] then
local ret = sys.call(cmd) local cmd = ""
if ret == 0 then if action == "start" then
result.success = true cmd = "/etc/rc.d/S99zzz start"
result.message = action .. " 成功" elseif action == "stop" then
else cmd = "/etc/rc.d/S99zzz stop"
result.success = false elseif action == "restart" then
result.message = action .. " 失败" cmd = "/etc/rc.d/S99zzz stop && sleep 2 && /etc/rc.d/S99zzz start"
end end
end
end
luci.http.prepare_content("application/json") if cmd ~= "" then
luci.http.write_json(result) local ret = sys.call(cmd)
if ret == 0 then
result.success = true
result.message = util.pcdata(action .. " 成功")
else
result.success = false
result.message = util.pcdata(action .. " 失败")
end
end
else
result.message = "无效的操作"
end
luci.http.prepare_content("application/json")
luci.http.write_json(result)
end end
function act_status() function act_status()
local sys = require "luci.sys" local sys = require("luci.sys")
local util = require "luci.util" local util = require("luci.util")
local status = {} local status = {}
-- Get status status.running = (sys.call("pgrep -f zzz >/dev/null") == 0)
status.running = (sys.call("pgrep -f zzz >/dev/null") == 0)
-- Get process info if status.running then
if status.running then status.process_info = util.trim(sys.exec("ps | grep -v grep | grep zzz"))
status.process_info = util.trim(sys.exec("ps | grep -v grep | grep zzz")) end
end
-- Get log local log_file = "/tmp/zzz.log"
local log_file = "/tmp/zzz.log" if nixio.fs.access(log_file) then
if nixio.fs.access(log_file) then status.log = util.trim(sys.exec("tail -20 " .. log_file))
status.log = util.trim(sys.exec("tail -20 " .. log_file)) else
else status.log = util.trim(sys.exec("logread | grep zzz | tail -10"))
status.log = util.trim(sys.exec("logread | grep zzz | tail -10")) end
end
luci.http.prepare_content("application/json") if status.log then
luci.http.write_json(status) status.log = util.pcdata(status.log)
end
luci.http.prepare_content("application/json")
luci.http.write_json(status)
end end

View File

@@ -1,117 +1,191 @@
-- /usr/lib/lua/luci/model/cbi/zzz.lua
local m, s, o local m, s, o
local sys = require "luci.sys" local sys = require("luci.sys")
local util = require("luci.util")
-- control m = Map("zzz", "ZZZ 802.1x 认证客户端", "配置使用 zzz 客户端进行网络访问的 802.1x 认证")
local start_action = luci.http.formvalue("cbid.zzz.auth.start_service")
local stop_action = luci.http.formvalue("cbid.zzz.auth.stop_service")
local restart_action = luci.http.formvalue("cbid.zzz.auth.restart_service")
if start_action then
sys.call("/etc/rc.d/S99zzz start")
elseif stop_action then
sys.call("/etc/rc.d/S99zzz stop")
elseif restart_action then
sys.call("/etc/rc.d/S99zzz stop; sleep 2; /etc/rc.d/S99zzz start")
end
m = Map("zzz", "ZZZ 802.1x 认证客户端",
"配置使用 zzz 客户端进行网络访问的 802.1x 认证")
-- Authentication Settings -- Authentication Settings
s = m:section(TypedSection, "auth", "认证设置") s = m:section(TypedSection, "auth", "认证设置")
s.anonymous = true s.anonymous = true
s.addremove = false s.addremove = false
-- Service Status
o = s:option(DummyValue, "_status", "当前状态") o = s:option(DummyValue, "_status", "当前状态")
o.rawhtml = true o.rawhtml = true
o.cfgvalue = function() o.cfgvalue = function()
local sys = require "luci.sys" local running = sys.call("pgrep zzz >/dev/null") == 0
local running = sys.call("pgrep zzz >/dev/null") == 0 if running then
if running then return "<span style='color:green;font-weight:bold'>✔ 正在运行中</span>"
return "<span style='color:green;font-weight:bold'>✔ 正在运行中</span>" else
else return "<span style='color:red;font-weight:bold'>✘ 未运行</span>"
return "<span style='color:red;font-weight:bold'>✘ 未运行</span>" end
end
end end
-- control buttons -- control buttons
control_buttons = s:option(DummyValue, "_control", "服务控制") control_buttons = s:option(DummyValue, "_control", "服务控制")
control_buttons.rawhtml = true control_buttons.rawhtml = true
control_buttons.cfgvalue = function() control_buttons.cfgvalue = function()
return [[ return [[
<div style="display: flex; gap: 10px; align-items: center; flex-wrap: wrap;"> <div style="display: flex; gap: 10px; align-items: center; flex-wrap: wrap;">
<input type="submit" class="cbi-button cbi-button-apply" <button type="button" class="cbi-button cbi-button-apply" onclick="fetch('/cgi-bin/luci/admin/network/zzz/service_control',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:'action=start'}).then(r=>r.json()).then(d=>{alert(d.message);if(d.success)location.reload();});return false;">启动服务</button>
name="cbid.zzz.auth.start_service" value="启动服务" /> <button type="button" class="cbi-button cbi-button-remove" onclick="fetch('/cgi-bin/luci/admin/network/zzz/service_control',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:'action=stop'}).then(r=>r.json()).then(d=>{alert(d.message);if(d.success)location.reload();});return false;">停止服务</button>
<input type="submit" class="cbi-button cbi-button-remove" <button type="button" class="cbi-button cbi-button-reload" onclick="fetch('/cgi-bin/luci/admin/network/zzz/service_control',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:'action=restart'}).then(r=>r.json()).then(d=>{alert(d.message);if(d.success)location.reload();});return false;">重启服务</button>
name="cbid.zzz.auth.stop_service" value="停止服务" /> </div>
<input type="submit" class="cbi-button cbi-button-reload" ]]
name="cbid.zzz.auth.restart_service" value="重启服务" />
</div>
]]
end end
-- Username -- Username
o = s:option(Value, "user", "用户名", "802.1x 认证用户名") o = s:option(
o.password = true Value,
"username",
"用户名",
[[802.1x 认证用户名
<span style="cursor: help; color: #007bff; font-weight: bold;" title="用户名为学号@运营商例如212306666@cucc移动为cmcc联通为cucc电信为ctcc">?</span>]]
)
o.rmempty = false o.rmempty = false
o.rawhtml = true
function o.validate(self, value)
value = value:match("^%s*(.-)%s*$") or value
if #value < 3 or #value > 64 then
return nil, "用户名长度必须在3-64字符之间"
end
if not value:match("^[a-zA-Z0-9@._-]+$") then
return nil, "用户名只能包含字母、数字、@、.、_和-"
end
return value
end
-- Password -- Password
o = s:option(Value, "password", "密码", "802.1x 认证密码")
o.password = true o.password = true
o.rmempty = false o.rmempty = false
o = s:option(
Value,
"password",
"密码",
[[802.1x 认证密码
<span style="cursor: help; color: #007bff; font-weight: bold;" title="密码默认为身份证号后六位可以在官方客户端inode中修改">?</span>]]
)
o.password = true
o.rmempty = false
o.rawhtml = true
function o.validate(self, value)
if #value < 4 or #value > 128 then
return nil, "密码长度必须在4-128字符之间"
end
return value
end
-- Network Device -- Network Device
o = s:option(ListValue, "device", "网络接口", "用于认证的网络接口") o = s:option(
Value,
"device",
"网络接口",
[[用于认证的网络接口
<span style="cursor: help; color: #007bff; font-weight: bold;" title="可以用ip addr命令查看有10.38开头ip的接口">?</span>]]
)
o.rmempty = false o.rmempty = false
o:value("eth0", "eth0") o:value("eth0", "eth0")
o:value("eth1", "eth1") o:value("eth1", "eth1")
o:value("wan", "WAN") o:value("wan", "WAN")
-- Add network interface
local interfaces = sys.net.devices() local interfaces = sys.net.devices()
for _, iface in ipairs(interfaces) do for _, iface in ipairs(interfaces) do
if iface ~= "lo" then if iface ~= "lo" and iface:match("^[a-zA-Z0-9]+$") then
o:value(iface, iface) o:value(iface, iface)
end end
end
function o.validate(self, value)
if not value:match("^[a-zA-Z0-9]+$") then
return nil, "网络接口只能包含字母和数字"
end
return value
end end
-- Auto start -- Auto start
auto_start = s:option(Flag, "auto_start", "启用定时启动") auto_start = s:option(Flag, "auto_start", "启用定时启动")
auto_start.description = "启用后将在每周一至周五的 7:00 自动启动服务" auto_start.description = "启用后将在每周一至周五自动启动服务"
auto_start.rmempty = false auto_start.rmempty = false
-- Schedule Time
schedule_time = s:option(Value, "schedule_time", "启动时间")
schedule_time.description = "设置定时启动的时间 (格式: HH:MM例如 07:30)"
schedule_time.placeholder = "07:00"
schedule_time.rmempty = true
schedule_time.default = "07:00"
schedule_time.cfgvalue = function(self, section)
local value = self.map:get(section, "schedule_time")
return value or "07:00"
end
function schedule_time.validate(self, value)
if not value:match("^[0-9][0-9]:[0-9][0-9]$") then
return nil, "时间格式必须为 HH:MM (例如 07:30)"
end
local hour = tonumber(value:sub(1, 2))
local minute = tonumber(value:sub(4, 5))
if hour < 0 or hour > 23 then
return nil, "小时必须在 0-23 之间"
end
if minute < 0 or minute > 59 then
return nil, "分钟必须在 0-59 之间"
end
return value
end
schedule_time:depends("auto_start", "1")
-- Get Status -- Get Status
auto_start.cfgvalue = function(self, section) auto_start.cfgvalue = function(self, section)
local has_cron = sys.call("crontab -l 2>/dev/null | grep 'S99zzz' >/dev/null") == 0 local has_cron = sys.call("crontab -l 2>/dev/null | grep 'S99zzz' >/dev/null") == 0
return has_cron and "1" or "0" return has_cron and "1" or "0"
end end
-- Crontab -- Crontab
auto_start.write = function(self, section, value) auto_start.write = function(self, section, value)
if value == "1" then local schedule_time_val = self.map:get(section, "schedule_time") or "07:00"
-- 启用定时任务:每周一至周五 7:00 启动 local hour, minute = schedule_time_val:match("^(%d+):(%d+)$")
sys.call("(crontab -l 2>/dev/null | grep -v 'S99zzz' | grep -v '# zzz auto') | crontab - 2>/dev/null") local temp_cron = "/tmp/.zzz_cron_tmp_" .. os.time()
sys.call("(crontab -l 2>/dev/null; echo '0 7 * * 1,2,3,4,5 /etc/rc.d/S99zzz start # zzz auto start') | crontab -") if value == "1" then
sys.call("/etc/init.d/cron enable && /etc/init.d/cron restart") sys.call("crontab -l 2>/dev/null > " .. temp_cron)
else sys.call("sed -i '/S99zzz/d' " .. temp_cron)
-- 禁用定时任务 sys.call("sed -i '/# zzz auto/d' " .. temp_cron)
sys.call("(crontab -l 2>/dev/null | grep -v 'S99zzz' | grep -v '# zzz auto') | crontab - 2>/dev/null") sys.call(string.format("echo '%s %s * * 1,2,3,4,5 /etc/rc.d/S99zzz start # zzz auto start' >> %s", minute, hour, temp_cron))
sys.call("/etc/init.d/cron restart") sys.call("crontab " .. temp_cron .. " 2>/dev/null && rm -f " .. temp_cron)
end sys.call("/etc/init.d/cron enable && /etc/init.d/cron restart")
else
sys.call("crontab -l 2>/dev/null > " .. temp_cron)
sys.call("sed -i '/S99zzz/d' " .. temp_cron)
sys.call("sed -i '/# zzz auto/d' " .. temp_cron)
sys.call("crontab " .. temp_cron .. " 2>/dev/null && rm -f " .. temp_cron)
sys.call("/etc/init.d/cron restart")
end
end end
-- Crontab Status -- Crontab Status
timer_status_display = s:option(DummyValue, "_timer_status_display", "定时任务状态") timer_status_display = s:option(DummyValue, "_timer_status_display", "定时任务状态")
timer_status_display.rawhtml = true timer_status_display.rawhtml = true
timer_status_display.cfgvalue = function() timer_status_display.cfgvalue = function()
local cron_output = sys.exec("crontab -l 2>/dev/null | grep 'S99zzz' || echo '未设置'") local cron_output = sys.exec("crontab -l 2>/dev/null | grep 'S99zzz' || echo '未设置'")
if cron_output:match("S99zzz") then if cron_output:match("S99zzz") then
return "<span style='color:green;font-weight:bold'>✔ 已启用 (每周一至周五 7:00 自动启动)</span>" local cron_line = cron_output:match("%d+%s+%d+%s+%*%s+%*%s+%d+,.*# zzz auto")
else if cron_line then
return "<span style='color:red;font-weight:bold'>✘ 未启用</span>" local minute, hour = cron_line:match("^(%d+)%s+(%d+)%s+")
end if minute and hour then
local time_str = string.format("%02d:%02d", tonumber(hour), tonumber(minute))
return string.format("<span style='color:green;font-weight:bold'>✔ 已启用 (每周一至周五 %s 自动启动)</span>", time_str)
end
end
return "<span style='color:green;font-weight:bold'>✔ 已启用</span>"
else
return "<span style='color:red;font-weight:bold'>✘ 未启用</span>"
end
end
-- 保存后自动重启 zzz 服务
m.on_commit = function(self)
local sys = require("luci.sys")
sys.call("/etc/rc.d/S99zzz restart >/dev/null 2>&1 &")
end end
return m return m

View File

@@ -1,66 +0,0 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=nyn
PKG_VERSION:=0.0.3
PKG_RELEASE:=1
PKG_MAINTAINER:=Dichgrem <brcefy@gmail.com>
PKG_LICENSE:=MIT
include $(INCLUDE_DIR)/package.mk
define Package/nyn
SECTION:=net
CATEGORY:=Network
TITLE:=NYN 802.1x Authentication Client
URL:=https://github.com/diredocks/nyn
DEPENDS:=+libpcap
endef
define Package/nyn/description
A 802.1x authentication client for OpenWrt routers.
Cross-compiled with musl toolchain for optimal compatibility.
endef
define Package/nyn/conffiles
/etc/config/nyn
/etc/nyn/config.toml
endef
define Build/Prepare
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/nyn/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)/etc/nyn
# Install precompiled binary based on architecture
$(if $(CONFIG_TARGET_x86_64),$(INSTALL_BIN) ./files/bin/nyn-x86_64 $(1)/usr/bin/nyn)
$(if $(CONFIG_TARGET_armvirt_64),$(INSTALL_BIN) ./files/bin/nyn-aarch64 $(1)/usr/bin/nyn)
$(if $(CONFIG_TARGET_bcm27xx_bcm2711),$(INSTALL_BIN) ./files/bin/nyn-aarch64 $(1)/usr/bin/nyn)
$(if $(CONFIG_TARGET_ath79_generic),$(INSTALL_BIN) ./files/bin/nyn-mips64 $(1)/usr/bin/nyn)
$(if $(CONFIG_TARGET_ramips_mt7621),$(INSTALL_BIN) ./files/bin/nyn-mips64 $(1)/usr/bin/nyn)
$(if $(CONFIG_TARGET_mediatek_mt7622),$(INSTALL_BIN) ./files/bin/nyn-aarch64 $(1)/usr/bin/nyn)
$(if $(CONFIG_TARGET_rockchip_armv8),$(INSTALL_BIN) ./files/bin/nyn-aarch64 $(1)/usr/bin/nyn)
# Fallback - try to detect architecture
$(if $(findstring arm,$(ARCH)),$(INSTALL_BIN) ./files/bin/nyn-armv7 $(1)/usr/bin/nyn)
$(if $(findstring aarch64,$(ARCH)),$(INSTALL_BIN) ./files/bin/nyn-aarch64 $(1)/usr/bin/nyn)
$(if $(findstring mips,$(ARCH)),$(INSTALL_BIN) ./files/bin/nyn-mips64 $(1)/usr/bin/nyn)
$(if $(findstring x86_64,$(ARCH)),$(INSTALL_BIN) ./files/bin/nyn-x86_64 $(1)/usr/bin/nyn)
$(if $(findstring i386,$(ARCH)),$(INSTALL_BIN) ./files/bin/nyn-i686 $(1)/usr/bin/nyn)
$(INSTALL_BIN) ./files/usr/bin/nyn-device-info $(1)/usr/bin/
$(INSTALL_CONF) ./files/etc/config/nyn $(1)/etc/config/
$(INSTALL_CONF) ./files/etc/nyn/config.toml $(1)/etc/nyn/
$(INSTALL_BIN) ./files/etc/init.d/nyn $(1)/etc/init.d/
endef
$(eval $(call BuildPackage,nyn))

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -1,16 +0,0 @@
config general 'general'
option enabled '0'
option timeout '5'
option retry '5'
option schedule_callback '0'
config crypto 'crypto'
option win_ver 'r70393861'
option client_key 'Oly5D62FaE94W7'
option client_version ''
config auth 'auth'
option user ''
option password ''
option device 'eth0'
option hardware_description ''

View File

@@ -1,41 +0,0 @@
#!/bin/sh /etc/rc.common
START=99
USE_PROCD=1
CONFIG=/etc/nyn/config.toml
start_service() {
generate_config
procd_open_instance
procd_set_param command /usr/bin/nyn -config "$CONFIG"
procd_set_param respawn
procd_close_instance
}
stop_service() {
procd_kill nyn
}
generate_config() {
mkdir -p /etc/nyn
cat >"$CONFIG" <<EOF
# Auto-generated by UCI
[general]
timeout = $(uci -q get nyn.general.timeout)
retry = $(uci -q get nyn.general.retry)
schedule_callback = $([ "$(uci -q get nyn.general.schedule_callback)" = "1" ] && echo "true" || echo "false")
[crypto]
win_ver = "$(uci -q get nyn.crypto.win_ver)"
client_key = "$(uci -q get nyn.crypto.client_key)"
[[auth]]
user = "$(uci -q get nyn.auth.user)"
password = "$(uci -q get nyn.auth.password)"
device = "$(uci -q get nyn.auth.device)"
EOF
}

View File

@@ -1,18 +0,0 @@
# Default configuration for NYN 802.1x client
# This file will be generated by UCI system
[general]
timeout = 5
retry = 5
schedule_callback = false
[crypto]
win_ver = "r70393861"
client_key = "Oly5D62FaE94W7"
# client_version = ""
[[auth]]
user = ""
password = ""
device = "eth0"
# hardware_description = ""

View File

@@ -1,29 +0,0 @@
#!/bin/sh
# /usr/bin/nyn-device-info
# Helper script to get device information for NYN configuration
echo "Available network devices:"
echo "=========================="
if command -v nyn >/dev/null 2>&1; then
nyn -mode info 2>/dev/null | grep -E "(Found|device|hardware_description)" | while read line; do
echo "$line"
done
else
echo "NYN binary not found. Showing available network interfaces:"
for dev in /sys/class/net/*; do
if [ -d "$dev" ]; then
iface=$(basename "$dev")
if [ "$iface" != "lo" ]; then
echo "Device: $iface"
if [ -f "$dev/address" ]; then
echo " MAC: $(cat "$dev/address")"
fi
if [ -f "$dev/operstate" ]; then
echo " State: $(cat "$dev/operstate")"
fi
echo ""
fi
fi
done
fi

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 91 KiB

View File

@@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=zzz PKG_NAME:=zzz
PKG_VERSION:=0.1.1 PKG_VERSION:=2.0.1
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_MAINTAINER:=Dichgrem <brcefy@gmail.com> PKG_MAINTAINER:=Dichgrem <brcefy@gmail.com>