mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-17 05:53:03 +08:00
🐶 Sync 2026-11-16 22:02:48
This commit is contained in:
1 parent
cdec1dfaa0
commit
61029384e8
43 files changed
+755
-102
No files matched your search
@@ -0,0 +1,58 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
PKG_NAME:=changeguard
|
||||
PKG_VERSION:=0.3.0-cg1
|
||||
PKG_RELEASE:=1
|
||||
include ./release.mk
|
||||
PKG_SOURCE:=changeguard-$(PKG_VERSION)-$(ARCH).tar.gz
|
||||
PKG_SOURCE_URL?=https://fw.koolcenter.com/binary/changeguard/releases/
|
||||
PKG_HASH:=skip
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
STRIP:=true
|
||||
RSTRIP:=:
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/changeguard
|
||||
SECTION:=admin
|
||||
CATEGORY:=System
|
||||
TITLE:=Device change protection CLI
|
||||
DEPENDS:=@(x86_64||aarch64) +linkspace +block-mount
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/changeguard/preinst
|
||||
#!/bin/sh
|
||||
[ -n "$${IPKG_INSTROOT:-}" ] && exit 0
|
||||
if [ -x /usr/libexec/changeguard-package ]; then /usr/libexec/changeguard-package preinst; exit $$?; fi
|
||||
if [ -x /usr/sbin/optimemachine_bin ] && [ -f /etc/optimemachine/config.json ]; then
|
||||
/usr/sbin/optimemachine_bin maintenance-check >/dev/null || exit 1
|
||||
touch /var/run/changeguard-package-upgrade
|
||||
if /etc/init.d/optimemachine enabled; then touch /var/run/optimemachine-package-enable; fi
|
||||
if /usr/sbin/optimemachine_bin status --config /etc/optimemachine/config.json >/dev/null 2>&1; then
|
||||
touch /var/run/optimemachine-package-restart
|
||||
/etc/init.d/optimemachine stop || exit 1
|
||||
fi
|
||||
/usr/sbin/optimemachine_bin maintenance-check --config /etc/optimemachine/config.json >/dev/null || exit 1
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
define Package/changeguard/postinst
|
||||
#!/bin/sh
|
||||
IPKG_INSTROOT="$${IPKG_INSTROOT:-}" "$${IPKG_INSTROOT:-}/usr/libexec/changeguard-package" postinst
|
||||
endef
|
||||
|
||||
define Package/changeguard/prerm
|
||||
#!/bin/sh
|
||||
IPKG_INSTROOT="$${IPKG_INSTROOT:-}" "$${IPKG_INSTROOT:-}/usr/libexec/changeguard-package" prerm
|
||||
endef
|
||||
|
||||
define Package/changeguard/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/changeguard_bin $(1)/usr/sbin/changeguard_bin
|
||||
$(CP) ./files/* $(1)/
|
||||
endef
|
||||
$(eval $(call BuildPackage,changeguard))
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
START=15
|
||||
STOP=89
|
||||
USE_PROCD=1
|
||||
BIN=/usr/sbin/changeguard_bin
|
||||
CONFIG=/etc/changeguard/config.json
|
||||
[ -e "$CONFIG" ] || { [ ! -e /etc/optimemachine/config.json ] || CONFIG=/etc/optimemachine/config.json; }
|
||||
case "$action" in
|
||||
stop|restart|reload|disable)
|
||||
if [ -f "$CONFIG" ]; then "$BIN" maintenance-check --config "$CONFIG" --phase "$action" >/dev/null || exit 1; fi
|
||||
;;
|
||||
esac
|
||||
start_service() {
|
||||
"$BIN" initialize --config "$CONFIG" >/dev/null || return 1
|
||||
procd_open_instance
|
||||
procd_set_param command "$BIN" serve --config "$CONFIG"
|
||||
procd_set_param respawn 3600 5 0
|
||||
procd_set_param stdout 1
|
||||
procd_set_param stderr 1
|
||||
procd_set_param file "$CONFIG"
|
||||
procd_close_instance
|
||||
}
|
||||
boot() {
|
||||
"$BIN" initialize --config "$CONFIG" >/dev/null || return 1
|
||||
"$BIN" boot-recover --config "$CONFIG" || logger -t changeguard 'early recovery needs attention; inspect boot-status'
|
||||
start
|
||||
}
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec /usr/sbin/changeguard_bin "$@"
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
root="${IPKG_INSTROOT:-}"
|
||||
phase=${1:-}
|
||||
entries() {
|
||||
cat <<'ENTRIES'
|
||||
/usr/share/linkease/apps.d/25-optimemachine.json
|
||||
/usr/share/linkeasefull/desktop-apps.d/25-optimemachine.json
|
||||
/usr/share/luci/menu.d/luci-app-optimemachine.json
|
||||
/www/luci-static/resources/view/optimemachine.js
|
||||
/usr/share/rpcd/acl.d/optimemachine.json
|
||||
/usr/share/optimemachine/optimemachine-plugin.json
|
||||
/usr/share/optimemachine/www/desktop-entry.js
|
||||
/usr/share/optimemachine/www/logo.svg
|
||||
ENTRIES
|
||||
}
|
||||
owned() {
|
||||
path=$1
|
||||
if [ -L "$path" ]; then [ "$(readlink "$path")" = /usr/share/optimemachine/optimemachine-plugin.json ]; return; fi
|
||||
[ -f "$path" ] || return 1
|
||||
digest=$(sha256sum "$path"); digest=${digest%% *}
|
||||
case "$digest" in
|
||||
57dc596ed4c3616169eef67256cec0e300a9fa9f3f0a3b12804132cddc0ad685|7721fcd859bb7d82888d6211c9381ee266083fd13895c151a5121491d9fa4bff|9b15773d8513210d898993121e577029c674791b7a678e641e63bf1e1bb8abcb|b5e615a6038108de61cd5e518d535bcb4e2a298cd0f67532b6dec4d1462e4383|c7f26d5b0b60a0ee8b195cadf0de1626b8643aead51f3d3088da73418f9e98c3|d4544b2d9a1fbacc224ba8834cb351f10c636e9a269217a3b7214cb6b643e4e0) return 0 ;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
stash_custom() {
|
||||
entries | while IFS= read -r rel; do
|
||||
path="$root$rel"; saved="$root/etc/changeguard/migration$rel"
|
||||
if { [ -f "$path" ] || [ -L "$path" ]; } && ! owned "$path"; then
|
||||
umask 077; mkdir -p "${saved%/*}"; rm -f "$saved"; cp -Pp "$path" "$saved"; touch "$saved.pending"
|
||||
fi
|
||||
done
|
||||
}
|
||||
retire_entries() {
|
||||
for link in "$root"/etc/rc.d/[SK][0-9][0-9]optimemachine; do
|
||||
[ -L "$link" ] || continue
|
||||
case "$(readlink "$link")" in ../init.d/optimemachine|/etc/init.d/optimemachine) rm -f "$link" ;; esac
|
||||
done
|
||||
entries | while IFS= read -r rel; do
|
||||
path="$root$rel"; saved="$root/etc/changeguard/migration$rel"
|
||||
if owned "$path"; then rm -f "$path"; fi
|
||||
if [ -f "$saved.pending" ]; then
|
||||
if [ ! -e "$path" ] && [ ! -L "$path" ]; then mkdir -p "${path%/*}"; cp -Pp "$saved" "$path"; fi
|
||||
rm -f "$saved.pending"
|
||||
fi
|
||||
done
|
||||
}
|
||||
case "$phase" in
|
||||
preinst|prerm) stash_custom ;;
|
||||
postinst) retire_entries ;;
|
||||
*) exit 2 ;;
|
||||
esac
|
||||
[ -n "$root" ] && exit 0
|
||||
bin=/usr/sbin/changeguard_bin
|
||||
config=/etc/changeguard/config.json
|
||||
[ -e "$config" ] || { [ ! -e /etc/optimemachine/config.json ] || config=/etc/optimemachine/config.json; }
|
||||
run_checked() {
|
||||
response=$("$bin" "$@" --config "$config") || { printf '%s\n' "$response" >&2; return 1; }
|
||||
}
|
||||
case "$phase" in
|
||||
preinst|prerm)
|
||||
if [ -f "$config" ]; then "$bin" maintenance-check --config "$config" >/dev/null || exit 1; touch /var/run/changeguard-package-upgrade; fi
|
||||
if [ -x /etc/init.d/changeguard ] && /etc/init.d/changeguard enabled; then touch /var/run/changeguard-package-enable; fi
|
||||
if "$bin" status --config "$config" >/dev/null 2>&1; then
|
||||
touch /var/run/changeguard-package-restart
|
||||
/etc/init.d/changeguard stop || exit 1
|
||||
fi
|
||||
if [ -f "$config" ]; then "$bin" maintenance-check --config "$config" >/dev/null || exit 1; fi
|
||||
if [ "$phase" = prerm ]; then /etc/init.d/changeguard disable || exit 1; fi
|
||||
;;
|
||||
postinst)
|
||||
fresh=0
|
||||
if [ ! -f "$config" ]; then fresh=1; else run_checked maintenance-check || exit 1; fi
|
||||
if /etc/init.d/changeguard enabled; then touch /var/run/changeguard-package-enable; fi
|
||||
if "$bin" status --config "$config" >/dev/null 2>&1; then
|
||||
touch /var/run/changeguard-package-restart
|
||||
/etc/init.d/changeguard stop || exit 1
|
||||
fi
|
||||
run_checked initialize || exit 1
|
||||
run_checked sync-backend || exit 1
|
||||
run_checked refresh-runtime || exit 1
|
||||
if [ "$fresh" = 1 ] || [ -f /var/run/changeguard-package-enable ] || [ -f /var/run/optimemachine-package-enable ]; then /etc/init.d/changeguard enable || exit 1; fi
|
||||
if [ "$fresh" = 1 ] || [ -f /var/run/changeguard-package-restart ] || [ -f /var/run/optimemachine-package-restart ]; then /etc/init.d/changeguard start || exit 1; fi
|
||||
rm -f /var/run/changeguard-package-upgrade /var/run/changeguard-package-enable /var/run/changeguard-package-restart /var/run/optimemachine-package-enable /var/run/optimemachine-package-restart
|
||||
;;
|
||||
esac
|
||||
@@ -0,0 +1,3 @@
|
||||
# Local candidate; not publicly published.
|
||||
CHANGEGUARD_HASH_x86_64:=11dba6b05e0bb7479253ee083292b2f5e078ee395ec770a2128ac85a5e166886
|
||||
CHANGEGUARD_HASH_aarch64:=3f2ffbcf2b58a11953b76163cbb187225f2591c16f4e70e6a96a49c3d74896ff
|
||||
+11
-8
@@ -9,12 +9,12 @@ include $(TOPDIR)/rules.mk
|
||||
KAIPLUS_ARCH_x86_64:=amd64
|
||||
KAIPLUS_ARCH_aarch64:=arm64
|
||||
KAIPLUS_ARCH:=$(KAIPLUS_ARCH_$(ARCH))
|
||||
KAIPLUS_HASH_x86_64:=945d1bcd7871426a10a77089512328e01e1db292f5dafbcf4e5c6b38f5a15cce
|
||||
KAIPLUS_HASH_aarch64:=8ea9ce946e42f95b02f98749869d4990008d7221705beb51a9a90c00a1b00f83
|
||||
KAIPLUS_HASH_x86_64:=15773187b86183eb802b03b48d4dbeccf27d2ae849aea002cc9cb16efbfa0d2d
|
||||
KAIPLUS_HASH_aarch64:=4d1eeca6cfecca4742d9a7fb7b1c25a819c90d5c6ff9a188ed0eb25ee2b9b691
|
||||
|
||||
PKG_NAME:=kaiplus
|
||||
PKG_VERSION:=1.0.11
|
||||
PKG_RELEASE:=18
|
||||
PKG_VERSION:=1.0.15
|
||||
PKG_RELEASE:=19
|
||||
|
||||
KAIPLUS_URL_FILE:=kaiplus-linux-$(KAIPLUS_ARCH)
|
||||
KAIPLUS_DOWNLOAD:=$(KAIPLUS_URL_FILE)-$(KAIPLUS_HASH_$(ARCH))
|
||||
@@ -28,7 +28,7 @@ RSTRIP:=:
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Download/kaiplus
|
||||
URL:=https://fw.koolcenter.com/binary/kai/releases/build/
|
||||
URL:=https://github.com/istoreos/istoreos-app-hub/releases/download/kaiplus-runtime-v$(PKG_VERSION)/
|
||||
URL_FILE:=$(KAIPLUS_URL_FILE)
|
||||
FILE:=$(KAIPLUS_DOWNLOAD)
|
||||
HASH:=skip
|
||||
@@ -40,7 +40,7 @@ define Package/$(PKG_NAME)
|
||||
SUBMENU:=
|
||||
TITLE:=KaiPlus
|
||||
URL:=https://github.com/linkease/istore-packages
|
||||
DEPENDS:=@(x86_64||aarch64) +linkease-app-entry
|
||||
DEPENDS:=@(x86_64||aarch64) +linkease-app-entry +changeguard
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
@@ -48,6 +48,7 @@ define Package/$(PKG_NAME)/description
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
/etc/init.d/kaiplus
|
||||
/etc/config/kaiplus
|
||||
endef
|
||||
|
||||
@@ -88,10 +89,12 @@ define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/sbin $(1)/usr/share/kaiplus $(1)/usr/share/linkease/apps.d $(1)/etc/init.d $(1)/etc/config
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/kaiplus $(1)/usr/sbin/kaiplus
|
||||
$(INSTALL_DIR) $(1)/usr/sbin $(1)/usr/share/kaiplus $(1)/usr/share/linkease/apps.d $(1)/usr/share/rpcd/acl.d $(1)/etc/init.d $(1)/etc/config
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/kaiplus $(1)/usr/sbin/kaiplus_bin
|
||||
ln -sf kaiplus_bin $(1)/usr/sbin/kaiplus
|
||||
$(INSTALL_DATA) ./files/logo.png $(1)/usr/share/kaiplus/logo.png
|
||||
$(INSTALL_DATA) ./files/kaiplus-plugin.json $(1)/usr/share/kaiplus/kaiplus-plugin.json
|
||||
$(INSTALL_DATA) ./files/kaiplus.json $(1)/usr/share/rpcd/acl.d/kaiplus.json
|
||||
ln -sf /usr/share/kaiplus/kaiplus-plugin.json $(1)/usr/share/linkease/apps.d/00-kaiplus-plugin.json
|
||||
$(INSTALL_BIN) ./files/kaiplus.init $(1)/etc/init.d/kaiplus
|
||||
$(INSTALL_CONF) ./files/kaiplus.config $(1)/etc/config/kaiplus
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"auth": { "mode": "passthrough" },
|
||||
"backend": {
|
||||
"type": "http",
|
||||
"scheme": "http",
|
||||
|
||||
@@ -34,6 +34,9 @@ start_service() {
|
||||
chmod 0700 "$data_dir/config" "$data_dir/state"
|
||||
|
||||
logger -t kaiplus "Starting KaiPlus service"
|
||||
if ! pidof changeguard_bin >/dev/null; then
|
||||
/etc/init.d/changeguard enable && /etc/init.d/changeguard start || return 1
|
||||
fi
|
||||
procd_open_instance kaiplus
|
||||
procd_set_param env \
|
||||
KAIPLUS_HOME="$data_dir" \
|
||||
@@ -43,7 +46,7 @@ start_service() {
|
||||
LINKEASE_AUTH_PROVIDER="openwrt_luci" \
|
||||
KAIPLUS_LISTEN_MODE="tcp" \
|
||||
REASONIX_CREDENTIALS_STORE="file"
|
||||
procd_set_param command /usr/sbin/kaiplus kaiplus-web
|
||||
procd_set_param command /usr/sbin/kaiplus_bin kaiplus-web
|
||||
procd_append_param command --listen-mode tcp
|
||||
procd_append_param command --addr "0.0.0.0:$port"
|
||||
procd_append_param command --data-dir "$data_dir"
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"kaiplus": {
|
||||
"description": "KaiPlus administrator tools on this device",
|
||||
"read": { "ubus": { "system": ["board"] } },
|
||||
"write": { "ubus": { "session": ["access"] } }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
PKG_NAME:=linkspace
|
||||
PKG_VERSION:=0.3.0-cg1
|
||||
PKG_RELEASE:=1
|
||||
include ./release.mk
|
||||
PKG_SOURCE:=linkspace-$(PKG_VERSION)-$(ARCH).tar.gz
|
||||
PKG_SOURCE_URL?=https://fw.koolcenter.com/binary/linkspace/releases/
|
||||
PKG_HASH:=skip
|
||||
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
|
||||
PKG_BUILD_PARALLEL:=1
|
||||
STRIP:=true
|
||||
RSTRIP:=:
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/linkspace
|
||||
SECTION:=admin
|
||||
CATEGORY:=System
|
||||
TITLE:=Linkspace backup engine
|
||||
DEPENDS:=@(x86_64||aarch64)
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/linkspace/preinst
|
||||
#!/bin/sh
|
||||
[ -n "$${IPKG_INSTROOT:-}" ] && exit 0
|
||||
if [ -x /usr/libexec/changeguard-package ]; then /usr/libexec/changeguard-package preinst; exit $$?; fi
|
||||
if [ -x /usr/sbin/optimemachine_bin ] && [ -f /etc/optimemachine/config.json ]; then
|
||||
/usr/sbin/optimemachine_bin maintenance-check >/dev/null || exit 1
|
||||
if /etc/init.d/optimemachine enabled; then touch /var/run/optimemachine-package-enable; fi
|
||||
if [ -S /var/run/optimemachine.sock ]; then touch /var/run/optimemachine-package-restart; /etc/init.d/optimemachine stop || exit 1; fi
|
||||
/usr/sbin/optimemachine_bin maintenance-check >/dev/null || { /etc/init.d/optimemachine start; exit 1; }
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
define Package/linkspace/prerm
|
||||
#!/bin/sh
|
||||
[ -n "$${IPKG_INSTROOT:-}" ] && exit 0
|
||||
if [ -x /usr/libexec/changeguard-package ]; then /usr/libexec/changeguard-package preinst; exit $$?; fi
|
||||
if [ -x /usr/sbin/optimemachine_bin ] && [ -f /etc/optimemachine/config.json ]; then
|
||||
/usr/sbin/optimemachine_bin maintenance-check >/dev/null || exit 1
|
||||
if [ -S /var/run/optimemachine.sock ]; then touch /var/run/optimemachine-package-restart; /etc/init.d/optimemachine stop || exit 1; fi
|
||||
/usr/sbin/optimemachine_bin maintenance-check >/dev/null || { /etc/init.d/optimemachine start; exit 1; }
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
define Package/linkspace/postinst
|
||||
#!/bin/sh
|
||||
[ -n "$${IPKG_INSTROOT:-}" ] && exit 0
|
||||
if [ -x /usr/libexec/changeguard-package ]; then /usr/libexec/changeguard-package postinst; exit $$?; fi
|
||||
if [ -x /usr/sbin/optimemachine_bin ] && [ -f /etc/optimemachine/config.json ]; then
|
||||
if ! /usr/sbin/optimemachine_bin capabilities | grep -q '"backendDescriptorV2":true'; then
|
||||
logger -t optimemachine "Linkspace updated; complete coordinated optimemachine upgrade before restarting protection"
|
||||
exit 0
|
||||
fi
|
||||
/usr/sbin/optimemachine_bin sync-backend >/dev/null || exit 1
|
||||
if [ -f /var/run/optimemachine-package-enable ]; then /etc/init.d/optimemachine enable; rm -f /var/run/optimemachine-package-enable; fi
|
||||
if [ -f /var/run/optimemachine-package-restart ]; then /etc/init.d/optimemachine start || exit 1; rm -f /var/run/optimemachine-package-restart; fi
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
define Package/linkspace/install
|
||||
$(INSTALL_DIR) $(1)/usr/bin $(1)/usr/share/linkspace
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/linkspace $(1)/usr/bin/linkspace
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/dependency.json $(1)/usr/share/linkspace/dependency.json
|
||||
endef
|
||||
$(eval $(call BuildPackage,linkspace))
|
||||
@@ -0,0 +1,3 @@
|
||||
# Local candidate; not publicly published.
|
||||
LINKSPACE_HASH_x86_64:=b6f2de26c0e2d146440486377036bfb9385d009def4ace01d3a2f39be4c96ab3
|
||||
LINKSPACE_HASH_aarch64:=3edbba641ac9145f6c8f2da15ebf14d6bfe4e6d0f389e5f1a894bdc8b18ddadb
|
||||
@@ -6,12 +6,12 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=LuCI support for IPSec VPN Server (IKEv1 with PSK and Xauth)
|
||||
LUCI_DEPENDS:=+strongswan +strongswan-minimal +strongswan-mod-xauth-generic +strongswan-mod-kernel-libipsec +strongswan-mod-des +kmod-tun
|
||||
LUCI_DEPENDS:=+strongswan +strongswan-minimal +strongswan-default +strongswan-mod-kernel-libipsec +kmod-tun
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
PKG_NAME:=luci-app-ipsec-vpnd
|
||||
PKG_VERSION:=27.906.25.12
|
||||
PKG_RELEASE:=4
|
||||
PKG_RELEASE:=5
|
||||
|
||||
define Package/luci-app-ipsec-vpnd/conffiles
|
||||
/etc/config/ipsec-vpnd
|
||||
|
||||
@@ -91,6 +91,20 @@ IKEv2 支持 MOBIKE:手机 Wi-Fi ↔ 蜂窝切换时在协议内更新地址
|
||||
> 生成/分发证书,所以继续用 IKEv1(Cisco IPSec)+ 账号密码,或接受 IKEv2 仅 PSK。
|
||||
> 在路由上等价于:`uci set ipsec-vpnd.ipsec.ikev2=1 && uci commit ipsec-vpnd`,再在 LuCI 里保存一次(触发 apply)。
|
||||
|
||||
## IKEv1 是可选能力(strongSwan 6.1 起默认关闭)
|
||||
|
||||
本包渲染前会检查 `/etc/strongswan.d/charon/xauth-generic.conf`:
|
||||
|
||||
- **存在**:生成 `conn xauth_psk`(IKEv1 + PSK + XAuth)和可选的 `conn ikev2_psk`;
|
||||
- **不存在**(例如 strongSwan 6.1 未用 `--enable-ikev1` 编译):**只生成 IKEv2 conn**,不再因为缺 xauth 插件而整体失败;LuCI 依赖面板会用「可选/警告」提示,而不是红色错误;
|
||||
- 如果既没有 IKEv1 也没启用 IKEv2,render 会拒绝生成配置并写日志,避免服务起来却谁都不能连。
|
||||
|
||||
> **对 iPhone 用户**:iOS 的「Cisco IPSec」配置走 IKEv1 + XAuth。如果系统 strongSwan 不带 IKEv1,这个配置会连不上;请改用「IKEv2 + 共享密钥」配置(本包 r19 起支持)。纯 IKEv2 环境不受影响。
|
||||
|
||||
### 安全提示
|
||||
|
||||
strongSwan 6.0.7 的后续版本(6.1.0 / 发行版 backport)修复了 11 个 CVE,其中包含 IKEv2 的认证绕过与 rekey use-after-free。装好系统后先确认包版本里带了补丁(例如 OpenWrt snapshot 的 `6.0.7-r13` 已包含,部分稳定版仍是 `-r1`);长期停留在未打补丁的 `-r1` 不建议。
|
||||
|
||||
## 稳定性与漫游(服务端行为)
|
||||
|
||||
| 机制 | 值 | 作用 |
|
||||
@@ -111,9 +125,10 @@ IKEv2 支持 MOBIKE:手机 Wi-Fi ↔ 蜂窝切换时在协议内更新地址
|
||||
| 包 | 作用 |
|
||||
|---|---|
|
||||
| `strongswan-minimal` | strongSwan 最小集,含 charon、starter(`/usr/lib/ipsec/starter`)、stroke 插件 |
|
||||
| `strongswan-mod-xauth-generic` | XAuth 账号认证插件,缺它 XAuth 账号无法登录 |
|
||||
| `strongswan-mod-kernel-libipsec` | 内核态 IPsec |
|
||||
| `strongswan-mod-des` | 3DES 加密插件,缺它本包声明的 3DES 提案不可用(老版本 iOS/Android 客户端需要) |
|
||||
| `strongswan-default` | strongSwan 默认插件集(6.0.x 含 xauth-generic/des,保证 IKEv1 可用;6.1 的打包会按自身能力调整) |
|
||||
| `strongswan-mod-xauth-generic` | **可选**(由 `strongswan-default` 间接引入)。6.1 起 strongSwan 默认关闭 IKEv1,该插件可能不存在,此时只提供 IKEv2 |
|
||||
| `strongswan-mod-kernel-libipsec` | 内核态 IPsec(必需) |
|
||||
| `strongswan-mod-des` | **可选**。3DES 加密插件,缺它只影响 3DES 回退,AES 不受影响 |
|
||||
| `kmod-tun` | TUN/TAP 设备 |
|
||||
|
||||
> `strongswan-mod-stroke` 会连带装上 `strongswan-ipsec`(提供 `/usr/sbin/ipsec` 命令与系统自带的 `ipsec` 服务)。
|
||||
@@ -280,6 +295,7 @@ GNU 环境,所以改完记得也在设备上跑一遍:busybox 的 `tr` 不
|
||||
| GitHub Actions 出包失败 | 看 `Build` workflow 的 step 日志;常见是 host 工具链 apt 装失败、或 apk-tools/po2lmo 编译报错 |
|
||||
| 手机切网后显示"已连接"但打不开网页 | IKEv1 没有 MOBIKE,切网必然断;改用 IKEv2 配置(页面开启 `ikev2`),或等 DPD(约 150s)清掉旧 SA 后让客户端重连。`ipsec statusall` 能看到是否残留旧 SA |
|
||||
| 网页能开,视频/大文件卡住 | 检查 MSS clamp 是否生效:`nft list ruleset \| grep ipsec0` 应有两条 maxseg;没有就 `uci set firewall.VPN.mtu_fix=1 && uci commit firewall && fw4 reload` |
|
||||
| 依赖面板提示 IKEv1 不可用 | 系统 strongSwan 缺 `xauth-generic`(6.1 默认关闭 IKEv1)。IKEv2 不受影响;需要 IKEv1 就换回带 IKEv1 的 strongSwan 构建,或改用 IKEv2 客户端 |
|
||||
| 升级后 IKEv2 开关没有/不生效 | `uci get ipsec-vpnd.ipsec.ikev2`(默认 `0`);在 LuCI 勾选「启用 IKEv2」并保存应用,渲染器会加 `conn ikev2_psk` 并重启 ipsec |
|
||||
|
||||
## 许可证
|
||||
|
||||
@@ -109,28 +109,44 @@ return view.extend({
|
||||
s.anonymous = true;
|
||||
s.render = function() {
|
||||
let box = E('div', { class: 'cbi-section-error' });
|
||||
let wrap = E('div', { id: 'ipsec_vpnd_deps_wrap', style: 'display:none' }, [ box ]);
|
||||
let warn = E('div', { class: 'cbi-section-note' });
|
||||
let wrap = E('div', { id: 'ipsec_vpnd_deps_wrap', style: 'display:none' }, [ box, warn ]);
|
||||
|
||||
let update = function() {
|
||||
return L.resolveDefault(callIpsecDeps(), {}).then(function(res) {
|
||||
let files = (res && Array.isArray(res.files)) ? res.files : [];
|
||||
let missing = files.filter(function(d) { return d.status !== 'ok'; });
|
||||
if (missing.length === 0) {
|
||||
let missing = files.filter(function(d) { return d.status === 'missing'; });
|
||||
let optional = files.filter(function(d) { return d.status === 'optional'; });
|
||||
if (missing.length === 0 && optional.length === 0) {
|
||||
wrap.style.display = 'none';
|
||||
return;
|
||||
}
|
||||
wrap.style.display = '';
|
||||
box.textContent = '';
|
||||
box.appendChild(E('h3', {}, _('Missing dependencies')));
|
||||
missing.forEach(function(d) {
|
||||
box.appendChild(E('p', {}, d.detail || d.key));
|
||||
});
|
||||
box.appendChild(E('p', {}, _('Install the missing packages with:')));
|
||||
warn.textContent = '';
|
||||
let mgr = (res && res.pkg_mgr === 'opkg') ? 'opkg' : 'apk';
|
||||
let cmd = (mgr === 'opkg')
|
||||
? 'opkg update && opkg install strongswan-minimal strongswan-mod-xauth-generic strongswan-mod-kernel-libipsec strongswan-mod-des'
|
||||
: 'apk update && apk add strongswan-minimal strongswan-mod-xauth-generic strongswan-mod-kernel-libipsec strongswan-mod-des';
|
||||
box.appendChild(E('pre', {}, cmd));
|
||||
|
||||
if (missing.length > 0) {
|
||||
box.appendChild(E('h3', {}, _('Missing dependencies')));
|
||||
missing.forEach(function(d) {
|
||||
box.appendChild(E('p', {}, d.detail || d.key));
|
||||
});
|
||||
box.appendChild(E('p', {}, _('Install the missing packages with:')));
|
||||
box.appendChild(E('pre', {}, (mgr === 'opkg')
|
||||
? 'opkg update && opkg install strongswan-minimal strongswan-mod-kernel-libipsec'
|
||||
: 'apk update && apk add strongswan-minimal strongswan-mod-kernel-libipsec'));
|
||||
}
|
||||
|
||||
if (optional.length > 0) {
|
||||
warn.appendChild(E('p', {}, _('IKEv1 is unavailable; IKEv2 still works.')));
|
||||
optional.forEach(function(d) {
|
||||
warn.appendChild(E('p', {}, d.detail || d.key));
|
||||
});
|
||||
warn.appendChild(E('p', {}, _('To enable IKEv1, install:')));
|
||||
warn.appendChild(E('pre', {}, (mgr === 'opkg')
|
||||
? 'opkg update && opkg install strongswan-mod-xauth-generic strongswan-mod-des'
|
||||
: 'apk update && apk add strongswan-mod-xauth-generic strongswan-mod-des'));
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -137,3 +137,11 @@ msgstr ""
|
||||
#: applications/luci-app-ipsec-vpnd/htdocs/luci-static/resources/view/ipsec-vpnd.js:171
|
||||
msgid "Adds an IKEv2 connection for the native iOS/Android IKEv2 client. It supports MOBIKE, so the phone keeps the tunnel while switching between Wi-Fi and cellular. It authenticates with the PSK only (no username/password), so use a strong PSK; existing IKEv1 clients are unaffected."
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-ipsec-vpnd/htdocs/luci-static/resources/view/ipsec-vpnd.js:141
|
||||
msgid "IKEv1 is unavailable; IKEv2 still works."
|
||||
msgstr ""
|
||||
|
||||
#: applications/luci-app-ipsec-vpnd/htdocs/luci-static/resources/view/ipsec-vpnd.js:146
|
||||
msgid "To enable IKEv1, install:"
|
||||
msgstr ""
|
||||
@@ -146,3 +146,11 @@ msgstr "启用 IKEv2(PSK + MOBIKE)"
|
||||
#: applications/luci-app-ipsec-vpnd/htdocs/luci-static/resources/view/ipsec-vpnd.js:171
|
||||
msgid "Adds an IKEv2 connection for the native iOS/Android IKEv2 client. It supports MOBIKE, so the phone keeps the tunnel while switching between Wi-Fi and cellular. It authenticates with the PSK only (no username/password), so use a strong PSK; existing IKEv1 clients are unaffected."
|
||||
msgstr "为 iOS/Android 原生 IKEv2 客户端增加一条 IKEv2 连接。它支持 MOBIKE,手机在 Wi-Fi 与蜂窝网络之间切换时可保持隧道。该连接仅用 PSK 认证(不再校验账号密码),请使用足够强的 PSK;原有 IKEv1 客户端不受影响。"
|
||||
|
||||
#: applications/luci-app-ipsec-vpnd/htdocs/luci-static/resources/view/ipsec-vpnd.js:141
|
||||
msgid "IKEv1 is unavailable; IKEv2 still works."
|
||||
msgstr "IKEv1 不可用,IKEv2 仍可正常使用。"
|
||||
|
||||
#: applications/luci-app-ipsec-vpnd/htdocs/luci-static/resources/view/ipsec-vpnd.js:146
|
||||
msgid "To enable IKEv1, install:"
|
||||
msgstr "如需启用 IKEv1,请安装:"
|
||||
@@ -100,6 +100,10 @@ EOF
|
||||
# 避免改名后覆盖本包自带配置(默认 enabled=0)
|
||||
[ -f "/etc/config/ipsec" ] && rm -f "/etc/config/ipsec"
|
||||
|
||||
# strongswan-default 会带 swanctl 服务;本包用 ipsec 服务托管 charon,
|
||||
# 两个都自启会抢 UDP 500/4500。
|
||||
[ -x /etc/init.d/swanctl ] && { /etc/init.d/swanctl stop >/dev/null 2>&1; /etc/init.d/swanctl disable >/dev/null 2>&1; }
|
||||
|
||||
# 记录初始化标记,避免升级时重复执行破坏性操作
|
||||
uci -q set ipsec-vpnd.ipsec.initialized='1'
|
||||
uci -q commit ipsec-vpnd
|
||||
|
||||
@@ -3,29 +3,38 @@
|
||||
#
|
||||
# luci-app-ipsec-vpnd 运行时依赖自检。
|
||||
#
|
||||
# 由两处共用:
|
||||
# - /etc/init.d/ipsec-vpnd:缺依赖时拒绝启动并写明确日志(避免只看到 NOT RUNNING)
|
||||
# 由三处共用:
|
||||
# - /usr/lib/ipsec/luci-ipsec-vpnd-render:渲染前检查「必需」依赖
|
||||
# - /usr/libexec/rpcd/ipsec-vpnd:LuCI 页面的依赖诊断面板
|
||||
# - 安装后/排障时手工执行
|
||||
#
|
||||
# 用法:
|
||||
# luci-ipsec-vpnd-deps files 文件类依赖检查(starter / charon / 插件)
|
||||
# luci-ipsec-vpnd-deps pkgs 软件包安装状态
|
||||
# luci-ipsec-vpnd-deps files 文件类检查(必需 + 可选)
|
||||
# luci-ipsec-vpnd-deps files-required 只检查必需文件(render 使用)
|
||||
# luci-ipsec-vpnd-deps pkgs 软件包安装状态(必需 + 可选)
|
||||
#
|
||||
# 输出格式(每行一条,'|' 分隔):
|
||||
# <key>|<status>|<detail>
|
||||
# status: ok | missing
|
||||
# detail: ok 时为路径或版本号;missing 时为处理建议
|
||||
# status: ok | missing | optional
|
||||
# missing = 必需项缺失,服务不可用
|
||||
# optional = 可选项缺失;IKEv2 仍可用,只影响 IKEv1/3DES
|
||||
# detail: ok 时为路径或版本号;缺失时为处理建议
|
||||
#
|
||||
# 退出码:全部就绪 0;存在缺失 1。
|
||||
# 退出码:仅必需项缺失时返回 1;可选项缺失返回 0。
|
||||
|
||||
PKGS="strongswan-minimal strongswan-charon strongswan-mod-stroke strongswan-mod-xauth-generic strongswan-mod-kernel-libipsec strongswan-mod-des kmod-tun"
|
||||
# 必需:所有协议都要用
|
||||
PKGS_REQUIRED="strongswan-minimal strongswan-charon strongswan-mod-stroke strongswan-mod-kernel-libipsec kmod-tun"
|
||||
# 可选:只影响 IKEv1(XAuth)与 3DES 回退;6.1 关闭 IKEv1 的构建没有这些包
|
||||
PKGS_OPTIONAL="strongswan-mod-xauth-generic strongswan-mod-des"
|
||||
|
||||
MISSING=0
|
||||
|
||||
check_file() {
|
||||
# $1=key $2=路径 $3=缺失时的处理建议
|
||||
# $1=key $2=路径 $3=缺失时的处理建议 $4=required|optional
|
||||
if [ -e "$2" ]; then
|
||||
printf '%s|ok|%s\n' "$1" "$2"
|
||||
elif [ "$4" = "optional" ]; then
|
||||
printf '%s|optional|%s\n' "$1" "$3"
|
||||
else
|
||||
MISSING=1
|
||||
printf '%s|missing|%s\n' "$1" "$3"
|
||||
@@ -33,16 +42,25 @@ check_file() {
|
||||
}
|
||||
|
||||
files() {
|
||||
local mode="${1:-all}"
|
||||
|
||||
check_file starter /usr/lib/ipsec/starter \
|
||||
"缺少 strongSwan 启动器 /usr/lib/ipsec/starter(由 strongswan-mod-stroke 提供,随 strongswan-minimal 一并安装)"
|
||||
"缺少 strongSwan 启动器 /usr/lib/ipsec/starter(由 strongswan-mod-stroke 提供,随 strongswan-minimal 一并安装)" \
|
||||
required
|
||||
check_file charon /usr/lib/ipsec/charon \
|
||||
"缺少 IKE 守护进程 /usr/lib/ipsec/charon(需安装 strongswan-charon)"
|
||||
check_file xauth /etc/strongswan.d/charon/xauth-generic.conf \
|
||||
"缺少 xauth-generic 插件(需安装 strongswan-mod-xauth-generic,否则 XAuth 账号无法认证)"
|
||||
"缺少 IKE 守护进程 /usr/lib/ipsec/charon(需安装 strongswan-charon)" \
|
||||
required
|
||||
check_file libipsec /etc/strongswan.d/charon/kernel-libipsec.conf \
|
||||
"缺少 kernel-libipsec 插件(需安装 strongswan-mod-kernel-libipsec)"
|
||||
"缺少 kernel-libipsec 插件(需安装 strongswan-mod-kernel-libipsec)" \
|
||||
required
|
||||
[ "$mode" = "required" ] && return 0
|
||||
|
||||
check_file xauth /etc/strongswan.d/charon/xauth-generic.conf \
|
||||
"缺少 xauth-generic 插件(需安装 strongswan-mod-xauth-generic);仅影响 IKEv1/XAuth,IKEv2 不受影响" \
|
||||
optional
|
||||
check_file des /etc/strongswan.d/charon/des.conf \
|
||||
"缺少 des 插件(需安装 strongswan-mod-des,否则本包声明的 3DES 提案不可用)"
|
||||
"缺少 des 插件(需安装 strongswan-mod-des);仅影响 3DES 回退,AES 不受影响" \
|
||||
optional
|
||||
}
|
||||
|
||||
# 取已安装包的版本号;apk 与 opkg 两种包管理器都支持
|
||||
@@ -55,7 +73,8 @@ pkg_version() {
|
||||
}
|
||||
|
||||
pkgs() {
|
||||
for p in $PKGS; do
|
||||
local p v
|
||||
for p in $PKGS_REQUIRED; do
|
||||
v="$(pkg_version "$p")"
|
||||
if [ -n "$v" ]; then
|
||||
printf '%s|ok|%s\n' "$p" "$v"
|
||||
@@ -64,12 +83,21 @@ pkgs() {
|
||||
printf '%s|missing|not installed\n' "$p"
|
||||
fi
|
||||
done
|
||||
for p in $PKGS_OPTIONAL; do
|
||||
v="$(pkg_version "$p")"
|
||||
if [ -n "$v" ]; then
|
||||
printf '%s|ok|%s\n' "$p" "$v"
|
||||
else
|
||||
printf '%s|optional|not installed (only needed for IKEv1 / 3DES)\n' "$p"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
case "${1:-files}" in
|
||||
files) files ;;
|
||||
files) files all ;;
|
||||
files-required) files required ;;
|
||||
pkgs) pkgs ;;
|
||||
*) files ;;
|
||||
*) files all ;;
|
||||
esac
|
||||
|
||||
exit $MISSING
|
||||
@@ -12,10 +12,11 @@
|
||||
|
||||
. "${IPKG_INSTROOT:-}/lib/functions.sh"
|
||||
|
||||
# 依赖自检:strongSwan 运行时不全时不要生成一份"看着能起、实际连不上"的配置,
|
||||
# 直接报错,由调用方(rpcd apply / postinst)把原因透出来。
|
||||
# 依赖自检:只拦「必需」项(starter/charon/kernel-libipsec)。
|
||||
# xauth-generic / des 是可选插件:6.1 默认关闭 IKEv1 的构建里没有 xauth-generic,
|
||||
# 这时仍应生成 IKEv2 配置,而不是整体失败。
|
||||
if [ -x /usr/lib/ipsec/luci-ipsec-vpnd-deps ]; then
|
||||
deps_out="$(/usr/lib/ipsec/luci-ipsec-vpnd-deps files)"
|
||||
deps_out="$(/usr/lib/ipsec/luci-ipsec-vpnd-deps files-required)"
|
||||
if [ $? -ne 0 ]; then
|
||||
oldifs="$IFS"
|
||||
IFS='
|
||||
@@ -26,13 +27,17 @@ if [ -x /usr/lib/ipsec/luci-ipsec-vpnd-deps ]; then
|
||||
esac
|
||||
done
|
||||
IFS="$oldifs"
|
||||
logger -t ipsec-vpnd "strongSwan 运行时不完整,未生成 ipsec.conf。请先 apk update,再安装 strongswan-minimal strongswan-mod-xauth-generic strongswan-mod-kernel-libipsec strongswan-mod-des"
|
||||
logger -t ipsec-vpnd "strongSwan 运行时不完整,未生成 ipsec.conf。请先 apk update,再安装 strongswan-minimal strongswan-mod-kernel-libipsec"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
config_load ipsec-vpnd
|
||||
|
||||
# IKEv1/XAuth 只在系统 strongSwan 带 xauth-generic 插件时可用。
|
||||
# 可用环境变量覆盖,便于离线测试。
|
||||
IKEV1_PLUGIN_CONF="${IKEV1_PLUGIN_CONF:-/etc/strongswan.d/charon/xauth-generic.conf}"
|
||||
|
||||
vt_enabled=0
|
||||
config_get vt_enabled "ipsec" "enabled" "0"
|
||||
|
||||
@@ -49,6 +54,18 @@ config_get vt_password "ipsec" "password" "$vt_password"
|
||||
config_get vt_secret "ipsec" "secret" "$vt_secret"
|
||||
config_get vt_ikev2 "ipsec" "ikev2" "$vt_ikev2"
|
||||
|
||||
vt_ikev1=1
|
||||
if [ ! -f "$IKEV1_PLUGIN_CONF" ]; then
|
||||
vt_ikev1=0
|
||||
logger -t ipsec-vpnd "未找到 xauth-generic 插件,IKEv1/XAuth 不可用;继续生成 IKEv2 配置"
|
||||
fi
|
||||
|
||||
# 两条路都没有时不生成配置,避免服务起来却谁都连不上。
|
||||
if [ "$vt_enabled" = "1" ] && [ "$vt_ikev1" = "0" ] && [ "$vt_ikev2" != "1" ]; then
|
||||
logger -t ipsec-vpnd "IKEv1 不可用且未启用 IKEv2,未生成 ipsec.conf"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 先写到临时文件,再和现有文件比对:内容没变就不动文件。
|
||||
# 这样 rpcd 的 apply 才知道要不要重启服务 —— 别的页面触发一次 apply
|
||||
# 不应该把正在跑的 VPN 连接踢掉。
|
||||
@@ -74,7 +91,8 @@ config setup
|
||||
EOF
|
||||
|
||||
if [ "$vt_enabled" = "1" ]; then
|
||||
cat >> "$TMP_CONF" <<EOF
|
||||
if [ "$vt_ikev1" = "1" ]; then
|
||||
cat >> "$TMP_CONF" <<EOF
|
||||
|
||||
conn xauth_psk
|
||||
keyexchange=ikev1
|
||||
@@ -96,6 +114,7 @@ conn xauth_psk
|
||||
dpdtimeout=150s
|
||||
dpdaction=clear
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [ "$vt_ikev2" = "1" ]; then
|
||||
# IKEv2 + MOBIKE:手机 Wi-Fi/4G 切换时在协议内更新地址,不必重握手。
|
||||
@@ -134,12 +153,17 @@ fi
|
||||
if [ "$vt_enabled" = "1" ]; then
|
||||
# secrets 含 PSK 与 XAUTH 密码,用 177 umask 创建并收紧权限,避免本地用户读取
|
||||
umask 177
|
||||
cat > "$TMP_SECRETS" <<EOF
|
||||
{
|
||||
cat <<EOF
|
||||
# /etc/ipsec.secrets - strongSwan IPsec secrets file
|
||||
# 由 luci-app-ipsec-vpnd 自动生成,请勿手工修改。
|
||||
: PSK "$vt_secret"
|
||||
$vt_account : XAUTH "$vt_password"
|
||||
EOF
|
||||
# IKEv1 不可用时不要留无用的 XAuth 凭据
|
||||
if [ "$vt_ikev1" = "1" ]; then
|
||||
printf '%s : XAUTH "%s"\n' "$vt_account" "$vt_password"
|
||||
fi
|
||||
} > "$TMP_SECRETS"
|
||||
umask 022
|
||||
else
|
||||
# 停用时清掉遗留的凭据,避免旧口令继续留在磁盘上
|
||||
|
||||
@@ -92,6 +92,9 @@ chmod 0755 "$TMP/bin/logger"
|
||||
PATH="$TMP/bin:$PATH"
|
||||
export PATH
|
||||
|
||||
# 默认模拟「有 xauth-generic 插件」的 6.0.x 环境;无 IKEv1 的用例会临时删掉它
|
||||
: > "$TMP/xauth-generic.conf"
|
||||
|
||||
# 渲染器里的绝对路径统统换成临时目录
|
||||
sed -e "s|/etc/ipsec.conf|$TMP/etc/ipsec.conf|g" \
|
||||
-e "s|/etc/ipsec.secrets|$TMP/etc/ipsec.secrets|g" \
|
||||
@@ -100,7 +103,8 @@ sed -e "s|/etc/ipsec.conf|$TMP/etc/ipsec.conf|g" \
|
||||
chmod 0755 "$TMP/render"
|
||||
|
||||
run_render() {
|
||||
TEST_UCI="$1" IPKG_INSTROOT="$TMP" "$TMP/render" >"$TMP/out" 2>&1
|
||||
TEST_UCI="$1" IPKG_INSTROOT="$TMP" IKEV1_PLUGIN_CONF="$TMP/xauth-generic.conf" \
|
||||
"$TMP/render" >"$TMP/out" 2>&1
|
||||
echo $?
|
||||
}
|
||||
|
||||
@@ -155,7 +159,44 @@ check "IKEv2 复用 clientip 地址池" "2" "$(grep -c '^ rightsourceip=10.9.8.1
|
||||
check "IKEv2 复用 clientdns" "2" "$(grep -c '^ rightdns=10.9.8.1$' "$TMP/etc/ipsec.conf")"
|
||||
check "IKEv2 不需要 EAP 凭据" "0" "$(count_matches ': EAP ' "$TMP/etc/ipsec.secrets")"
|
||||
|
||||
# --- 3. enabled=0 ----------------------------------------------------------
|
||||
# --- 3. 无 IKEv1 插件(6.1 关闭 IKEv1 的构建) ------------------------------
|
||||
rm -f "$TMP/xauth-generic.conf"
|
||||
cat > "$TMP/uci" <<'EOF'
|
||||
enabled=1
|
||||
clientip=10.9.8.10/24
|
||||
clientdns=10.9.8.1
|
||||
account=acc1
|
||||
password=pw1
|
||||
secret=psk1
|
||||
ikev2=1
|
||||
EOF
|
||||
|
||||
rc="$(run_render "$TMP/uci")"
|
||||
check "无 IKEv1 插件时渲染成功" "0" "$rc"
|
||||
check "无 IKEv1 插件时不生成 IKEv1 conn" "0" "$(count_matches '^conn xauth_psk$' "$TMP/etc/ipsec.conf")"
|
||||
check "无 IKEv1 插件时仍生成 IKEv2 conn" "1" "$(count_matches '^conn ikev2_psk$' "$TMP/etc/ipsec.conf")"
|
||||
check "无 IKEv1 插件时 secrets 不含 XAUTH" "0" "$(count_matches ': XAUTH ' "$TMP/etc/ipsec.secrets")"
|
||||
check "无 IKEv1 插件时 secrets 仍含 PSK" "1" "$(count_matches '^: PSK "psk1"$' "$TMP/etc/ipsec.secrets")"
|
||||
|
||||
# 无 IKEv1 且没启用 IKEv2:两条路都没有,必须失败且不写配置
|
||||
cat > "$TMP/uci" <<'EOF'
|
||||
enabled=1
|
||||
clientip=10.9.8.10/24
|
||||
clientdns=10.9.8.1
|
||||
account=acc1
|
||||
password=pw1
|
||||
secret=psk1
|
||||
ikev2=0
|
||||
EOF
|
||||
rm -f "$TMP/etc/ipsec.conf"
|
||||
rc="$(run_render "$TMP/uci")"
|
||||
check "无 IKEv1 且无 IKEv2 时拒绝渲染" "1" "$([ "$rc" != "0" ] && echo 1 || echo 0)"
|
||||
check "无可用协议时不生成 ipsec.conf" "0" "$([ -e "$TMP/etc/ipsec.conf" ] && echo 1 || echo 0)"
|
||||
|
||||
# 恢复插件,供后面的用例使用
|
||||
: > "$TMP/xauth-generic.conf"
|
||||
|
||||
# --- 4. enabled=0 ----------------------------------------------------------
|
||||
cat > "$TMP/uci" <<'EOF'
|
||||
enabled=0
|
||||
clientip=10.9.8.10/24
|
||||
@@ -185,7 +226,7 @@ EOF
|
||||
|
||||
cat > "$TMP/usr/lib/ipsec/luci-ipsec-vpnd-deps" <<'EOF'
|
||||
#!/bin/sh
|
||||
[ "$1" = "files" ] && echo "starter|missing|/usr/lib/ipsec/starter"
|
||||
[ "$1" = "files" ] || [ "$1" = "files-required" ] && echo "starter|missing|/usr/lib/ipsec/starter"
|
||||
exit 1
|
||||
EOF
|
||||
chmod 0755 "$TMP/usr/lib/ipsec/luci-ipsec-vpnd-deps"
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=KaiPlus
|
||||
PKG_VERSION:=1.0.11-r2
|
||||
PKG_RELEASE:=17
|
||||
PKG_VERSION:=1.0.11-r3
|
||||
PKG_RELEASE:=18
|
||||
LUCI_DEPENDS:=+kaiplus +luci-compat +luci-lib-taskd +luci-lib-linkeaseauth +linkease-app-entry
|
||||
LUCI_MINIFY_CSS:=0
|
||||
LUCI_MINIFY_JS:=0
|
||||
|
||||
@@ -58,7 +58,7 @@ function kaiplus_status()
|
||||
local sys = require "luci.sys"
|
||||
local uci = require("luci.model.uci").cursor()
|
||||
compat():legacy_status("kaiplus", {
|
||||
running = sys.call("pidof kaiplus >/dev/null") == 0,
|
||||
running = sys.call("pidof kaiplus kaiplus_bin >/dev/null") == 0,
|
||||
kai_installed = require("luci.model.kaiplus.classic").installed(),
|
||||
port = uci:get_first("kaiplus", "kaiplus", "port") or "8189",
|
||||
base_path = "/apps/kaiplus/",
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
"""Run with LUA_COMMAND='ssh root@192.168.30.7 lua -' when Lua is remote."""
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
import re
|
||||
import shlex
|
||||
import shutil
|
||||
import subprocess
|
||||
import unittest
|
||||
|
||||
|
||||
APP = Path(__file__).resolve().parents[1]
|
||||
|
||||
|
||||
class ServiceStatusTest(unittest.TestCase):
|
||||
def test_real_controller_and_status_button_for_both_binary_names(self):
|
||||
command = os.environ.get("LUA_COMMAND")
|
||||
if not command:
|
||||
lua = shutil.which("lua5.1") or shutil.which("lua")
|
||||
if not lua:
|
||||
self.skipTest("Lua 5.1 required; set LUA_COMMAND for SSH")
|
||||
command = shlex.quote(lua) + " -"
|
||||
controller = (APP / "luasrc/controller/kaiplus.lua").read_text()
|
||||
self.assertNotIn("]====]", controller)
|
||||
harness = r'''
|
||||
local reply, processes
|
||||
package.loaded["luci.http"] = {}
|
||||
package.loaded["luci.dispatcher"] = {build_url = function() return "/auth" end}
|
||||
package.loaded["luci.model.linkease.apps_openwrt"] = {new = function() return {} end}
|
||||
package.loaded["luci.model.linkease.apps_compat"] = {new = function() return {
|
||||
legacy_status = function(_, id, fields) assert(id == "kaiplus"); reply = fields end
|
||||
} end}
|
||||
package.loaded["luci.model.uci"] = {cursor = function() return {
|
||||
get_first = function() return "8189" end, get = function() return "192.168.30.7" end
|
||||
} end}
|
||||
package.loaded["luci.model.kaiplus.classic"] = {installed = function() return false end}
|
||||
package.loaded["luci.sys"] = {call = function(cmd)
|
||||
local names = assert(cmd:match("^pidof (.-) >[ /%w]+$"), cmd)
|
||||
for name in names:gmatch("%S+") do if processes[name] then return 0 end end
|
||||
return 1
|
||||
end}
|
||||
local env = setmetatable({module = function() end}, {__index = _G})
|
||||
local chunk = assert(loadstring(source)); setfenv(chunk, env); chunk()
|
||||
for _, case in ipairs({
|
||||
{name="kaiplus_bin", processes={kaiplus_bin=true}, expected=true},
|
||||
{name="kaiplus", processes={kaiplus=true}, expected=true},
|
||||
{name="stopped", processes={}, expected=false},
|
||||
{name="classic-only", processes={kai_bin=true}, expected=false}
|
||||
}) do
|
||||
processes = case.processes; env.kaiplus_status()
|
||||
assert(reply.running == case.expected, case.name .. " reported " .. tostring(reply.running))
|
||||
print(tostring(reply.running))
|
||||
end
|
||||
'''
|
||||
result = subprocess.run(shlex.split(command), input="local source = [====[" + controller + "]====]\n" + harness,
|
||||
text=True, capture_output=True, timeout=30)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
states = [line == "true" for line in result.stdout.splitlines()]
|
||||
self.assertEqual(states, [True, True, False, False])
|
||||
|
||||
template = (APP / "luasrc/view/kaiplus/kaiplus_status.htm").read_text()
|
||||
script = re.search(r"<script[^>]*>(.*?)</script>", template, re.S).group(1)
|
||||
script = re.sub(r'<%=url\("([^"]+)"\)%>', r"/cgi-bin/luci/\1", script)
|
||||
script = re.sub(r"<%:([^%]+)%>", r"\1", script)
|
||||
self.assertNotIn("<%", script)
|
||||
browser = r'''
|
||||
const vm = require('node:vm'), assert = require('node:assert/strict');
|
||||
const elements = {'kaiplus_status': {}, 'kaiplus-open': {style: {}}};
|
||||
let poll;
|
||||
vm.runInNewContext(source, {
|
||||
XHR: {poll: (_, url, data, callback) => {poll = callback;}},
|
||||
document: {getElementById: id => elements[id]}
|
||||
});
|
||||
for (const running of states) {
|
||||
poll(null, {running, proxy_prefix_enabled: true, app_entry_running: true});
|
||||
assert.equal(elements['kaiplus-open'].style.display, running ? '' : 'none');
|
||||
assert.ok(elements.kaiplus_status.innerHTML.includes(running ? 'service is running.' : 'service is not running.'));
|
||||
assert.ok(elements.kaiplus_status.innerHTML.includes('LinkEase Desktop proxy.'));
|
||||
}
|
||||
'''
|
||||
result = subprocess.run(["node", "-e", "const source = " + json.dumps(script) + "; const states = " + json.dumps(states) + ";\n" + browser],
|
||||
text=True, capture_output=True, timeout=15)
|
||||
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -1,8 +1,8 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-open-box
|
||||
PKG_VERSION:=0.1.450
|
||||
PKG_RELEASE:=84
|
||||
PKG_VERSION:=0.1.451
|
||||
PKG_RELEASE:=85
|
||||
|
||||
PKG_MAINTAINER:=liandu2024
|
||||
PKG_LICENSE:=GPL-3.0-or-later
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
PKG_NAME:=luci-app-optimemachine
|
||||
PKG_VERSION:=0.3.0-cg1
|
||||
PKG_RELEASE:=1
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/luci-app-optimemachine
|
||||
SECTION:=admin
|
||||
CATEGORY:=System
|
||||
TITLE:=Legacy time machine UI retirement
|
||||
DEPENDS:=+changeguard
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/luci-app-optimemachine/preinst
|
||||
#!/bin/sh
|
||||
IPKG_INSTROOT="$${IPKG_INSTROOT:-}" "$${IPKG_INSTROOT:-}/usr/libexec/changeguard-package" preinst
|
||||
endef
|
||||
|
||||
define Package/luci-app-optimemachine/postinst
|
||||
#!/bin/sh
|
||||
IPKG_INSTROOT="$${IPKG_INSTROOT:-}" "$${IPKG_INSTROOT:-}/usr/libexec/changeguard-package" postinst
|
||||
endef
|
||||
|
||||
define Package/luci-app-optimemachine/install
|
||||
$(INSTALL_DIR) $(1)/usr/share/changeguard
|
||||
endef
|
||||
$(eval $(call BuildPackage,luci-app-optimemachine))
|
||||
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-passwall
|
||||
PKG_VERSION:=26.11.11
|
||||
PKG_RELEASE:=379
|
||||
PKG_RELEASE:=380
|
||||
PKG_PO_VERSION:=$(PKG_VERSION)
|
||||
|
||||
PKG_CONFIG_DEPENDS:= \
|
||||
|
||||
@@ -1437,22 +1437,24 @@ function gen_config(var)
|
||||
end
|
||||
|
||||
local valid_nodes = {}
|
||||
local valid_node_tags = {}
|
||||
for i = 1, #(ut_nodes or {}) do
|
||||
local ut_node_id = ut_nodes[i]
|
||||
local ut_node_tag = "ut-" .. ut_node_id
|
||||
local is_new_ut_node = true
|
||||
local outboundTag
|
||||
for _, outbound in ipairs(outbounds) do
|
||||
if string.sub(outbound.tag, 1, #ut_node_tag) == ut_node_tag then
|
||||
is_new_ut_node = false
|
||||
valid_nodes[#valid_nodes + 1] = outbound.tag
|
||||
outboundTag = outbound.tag
|
||||
break
|
||||
end
|
||||
end
|
||||
if is_new_ut_node then
|
||||
local outboundTag = gen_outbound_get_tag(flag, ut_node_id, ut_node_tag, { fragment = singbox_settings.fragment == "1" or nil, record_fragment = singbox_settings.record_fragment == "1" or nil })
|
||||
if outboundTag then
|
||||
valid_nodes[#valid_nodes + 1] = outboundTag
|
||||
end
|
||||
if not outboundTag then
|
||||
outboundTag = gen_outbound_get_tag(flag, ut_node_id, ut_node_tag, { fragment = singbox_settings.fragment == "1" or nil, record_fragment = singbox_settings.record_fragment == "1" or nil })
|
||||
end
|
||||
-- URLTest 组内的成员标签必须唯一,复用已有出站时也需要去重。
|
||||
if outboundTag and not valid_node_tags[outboundTag] then
|
||||
valid_node_tags[outboundTag] = true
|
||||
valid_nodes[#valid_nodes + 1] = outboundTag
|
||||
end
|
||||
end
|
||||
if #valid_nodes == 0 then return nil end
|
||||
|
||||
@@ -1156,22 +1156,24 @@ function gen_config(var)
|
||||
end
|
||||
|
||||
local valid_nodes = {}
|
||||
local valid_node_tags = {}
|
||||
for i = 1, #(blc_nodes or {}) do
|
||||
local blc_node_id = blc_nodes[i]
|
||||
local blc_node_tag = "blc-" .. blc_node_id
|
||||
local is_new_blc_node = true
|
||||
local outboundTag
|
||||
for _, outbound in ipairs(outbounds) do
|
||||
if string.sub(outbound.tag, 1, #blc_node_tag) == blc_node_tag then
|
||||
is_new_blc_node = false
|
||||
valid_nodes[#valid_nodes + 1] = outbound.tag
|
||||
outboundTag = outbound.tag
|
||||
break
|
||||
end
|
||||
end
|
||||
if is_new_blc_node then
|
||||
local outboundTag = gen_outbound_get_tag(flag, blc_node_id, blc_node_tag, { fragment = xray_settings.fragment == "1" or nil, noise = xray_settings.noise == "1" or nil })
|
||||
if outboundTag then
|
||||
valid_nodes[#valid_nodes + 1] = outboundTag
|
||||
end
|
||||
if not outboundTag then
|
||||
outboundTag = gen_outbound_get_tag(flag, blc_node_id, blc_node_tag, { fragment = xray_settings.fragment == "1" or nil, noise = xray_settings.noise == "1" or nil })
|
||||
end
|
||||
-- 每个成员标签只保留一次,复用已有出站时也需要去重。
|
||||
if outboundTag and not valid_node_tags[outboundTag] then
|
||||
valid_node_tags[outboundTag] = true
|
||||
valid_nodes[#valid_nodes + 1] = outboundTag
|
||||
end
|
||||
-- Check if balancing node duplicates fallback node
|
||||
if _node.fallback_node == blc_node_id then
|
||||
|
||||
@@ -246,6 +246,7 @@ do
|
||||
if true then
|
||||
local i = 0
|
||||
local option = "lbss"
|
||||
local usedNodes = {}
|
||||
local function is_ip_port(str)
|
||||
if type(str) ~= "string" then return false end
|
||||
local ip, port = str:match("^([%d%.]+):(%d+)$")
|
||||
@@ -254,9 +255,13 @@ do
|
||||
uci_foreach("haproxy_config", function(t)
|
||||
i = i + 1
|
||||
local node_id = t[option]
|
||||
-- 同一监听端口共用已选节点记录,避免多个后端替换成同一节点。
|
||||
local port = t.haproxy_port or ""
|
||||
usedNodes[port] = usedNodes[port] or {}
|
||||
CONFIG[#CONFIG + 1] = {
|
||||
log = true,
|
||||
id = t[".name"],
|
||||
usedNodes = usedNodes[port],
|
||||
remarks = "HAProxy负载均衡节点列表[" .. i .. "]",
|
||||
currentNode = node_id and uci_get(node_id) or nil,
|
||||
set = function(o, server)
|
||||
@@ -1889,6 +1894,20 @@ end
|
||||
local function select_node(nodes, config, parentConfig)
|
||||
if config.currentNode then
|
||||
local server
|
||||
if parentConfig and not parentConfig.usedNodes then parentConfig.usedNodes = {} end
|
||||
local usedNodes = parentConfig and parentConfig.usedNodes or config.usedNodes
|
||||
local current_id = config.currentNode[".name"] or config.currentNode.Socks
|
||||
-- 已用于替换其他旧节点的候选节点,不再参与本列表的匹配。
|
||||
if usedNodes then
|
||||
local available_nodes = {}
|
||||
for _, node in pairs(nodes) do
|
||||
local used_by = usedNodes[node[".name"]]
|
||||
if not used_by or used_by == current_id then
|
||||
available_nodes[#available_nodes + 1] = node
|
||||
end
|
||||
end
|
||||
nodes = available_nodes
|
||||
end
|
||||
-- 全局节点、acl节点、负载均衡、urltest中的 (Socks [端口]) 节点保持原id
|
||||
if config.currentNode["Socks"] then
|
||||
server = config.currentNode.Socks
|
||||
@@ -1985,7 +2004,7 @@ local function select_node(nodes, config, parentConfig)
|
||||
end
|
||||
end
|
||||
end
|
||||
if not parentConfig then
|
||||
if not parentConfig and not usedNodes then
|
||||
-- 还不行 随便找一个
|
||||
if not server then
|
||||
if #nodes_table > 0 then
|
||||
@@ -1997,11 +2016,15 @@ local function select_node(nodes, config, parentConfig)
|
||||
end
|
||||
end
|
||||
if server then
|
||||
if usedNodes then usedNodes[server] = current_id end
|
||||
if parentConfig then
|
||||
config.set(parentConfig, server)
|
||||
else
|
||||
config.set(config, server)
|
||||
end
|
||||
elseif usedNodes and config.delete then
|
||||
-- HAProxy 没有剩余匹配节点时,删除失效引用。
|
||||
config.delete(config)
|
||||
end
|
||||
else
|
||||
if not parentConfig then
|
||||
|
||||
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-passwall2
|
||||
PKG_VERSION:=26.11.11
|
||||
PKG_RELEASE:=180
|
||||
PKG_RELEASE:=181
|
||||
PKG_PO_VERSION:=$(PKG_VERSION)
|
||||
|
||||
PKG_CONFIG_DEPENDS:= \
|
||||
|
||||
@@ -1472,22 +1472,24 @@ function gen_config(var)
|
||||
ut_nodes = _node.urltest_node
|
||||
end
|
||||
local valid_nodes = {}
|
||||
local valid_node_tags = {}
|
||||
for i = 1, #(ut_nodes or {}) do
|
||||
local ut_node_id = ut_nodes[i]
|
||||
local ut_node_tag = "ut-" .. ut_node_id
|
||||
local is_new_ut_node = true
|
||||
local outboundTag
|
||||
for _, outbound in ipairs(outbounds) do
|
||||
if string.sub(outbound.tag, 1, #ut_node_tag) == ut_node_tag then
|
||||
is_new_ut_node = false
|
||||
valid_nodes[#valid_nodes + 1] = outbound.tag
|
||||
outboundTag = outbound.tag
|
||||
break
|
||||
end
|
||||
end
|
||||
if is_new_ut_node then
|
||||
local outboundTag = gen_outbound_get_tag(flag, ut_node_id, ut_node_tag, { fragment = singbox_settings.fragment == "1" or nil, record_fragment = singbox_settings.record_fragment == "1" or nil })
|
||||
if outboundTag then
|
||||
valid_nodes[#valid_nodes + 1] = outboundTag
|
||||
end
|
||||
if not outboundTag then
|
||||
outboundTag = gen_outbound_get_tag(flag, ut_node_id, ut_node_tag, { fragment = singbox_settings.fragment == "1" or nil, record_fragment = singbox_settings.record_fragment == "1" or nil })
|
||||
end
|
||||
-- Keep URLTest member tags unique, including reused outbounds.
|
||||
if outboundTag and not valid_node_tags[outboundTag] then
|
||||
valid_node_tags[outboundTag] = true
|
||||
valid_nodes[#valid_nodes + 1] = outboundTag
|
||||
end
|
||||
end
|
||||
if #valid_nodes == 0 then return nil end
|
||||
|
||||
@@ -1151,26 +1151,28 @@ function gen_config(var)
|
||||
blc_nodes = _node.balancing_node
|
||||
end
|
||||
local valid_nodes = {}
|
||||
local valid_node_tags = {}
|
||||
for i = 1, #(blc_nodes or {}) do
|
||||
local blc_node_id = blc_nodes[i]
|
||||
local blc_node_tag = "blc-" .. blc_node_id
|
||||
local is_new_blc_node = true
|
||||
local outboundTag
|
||||
for _, outbound in ipairs(outbounds) do
|
||||
if string.sub(outbound.tag, 1, #blc_node_tag) == blc_node_tag then
|
||||
is_new_blc_node = false
|
||||
valid_nodes[#valid_nodes + 1] = outbound.tag
|
||||
outboundTag = outbound.tag
|
||||
break
|
||||
end
|
||||
end
|
||||
if is_new_blc_node then
|
||||
local outboundTag = gen_outbound_get_tag(flag, blc_node_id, blc_node_tag, { fragment = xray_settings.fragment == "1" or nil, noise = xray_settings.noise == "1" or nil })
|
||||
if outboundTag then
|
||||
valid_nodes[#valid_nodes + 1] = outboundTag
|
||||
end
|
||||
-- Check if balancing node duplicates fallback node
|
||||
if _node.fallback_node == blc_node_id then
|
||||
_node.fallback_node = nil
|
||||
end
|
||||
if not outboundTag then
|
||||
outboundTag = gen_outbound_get_tag(flag, blc_node_id, blc_node_tag, { fragment = xray_settings.fragment == "1" or nil, noise = xray_settings.noise == "1" or nil })
|
||||
end
|
||||
-- Keep each member tag only once, including reused outbounds.
|
||||
if outboundTag and not valid_node_tags[outboundTag] then
|
||||
valid_node_tags[outboundTag] = true
|
||||
valid_nodes[#valid_nodes + 1] = outboundTag
|
||||
end
|
||||
-- Check if balancing node duplicates fallback node
|
||||
if _node.fallback_node == blc_node_id then
|
||||
_node.fallback_node = nil
|
||||
end
|
||||
end
|
||||
if #valid_nodes == 0 then return nil end
|
||||
|
||||
@@ -230,6 +230,7 @@ do
|
||||
if true then
|
||||
local i = 0
|
||||
local option = "lbss"
|
||||
local usedNodes = {}
|
||||
local function is_ip_port(str)
|
||||
if type(str) ~= "string" then return false end
|
||||
local ip, port = str:match("^([%d%.]+):(%d+)$")
|
||||
@@ -238,9 +239,13 @@ do
|
||||
uci_foreach("haproxy_config", function(t)
|
||||
i = i + 1
|
||||
local node_id = t[option]
|
||||
-- Share selected nodes within each listening port to avoid duplicate backends.
|
||||
local port = t.haproxy_port or ""
|
||||
usedNodes[port] = usedNodes[port] or {}
|
||||
CONFIG[#CONFIG + 1] = {
|
||||
log = true,
|
||||
id = t[".name"],
|
||||
usedNodes = usedNodes[port],
|
||||
remarks = i18n.translatef("HAProxy node list [%s]", i),
|
||||
currentNode = node_id and uci_get(node_id) or nil,
|
||||
set = function(o, server)
|
||||
@@ -1893,6 +1898,20 @@ local function select_node(nodes, config, parentConfig)
|
||||
end
|
||||
if config.currentNode then
|
||||
local server
|
||||
if parentConfig and not parentConfig.usedNodes then parentConfig.usedNodes = {} end
|
||||
local usedNodes = parentConfig and parentConfig.usedNodes or config.usedNodes
|
||||
local current_id = config.currentNode[".name"] or config.currentNode.Socks
|
||||
-- Exclude candidates already used to replace other old nodes in this list.
|
||||
if usedNodes then
|
||||
local available_nodes = {}
|
||||
for _, node in pairs(nodes) do
|
||||
local used_by = usedNodes[node[".name"]]
|
||||
if not used_by or used_by == current_id then
|
||||
available_nodes[#available_nodes + 1] = node
|
||||
end
|
||||
end
|
||||
nodes = available_nodes
|
||||
end
|
||||
-- Load balancing, keeping the original ID of the Socks [port] node in urltest.
|
||||
if config.currentNode["Socks"] then
|
||||
server = config.currentNode.Socks
|
||||
@@ -1989,7 +2008,7 @@ local function select_node(nodes, config, parentConfig)
|
||||
end
|
||||
end
|
||||
end
|
||||
if not parentConfig then
|
||||
if not parentConfig and not usedNodes then
|
||||
-- If that doesn't work, just find one.
|
||||
if not server then
|
||||
if #nodes_table > 0 then
|
||||
@@ -2001,11 +2020,15 @@ local function select_node(nodes, config, parentConfig)
|
||||
end
|
||||
end
|
||||
if server then
|
||||
if usedNodes then usedNodes[server] = current_id end
|
||||
if parentConfig then
|
||||
config.set(parentConfig, server)
|
||||
else
|
||||
config.set(config, server)
|
||||
end
|
||||
elseif usedNodes and config.delete then
|
||||
-- Delete stale HAProxy references when no matching candidates remain.
|
||||
config.delete(config)
|
||||
end
|
||||
else
|
||||
if not parentConfig then
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["luci-static/quickstart/FastnetInstallDialog.js","luci-static/quickstart/app.js","luci-static/quickstart/vendor.js","luci-static/quickstart/installClient.js"])))=>i.map(i=>d[i]);
|
||||
var kr=Object.defineProperty,wr=Object.defineProperties;var $r=Object.getOwnPropertyDescriptors;var ms=Object.getOwnPropertySymbols;var _l=Object.prototype.hasOwnProperty,yl=Object.prototype.propertyIsEnumerable;var fs=Math.pow,co=(s,t,n)=>t in s?kr(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n,ye=(s,t)=>{for(var n in t||(t={}))_l.call(t,n)&&co(s,n,t[n]);if(ms)for(var n of ms(t))yl.call(t,n)&&co(s,n,t[n]);return s},Ne=(s,t)=>wr(s,$r(t));var kl=(s,t)=>{var n={};for(var l in s)_l.call(s,l)&&t.indexOf(l)<0&&(n[l]=s[l]);if(s!=null&&ms)for(var l of ms(s))t.indexOf(l)<0&&yl.call(s,l)&&(n[l]=s[l]);return n};var Nn=(s,t,n)=>co(s,typeof t!="symbol"?t+"":t,n);var B=(s,t,n)=>new Promise((l,u)=>{var c=v=>{try{p(n.next(v))}catch(h){u(h)}},r=v=>{try{p(n.throw(v))}catch(h){u(h)}},p=v=>v.done?l(v.value):Promise.resolve(v.value).then(c,r);p((n=n.apply(s,t)).next())});import{defineComponent as X,computed as R,openBlock as i,createElementBlock as d,normalizeStyle as pt,createElementVNode as e,toDisplayString as a,unref as o,createCommentVNode as T,resolveComponent as At,createVNode as G,renderSlot as Ct,withDirectives as W,vModelCheckbox as gt,createBlock as Y,withCtx as pe,ref as x,watch as We,onMounted as nt,Fragment as V,renderList as oe,vModelSelect as Be,vModelText as Oe,createStaticVNode as Hn,shallowRef as Na,nextTick as ot,onUnmounted as lt,Teleport as Fo,withModifiers as Ge,normalizeClass as _e,withKeys as Qt,reactive as Xe,readonly as Cr,markRaw as Kn,onErrorCaptured as Sr,resolveDynamicComponent as Aa,mergeProps as Zl,inject as ba,Transition as fn,createApp as cn,createTextVNode as ue,provide as ma,TransitionGroup as xr,toRef as uo,onBeforeUnmount as ga,vShow as Bs,vModelRadio as Mt,createSlots as Pr,defineAsyncComponent as Tr,h as vo,isRef as Mr,Suspense as Er,render as Us,withAsyncContext as Ir,useCssVars as Dr,vModelDynamic as Lr}from"/luci-static/quickstart/card-runtime-v1.js";import{a as Ar,c as Nr,d as Fs,u as Yl,i as Or,b as zr,e as qr,f as Ql,g as Xl,h as Rr,j as ei,k as as,l as ta,o as ti,m as Vr,n as ss,p as Br,q as Ur,r as Fr}from"./vendor.js?v=B46K-l76";const Bn={language:void 0,numberFormat:new Intl.NumberFormat("en",{notation:"compact"})},tj=s=>B(null,null,function*(){const t=window.vue_lang||(navigator.language.toLowerCase().startsWith("zh")?"zh-cn":"en");let n={};const l=window.vue_lang_data||(t==="zh-cn"?"":`/luci-static/quickstart/i18n/${t}.json`);if(l)try{const r=yield Ar({url:l,method:"GET"});r.data&&(n=r.data)}catch(r){console.log(r)}const u=Nr({defaultLanguage:t,mutedLanguages:["zh-cn"],translations:n,setGlobalProperties:!1,provideDirective:!1,provideComponent:!1});s.use(u),Bn.language=u;const{$gettext:c}=u;window.$i18n=c;try{Bn.numberFormat=new Intl.NumberFormat(t,{notation:"compact"})}catch(r){console.error("Intl.NumberFormat unsupported lang",t,r)}}),Ae=()=>{if(Bn.language)return Bn.language;throw new Error("I18N Uninitialized!")},Hs=()=>({$gettext:(s,t,n)=>{if(Bn.language)return Bn.language.$gettext(s,t,n);throw new Error("I18N Uninitialized!")},$ngettext:(s,t,n,l,u)=>{if(Bn.language)return Bn.language.$ngettext(s,t,n,l,u);throw new Error("I18N Uninitialized!")}}),bs=s=>typeof s=="number"?Bn.numberFormat.format(s):"?",{$gettext:Hr}=Hs(),ni=(s,t)=>B(null,null,function*(){return new Promise((n,l)=>B(null,null,function*(){try{const u=yield fetch(s,t);if(Math.floor(u.status/100)!=2)throw u.status+" "+u.statusText;const c=ye({},u);c.data=yield u.json(),n(c)}catch(u){const c=u;l(Hr("网络异常:")+((c==null?void 0:c.message)||u))}}))});class Ho{constructor(t){Nn(this,"config",{baseURL:"",headers:{}});Nn(this,"useRequest",t=>t);Nn(this,"useResponse",t=>t);Nn(this,"useError",t=>t);t.baseURL&&(this.config.baseURL=t.baseURL),t.headers&&(this.config.headers=t.headers)}static create(t){return new Ho(t)}Do(t,n){return B(this,null,function*(){return new Promise((l,u)=>B(this,null,function*(){try{const c=this.useRequest({baseURL:this.config.baseURL,headers:this.config.headers});t=`${c.baseURL||""}${t}`,n.headers==null&&(n.headers={}),c.headers&&(n.headers=ye({},c.headers));const p=yield fetch(t,n),v=ye({},p);v.data=yield p.json(),l(this.useResponse(v))}catch(c){this.useError(c),u(c)}}))})}TEXT(t,n){return B(this,null,function*(){return new Promise((l,u)=>B(this,null,function*(){try{const c=this.useRequest({baseURL:this.config.baseURL,headers:this.config.headers});t=`${c.baseURL||""}${t}`,n.headers==null&&(n.headers={}),c.headers&&(n.headers=ye({},c.headers));const p=yield fetch(t,n),v=ye({},p);v.data=yield p.text(),l(v)}catch(c){this.useError(c),u(c)}}))})}interceptors(){const t=this;return{requset:{use(n){t.useRequest=n}},response:{use(n,l){t.useResponse=n,l&&(t.useError=l)}}}}}const ai=Ho.create({});ai.interceptors().requset.use((s=>s));ai.interceptors().response.use((s=>(s.data&&s.data.success==null&&s.data.success==0,s)));const{$gettext:si}=Hs(),Gr="/cgi-bin/luci/istore",jr="/cgi-bin/luci/admin";let Ms=!1;const Pe=(s,t)=>{if(!["GET","HEAD","OPTIONS"].includes((t.method||"GET").tLine truncated
|
||||
var kr=Object.defineProperty,wr=Object.defineProperties;var $r=Object.getOwnPropertyDescriptors;var ms=Object.getOwnPropertySymbols;var _l=Object.prototype.hasOwnProperty,yl=Object.prototype.propertyIsEnumerable;var fs=Math.pow,co=(s,t,n)=>t in s?kr(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n,ye=(s,t)=>{for(var n in t||(t={}))_l.call(t,n)&&co(s,n,t[n]);if(ms)for(var n of ms(t))yl.call(t,n)&&co(s,n,t[n]);return s},Ne=(s,t)=>wr(s,$r(t));var kl=(s,t)=>{var n={};for(var l in s)_l.call(s,l)&&t.indexOf(l)<0&&(n[l]=s[l]);if(s!=null&&ms)for(var l of ms(s))t.indexOf(l)<0&&yl.call(s,l)&&(n[l]=s[l]);return n};var Nn=(s,t,n)=>co(s,typeof t!="symbol"?t+"":t,n);var B=(s,t,n)=>new Promise((l,u)=>{var c=v=>{try{p(n.next(v))}catch(h){u(h)}},r=v=>{try{p(n.throw(v))}catch(h){u(h)}},p=v=>v.done?l(v.value):Promise.resolve(v.value).then(c,r);p((n=n.apply(s,t)).next())});import{defineComponent as X,computed as R,openBlock as i,createElementBlock as d,normalizeStyle as pt,createElementVNode as e,toDisplayString as a,unref as o,createCommentVNode as T,resolveComponent as At,createVNode as G,renderSlot as Ct,withDirectives as W,vModelCheckbox as gt,createBlock as Y,withCtx as pe,ref as x,watch as We,onMounted as nt,Fragment as V,renderList as oe,vModelSelect as Be,vModelText as Oe,createStaticVNode as Hn,shallowRef as Na,nextTick as ot,onUnmounted as lt,Teleport as Fo,withModifiers as Ge,normalizeClass as _e,withKeys as Qt,reactive as Xe,readonly as Cr,markRaw as Kn,onErrorCaptured as Sr,resolveDynamicComponent as Aa,mergeProps as Zl,inject as ba,Transition as fn,createApp as cn,createTextVNode as ue,provide as ma,TransitionGroup as xr,toRef as uo,onBeforeUnmount as ga,vShow as Bs,vModelRadio as Mt,createSlots as Pr,defineAsyncComponent as Tr,h as vo,isRef as Mr,Suspense as Er,render as Us,withAsyncContext as Ir,useCssVars as Dr,vModelDynamic as Lr}from"/luci-static/quickstart/card-runtime-v1.js";import{a as Ar,c as Nr,d as Fs,u as Yl,i as Or,b as zr,e as qr,f as Ql,g as Xl,h as Rr,j as ei,k as as,l as ta,o as ti,m as Vr,n as ss,p as Br,q as Ur,r as Fr}from"./vendor.js?v=B46K-l76";const Bn={language:void 0,numberFormat:new Intl.NumberFormat("en",{notation:"compact"})},tj=s=>B(null,null,function*(){const t=window.vue_lang||(navigator.language.toLowerCase().startsWith("zh")?"zh-cn":"en");let n={};const l=window.vue_lang_data||(t==="zh-cn"?"":`/luci-static/quickstart/i18n/${t}.json`);if(l)try{const r=yield Ar({url:l,method:"GET"});r.data&&(n=r.data)}catch(r){console.log(r)}const u=Nr({defaultLanguage:t,mutedLanguages:["zh-cn"],translations:n,setGlobalProperties:!1,provideDirective:!1,provideComponent:!1});s.use(u),Bn.language=u;const{$gettext:c}=u;window.$i18n=c;try{Bn.numberFormat=new Intl.NumberFormat(t,{notation:"compact"})}catch(r){console.error("Intl.NumberFormat unsupported lang",t,r)}}),Ae=()=>{if(Bn.language)return Bn.language;throw new Error("I18N Uninitialized!")},Hs=()=>({$gettext:(s,t,n)=>{if(Bn.language)return Bn.language.$gettext(s,t,n);throw new Error("I18N Uninitialized!")},$ngettext:(s,t,n,l,u)=>{if(Bn.language)return Bn.language.$ngettext(s,t,n,l,u);throw new Error("I18N Uninitialized!")}}),bs=s=>typeof s=="number"?Bn.numberFormat.format(s):"?",{$gettext:Hr}=Hs(),ni=(s,t)=>B(null,null,function*(){return new Promise((n,l)=>B(null,null,function*(){try{const u=yield fetch(s,t);if(Math.floor(u.status/100)!=2)throw u.status+" "+u.statusText;const c=ye({},u);c.data=yield u.json(),n(c)}catch(u){const c=u;l(Hr("网络异常:")+((c==null?void 0:c.message)||u))}}))});class Ho{constructor(t){Nn(this,"config",{baseURL:"",headers:{}});Nn(this,"useRequest",t=>t);Nn(this,"useResponse",t=>t);Nn(this,"useError",t=>t);t.baseURL&&(this.config.baseURL=t.baseURL),t.headers&&(this.config.headers=t.headers)}static create(t){return new Ho(t)}Do(t,n){return B(this,null,function*(){return new Promise((l,u)=>B(this,null,function*(){try{const c=this.useRequest({baseURL:this.config.baseURL,headers:this.config.headers});t=`${c.baseURL||""}${t}`,n.headers==null&&(n.headers={}),c.headers&&(n.headers=ye({},c.headers));const p=yield fetch(t,n),v=ye({},p);v.data=yield p.json(),l(this.useResponse(v))}catch(c){this.useError(c),u(c)}}))})}TEXT(t,n){return B(this,null,function*(){return new Promise((l,u)=>B(this,null,function*(){try{const c=this.useRequest({baseURL:this.config.baseURL,headers:this.config.headers});t=`${c.baseURL||""}${t}`,n.headers==null&&(n.headers={}),c.headers&&(n.headers=ye({},c.headers));const p=yield fetch(t,n),v=ye({},p);v.data=yield p.text(),l(v)}catch(c){this.useError(c),u(c)}}))})}interceptors(){const t=this;return{requset:{use(n){t.useRequest=n}},response:{use(n,l){t.useResponse=n,l&&(t.useError=l)}}}}}const ai=Ho.create({});ai.interceptors().requset.use((s=>s));ai.interceptors().response.use((s=>(s.data&&s.data.success==null&&s.data.success==0,s)));const{$gettext:si}=Hs(),Gr="/cgi-bin/luci/istore",jr="/cgi-bin/luci/admin";let Ms=!1;const Pe=(s,t)=>{if(!["GET","HEAD","OPTIONS"].includes((t.method||"GET").tLine truncated
|
||||
`+p.value+`
|
||||
`+c.value,disabled:""},null,8,pI)]),e("div",hI,[e("div",{class:"close",onClick:g,disabled:u.value},a(o(t)("关闭")),9,mI),u.value?T("",!0):(i(),d("div",{key:0,class:"next",onClick:b,disabled:u.value},a(o(t)("运行")),9,fI))])])]),_:1}))}}),gI=le(bI,[["__scopeId","data-v-3fabbd23"]]),_I={class:"actioner-container"},yI={class:"actioner-container_header"},kI={class:"tabs"},wI={class:"actioner-container_body"},$I={key:0,class:"table"},CI={class:"tr"},SI={class:"td left"},xI={class:"td left"},PI={class:"tr"},TI={class:"td left"},MI={class:"td left"},EI={class:"tr"},II={class:"td left"},DI={class:"td left"},LI=["value"],AI=["value"],NI=["value"],OI={class:"actioner-container_footer"},zI=["disabled"],qI=X({__name:"disk-info",props:{close:{type:Function,required:!0},disk:{type:Object,required:!0}},setup(s){const{$gettext:t,$ngettext:n}=Ae(),l=s,u=x(!1),c=x("info"),r=m=>{switch(c.value=m,m){case"info":break;case"attribute":g();break;case"log":h();break;case"extend":b();break}},p=()=>{u.value=!0,l.close()},v=Xe({log:"",attribute:"",extend:""}),h=()=>B(null,null,function*(){try{const m=yield we.Smart.Test.Result.POST({type:"selftest",devicePath:l.disk.path||""});if(m.data){const{result:f,error:k}=m.data;f&&f.result&&(v.log=f.result),k&&(v.log=k)}}catch(m){v.log=m}}),g=()=>B(null,null,function*(){try{const m=yield we.Smart.Attribute.Result.POST({devicePath:l.disk.path||""});if(m.data){const{result:f,error:k}=m.data;f&&f.result&&(v.attribute=f.result),k&&(v.attribute=k)}}catch(m){v.attribute=m}}),b=()=>B(null,null,function*(){try{const m=yield we.Smart.Extend.Result.POST({devicePath:l.disk.path||""});if(m.data){const{result:f,error:k}=m.data;f&&f.result&&(v.extend=f.result),k&&(v.extend=k)}}catch(m){v.extend=m}});return(m,f)=>(i(),Y(Xs,null,{default:pe(()=>[e("div",_I,[e("div",yI,[e("ul",kI,[e("li",{class:_e({"active cbi-tab":c.value=="info"}),onClick:f[0]||(f[0]=k=>r("info"))},[e("a",null,a(o(t)("设备信息")),1)],2),e("li",{class:_e({"active cbi-tab":c.value=="attribute"}),onClick:f[1]||(f[1]=k=>r("attribute"))},[e("a",null,a(o(t)("属性")),1)],2),e("li",{class:_e({"active cbi-tab":c.value=="log"}),onClick:f[2]||(f[2]=k=>r("log"))},[e("a",null,a(o(t)("自检日志")),1)],2),e("li",{class:_e({"active cbi-tab":c.value=="extend"}),onClick:f[3]||(f[3]=k=>r("extend"))},[e("a",null,a(o(t)("扩展信息")),1)],2)])]),e("div",wI,[c.value=="info"?(i(),d("table",$I,[e("tr",CI,[e("td",SI,a(o(t)("设备")),1),e("td",xI,a(s.disk.path),1)]),e("tr",PI,[e("td",TI,a(o(t)("型号")),1),e("td",MI,a(s.disk.model),1)]),e("tr",EI,[e("td",II,a(o(t)("序号")),1),e("td",DI,a(s.disk.serial),1)])])):c.value=="attribute"?(i(),d("textarea",{key:1,disabled:"",value:v.attribute},null,8,LI)):c.value=="log"?(i(),d("textarea",{key:2,disabled:"",value:v.log},null,8,AI)):c.value=="extend"?(i(),d("textarea",{key:3,disabled:"",value:v.extend},null,8,NI)):T("",!0)]),e("div",OI,[e("div",{class:"close",onClick:p,disabled:u.value},a(o(t)("关闭")),9,zI)])])]),_:1}))}}),RI=le(qI,[["__scopeId","data-v-ba5f9eb4"]]),VI=s=>{const t=document.createElement("div");document.body.appendChild(t);const n=G(CE,Ne(ye({},s),{close:()=>{l()}})),l=()=>{t.remove()};Us(n,t)},BI=s=>{const t=document.createElement("div");document.body.appendChild(t);const n=G(cI,Ne(ye({},s),{close:()=>{l()}})),l=()=>{t.remove()};Us(n,t)},UI=s=>{const t=document.createElement("div");document.body.appendChild(t);const n=G(gI,Ne(ye({},s),{close:()=>{l()}})),l=()=>{t.remove()};Us(n,t)},FI=s=>{const t=document.createElement("div");document.body.appendChild(t);const n=G(RI,Ne(ye({},s),{close:()=>{l()}})),l=()=>{t.remove()};Us(n,t)},HI={class:"cbi-section"},GI={class:"cbi-value"},jI={class:"cbi-value-title"},WI={class:"cbi-value-field"},JI={class:"cbi-checkbox"},KI=["value"],ZI={class:"cbi-value"},YI={class:"cbi-value-title"},QI={class:"cbi-value-field"},XI={class:"cbi-checkbox"},eD={value:"never"},tD={value:"sleep"},nD={value:"standby"},aD={value:"idle"},sD={class:"cbi-value-description"},oD={class:"cbi-value"},lD={class:"cbi-value-title"},iD={class:"cbi-value-field"},rD={class:"cbi-checkbox"},cD={value:0},dD=["value"],uD={class:"cbi-value-description"},vD={class:"cbi-value"},pD={class:"cbi-value-title"},hD={class:"cbi-value-field"},mD={class:"cbi-checkbox"},fD={value:0},bD=["value"],gD={class:"cbi-value-description"},_D={class:"cbi-section cbi-tblsection",id:"cbi-nfs-mount"},yD={class:"table cbi-section-table"},kD={class:"tr cbi-section-table-titles anonymous"},wD={class:"th cbi-section-table-cell","data-widget":"value"},$D={class:"th cbi-section-table-cell","data-widget":"value"},CD={class:"th cbi-section-table-cell","data-widget":"value"},SD={class:"th cbi-section-table-cell","data-widget":"value"},xD={class:"th cbi-section-table-cell","data-widget":"value"},PD={class:"th cbi-section-table-cell","data-widget":"value"},TD={class:"th cbi-section-table-cell","data-widget":"value"},MD={class:"th cbi-section-table-cell","data-widget":"value"},ED={class:"tr cbi-section-table-row"},ID={class:"td cb
Line truncated
|
||||
${n("设备和单设备例外不会被删除。")}`))try{const H=(yield t.DeviceMangement.deviceGroupsV2.POST({action:"delete_group",groupId:he.id,expectedVersion:p.value})).data.result;if(H!=null&&H.error)throw new Error(H.error.message);yield it()}catch(H){c.value=(H==null?void 0:H.message)||n("删除失败")}}),it=()=>B(null,null,function*(){var he,H,J;l.value=!0,c.value="";try{const[ge,ze,Fe]=yield Promise.all([t.DeviceMangement.deviceGroupsV2.GET(),t.DeviceMangement.deviceInventoryV2.GET(),t.DeviceMangement.gatewayTargetsV2.GET().catch(()=>null)]),Ee=ge.data.result;if(Ee!=null&&Ee.error)throw new Error(Ee.error.message);$.value=(Ee==null?void 0:Ee.groups)||[],$e.value=(Ee==null?void 0:Ee.globalPolicy)||null,S.value=(Ee==null?void 0:Ee.effective)||[],p.value=(Ee==null?void 0:Ee.version)||"",v.value=(Ee==null?void 0:Ee.timezone)||"",h.value=(Ee==null?void 0:Ee.nextEvaluationAt)||"",y.value=Ee==null?void 0:Ee.lastBatch,w.value=((he=ze.data.result)==null?void 0:he.devices)||[],C.value=((J=(H=Fe==null?void 0:Fe.data)==null?void 0:H.result)==null?void 0:J.targets)||[]}catch(ge){c.value=(ge==null?void 0:ge.message)||n("读取设备分组失败")}finally{l.value=!1}});return it(),(he,H)=>(i(),d("section",eR,[e("header",tR,[e("div",null,[e("h2",nR,a(o(n)("分组与计划")),1),e("p",null,a(o(n)("把需要相同安排的设备放在一起,一次设置联网、速度、路线、时段或流量额度。")),1)]),e("div",aR,[e("button",{type:"button",onClick:re},a(o(n)("默认规则")),1),e("button",{type:"button",class:"primary",onClick:j},a(o(n)("新建分组")),1)])]),l.value?(i(),Y(yt,{key:0,kind:"loading",title:o(n)("正在读取设备分组")},null,8,["title"])):c.value?(i(),Y(yt,{key:1,kind:"error",title:o(n)("设备分组读取失败"),description:c.value,"action-label":o(n)("重新加载"),onAction:it},null,8,["title","description","action-label"])):(i(),d(V,{key:2},[e("div",sR,[e("span",null,a(o(n)("按路由器时间执行"))+" · "+a(v.value||"—"),1),e("span",null,a(o(n)("下次检查"))+" "+a(q(h.value)),1)]),y.value&&y.value.status!=="unchanged"?(i(),d("div",{key:0,class:_e(["batch-result",y.value.status]),role:"status"},[e("strong",null,a(K(y.value.status)),1),e("span",null,a(o(n)("成功"))+" "+a(y.value.applied)+" · "+a(o(n)("跳过"))+" "+a(y.value.skipped)+" · "+a(o(n)("失败"))+" "+a(y.value.failed),1)],2)):T("",!0),!$.value.length&&!g.value?(i(),Y(yt,{key:1,kind:"empty",title:o(n)("还没有设备分组"),description:o(n)("例如创建“儿童设备”,设置晚间暂停联网和每月流量额度。")},null,8,["title","description"])):(i(),d("div",oR,[(i(!0),d(V,null,oe($.value,J=>(i(),d("article",{key:J.id,class:"group-card"},[e("div",lR,[e("div",null,[e("strong",null,a(J.name),1),e("span",null,a(J.members.length)+" "+a(o(n)("台设备")),1)]),e("span",iR,"P"+a(J.priority),1)]),e("p",null,a(O(J.policy)),1),e("div",rR,a(F(J.members)),1),e("div",cR,[e("button",{type:"button",onClick:ge=>De(J)},a(o(n)("编辑")),9,dR),e("button",{type:"button",class:"danger-link",onClick:ge=>Ze(J)},a(o(n)("删除")),9,uR)])]))),128))])),S.value.length?(i(),d("details",vR,[e("summary",null,[ue(a(o(n)("查看最终生效结果与来源"))+" ",1),e("small",null,a(Math.min(S.value.length,50))+" / "+a(S.value.length),1)]),e("div",pR,[(i(!0),d(V,null,oe(S.value.slice(0,50),J=>(i(),d("div",{key:J.deviceId},[e("span",null,[e("strong",null,a(z(J.deviceId)),1),e("small",null,a(ve(J)),1)]),e("em",null,a(ce(J.sources)),1)]))),128))])])):T("",!0),g.value?(i(),d("form",{key:4,class:"editor",onSubmit:Ge(at,["prevent"])},[e("div",hR,[e("div",null,[e("h3",null,a(m.value?o(n)("默认规则"):b.value?o(n)("编辑分组"):o(n)("新建分组")),1),e("p",null,a(m.value?o(n)("只为没有更具体规则的设备提供默认值。"):o(n)("单设备例外始终优先;多个分组冲突时,优先级较高的生效。")),1)]),e("button",{type:"button",class:"close",onClick:Ke,"aria-label":o(n)("关闭")},"×",8,mR)]),m.value?T("",!0):(i(),d("div",fR,[e("label",null,[e("span",null,a(o(n)("分组名称")),1),W(e("input",{"onUpdate:modelValue":H[0]||(H[0]=J=>_.name=J),maxlength:"64",required:"",placeholder:o(n)("例如:儿童设备")},null,8,bR),[[Oe,_.name,void 0,{trim:!0}]])])])),m.value?T("",!0):(i(),d("details",gR,[e("summary",null,a(o(n)("高级设置")),1),e("label",null,[e("span",null,a(o(n)("优先级")),1),W(e("input",{"onUpdate:modelValue":H[1]||(H[1]=J=>_.priority=J),type:"number",min:"0",max:"999"},null,512),[[Oe,_.priority,void 0,{number:!0}]]),e("small",null,a(o(n)("单设备例外始终优先;多个分组冲突时,优先级较高的生效。")),1)])])),m.value?T("",!0):(i(),d("fieldset",_R,[e("legend",null,[ue(a(o(n)("选择设备"))+" ",1),e("small",null,a(o(n)("已选择"))+" "+a(_.members.length)+" "+a(o(n)("台设备")),1)]),W(e("input",{"onUpdate:modelValue":H[2]||(H[2]=J=>f.value=J),class:"device-search",type:"search",placeholder:o(n)("搜索名称、IP 或 MAC")},null,8,yR),[[Oe,f.value,void 0,{trim:
Line truncated
|
||||
|
||||
@@ -19,6 +19,8 @@ sed -i -E '
|
||||
s/get favorites\(\)\{return ([^}]*\.favorites)\}/get favorites(){return \1.filter(y=>!["tool-source","tool-firmware","tool-sandbox"].includes(y))}/
|
||||
s/,[a-zA-Z0-9_$]+\("button",\{[^}]*"data-shortcut-restore":""\},[^}]*\("恢复默认八项","Restore eight defaults"\)\),1\)//
|
||||
|
||||
s,admin/store,admin/services/store,
|
||||
|
||||
# 5. 自定义链接支持 / 开头的绝对路径(保存时转为 http://localhost/... 以通过后端校验,展示与跳转时还原为 /...)
|
||||
s/!\/\^https\?:\\\/\\\/\/\.test\(([a-zA-Z0-9_$]+\.url)\)/(\/^\\\/(?!\\\/)\/.test(\1)\&\&(\1="http:\/\/localhost"+\1),&)/
|
||||
s/path:([a-zA-Z0-9_$]+\.url),/path:\1.replace(\/^http:\\\/\\\/localhost(?=\\\/)\/,""),/
|
||||
|
||||
@@ -6,7 +6,7 @@ LUCI_TITLE:=LuCI shared integration for LinkEase apps
|
||||
LUCI_PKGARCH:=all
|
||||
|
||||
PKG_VERSION:=1.2.1-r3
|
||||
PKG_RELEASE:=8
|
||||
PKG_RELEASE:=9
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
|
||||
@@ -65,11 +65,12 @@ bridge:auth()
|
||||
local state = result.redirect:match("/auth_finish/([A-Za-z0-9_-]+)$")
|
||||
equal(type(state), "string", "auth begin must encode return intent into the protected path")
|
||||
|
||||
bridge, result = scenario({
|
||||
bridge, result, headers = scenario({
|
||||
cookies = { sysauth = "valid-session" },
|
||||
valid_sid = "valid-session"
|
||||
})
|
||||
bridge:auth_finish(state)
|
||||
equal(has_header(headers, "linkease_openwrt_sid=valid%-session; Path=/apps"), true)
|
||||
equal(result.redirect, "/apps/kaiplus/")
|
||||
|
||||
local first_bridge, first_result = scenario({
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
PKG_NAME:=optimemachine
|
||||
PKG_VERSION:=0.3.0-cg1
|
||||
PKG_RELEASE:=1
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/optimemachine
|
||||
SECTION:=admin
|
||||
CATEGORY:=System
|
||||
TITLE:=changeguard legacy command compatibility
|
||||
DEPENDS:=+changeguard
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/optimemachine/conffiles
|
||||
/etc/config/optimemachine
|
||||
endef
|
||||
|
||||
define Package/optimemachine/preinst
|
||||
#!/bin/sh
|
||||
[ -n "$${IPKG_INSTROOT:-}" ] && exit 0
|
||||
if [ -x /usr/libexec/changeguard-package ]; then /usr/libexec/changeguard-package preinst; exit $$?; fi
|
||||
if [ -x /usr/sbin/optimemachine_bin ] && [ -f /etc/optimemachine/config.json ]; then
|
||||
/usr/sbin/optimemachine_bin maintenance-check >/dev/null || exit 1
|
||||
touch /var/run/changeguard-package-upgrade
|
||||
if /etc/init.d/optimemachine enabled; then touch /var/run/optimemachine-package-enable; fi
|
||||
if /usr/sbin/optimemachine_bin status --config /etc/optimemachine/config.json >/dev/null 2>&1; then
|
||||
touch /var/run/optimemachine-package-restart
|
||||
/etc/init.d/optimemachine stop || exit 1
|
||||
fi
|
||||
/usr/sbin/optimemachine_bin maintenance-check --config /etc/optimemachine/config.json >/dev/null || exit 1
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
define Package/optimemachine/postinst
|
||||
#!/bin/sh
|
||||
IPKG_INSTROOT="$${IPKG_INSTROOT:-}" "$${IPKG_INSTROOT:-}/usr/libexec/changeguard-package" postinst
|
||||
endef
|
||||
|
||||
define Package/optimemachine/prerm
|
||||
#!/bin/sh
|
||||
[ -n "$${IPKG_INSTROOT:-}" ] && exit 0
|
||||
/usr/sbin/changeguard_bin maintenance-check >/dev/null
|
||||
endef
|
||||
|
||||
define Package/optimemachine/install
|
||||
$(CP) ./files/* $(1)/
|
||||
endef
|
||||
$(eval $(call BuildPackage,optimemachine))
|
||||
@@ -0,0 +1,4 @@
|
||||
config optimemachine 'main'
|
||||
option config_file '/etc/optimemachine/config.json'
|
||||
option scheme 'http'
|
||||
option socket_path '/var/run/optimemachine.sock'
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
# Compatibility only: no second procd service or watchdog.
|
||||
exec /etc/init.d/changeguard "$@"
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec /usr/sbin/changeguard_bin "$@"
|
||||
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec /usr/libexec/changeguard-package "$@"
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
exec /usr/sbin/changeguard_bin "$@"
|
||||
Reference in new issue
Block a user