update 2024-12-09 00:23:41

This commit is contained in:
kenzok8 2024-12-09 00:23:41 +08:00
parent c54ed1e363
commit bc66930bd8
15 changed files with 276 additions and 70 deletions

View File

@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=floatip PKG_NAME:=floatip
PKG_VERSION:=1.0.2 PKG_VERSION:=1.0.4
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_MAINTAINER:=jjm2473 <jjm2473@gmail.com> PKG_MAINTAINER:=jjm2473 <jjm2473@gmail.com>
@ -18,6 +18,7 @@ define Package/$(PKG_NAME)
CATEGORY:=Network CATEGORY:=Network
SUBMENU:=IP Addresses and Names SUBMENU:=IP Addresses and Names
TITLE:=Float IP TITLE:=Float IP
DEPENDS:=+iputils-arping
PKGARCH:=all PKGARCH:=all
endef endef

View File

@ -12,35 +12,33 @@ start_service() {
local set_ip set_prefix local set_ip set_prefix
config_get set_ip "main" set_ip config_get set_ip "main" set_ip
[[ -n "$set_ip" ]] || return 0 [[ -n "$set_ip" ]] || return 0
eval "$(ipcalc.sh "$set_ip" )";set_prefix=$PREFIX;set_ip=$IP if [[ "$set_ip" = "*/*" ]]; then
[[ "$set_ip" = 0.0.0.0 ]] && set_ip=192.168.100.3 eval "$(ipcalc.sh "$set_ip" )";set_prefix=$PREFIX;set_ip=$IP
[[ "$set_prefix" = 0 ]] && set_prefix=32 else
set_prefix=32
fi
local lan_ip="`uci -q get network.lan.ipaddr`" local lan_ip="`uci -q get network.lan.ipaddr`"
[[ -n "$lan_ip" ]] || return 0 [[ -n "$lan_ip" ]] || return 0
local lan_net lan_prefix set_net ip local lan_net lan_prefix set_net ip
local in_range=0 local in_range=0
if echo "$lan_ip" | grep -Fq '/'; then local lan_netmask="`uci -q get network.lan.netmask`"
for ip in $lan_ip; do for ip in $lan_ip; do
eval "$(ipcalc.sh ${ip/\// } )";lan_net=$NETWORK;lan_prefix=$PREFIX if [[ "$ip" = "*/*" ]]; then
[[ "$set_prefix" -ge "$lan_prefix" ]] || continue eval "$(ipcalc.sh $ip )";lan_net=$NETWORK;lan_prefix=$PREFIX
eval "$(ipcalc.sh $set_ip $lan_prefix } )";set_net=$NETWORK else
[[ "$set_net" = "$lan_net" ]] && { # prefix=32 if not present
[[ "$set_prefix" = 32 ]] && set_prefix=$lan_prefix [[ -n "$lan_netmask" ]] || continue
in_range=1 eval "$(ipcalc.sh $ip $lan_netmask )";lan_net=$NETWORK;lan_prefix=$PREFIX
break
}
done
else
local netmask="`uci -q get network.lan.netmask`"
eval "$(ipcalc.sh "$lan_ip" "$netmask" )";lan_net=$NETWORK;lan_prefix=$PREFIX
if [[ "$set_prefix" -ge "$lan_prefix" ]]; then
eval "$(ipcalc.sh $set_ip $lan_prefix } )";set_net=$NETWORK
if [[ "$set_net" = "$lan_net" ]]; then
[[ "$set_prefix" = 32 ]] && set_prefix=$lan_prefix
in_range=1
fi
fi fi
fi [[ "$set_prefix" -ge "$lan_prefix" ]] || continue
eval "$(ipcalc.sh $set_ip/$lan_prefix )";set_net=$NETWORK
[[ "$set_net" = "$lan_net" ]] && {
[[ "$set_prefix" = 32 ]] && set_prefix=$lan_prefix
in_range=1
break
}
done
[[ $in_range = 1 ]] || return 0 [[ $in_range = 1 ]] || return 0
procd_open_instance procd_open_instance
procd_set_param command /usr/libexec/floatip.sh "$set_prefix" procd_set_param command /usr/libexec/floatip.sh "$set_prefix"

View File

@ -11,8 +11,10 @@ random() {
echo ${num:-1} echo ${num:-1}
} }
# check host alive, timeout in 2 seconds
host_alive() { host_alive() {
ping -4 -c 2 -A -t 1 -W 1 -q "$1" >/dev/null # ping -4 -c 2 -A -t 1 -W 1 -q "$1" >/dev/null
arping -f -q -b -c 2 -w 2 -i 1 -I br-lan "$1"
} }
set_up() { set_up() {
@ -44,14 +46,15 @@ fallback_loop() {
local set_ip check_ip set_net set_prefix local set_ip check_ip set_net set_prefix
config_get set_ip "main" set_ip config_get set_ip "main" set_ip
config_get check_ip "main" check_ip config_get check_ip "main" check_ip
[[ "$set_ip" = "*/*" ]] || set_ip="$set_ip/32"
eval "$(ipcalc.sh "$set_ip" )";set_net=$NETWORK;set_prefix=$PREFIX;set_ip=$IP eval "$(ipcalc.sh "$set_ip" )";set_net=$NETWORK;set_prefix=$PREFIX;set_ip=$IP
[[ "$set_net" = 0.0.0.0 ]] && set_net=192.168.100.0 [[ "$set_net" = 0.0.0.0 ]] && set_net=192.168.100.0
[[ "$set_prefix" = 0 ]] && set_prefix=$DEFAULT_PREFIX [[ "$set_prefix" = 32 ]] && set_prefix=$DEFAULT_PREFIX
[[ "$set_ip" = 0.0.0.0 ]] && set_ip=192.168.100.3 [[ "$set_ip" = 0.0.0.0 ]] && set_ip=192.168.100.3
local ipaddr="$set_ip/$set_prefix" local ipaddr="$set_ip/$set_prefix"
local valid_check_ip cip local valid_check_ip cip
for cip in $check_ip; do for cip in $check_ip; do
eval "$(ipcalc.sh $cip $set_prefix )" eval "$(ipcalc.sh $cip/$set_prefix )"
[[ "$NETWORK" = "$set_net" ]] && valid_check_ip="$valid_check_ip $cip" [[ "$NETWORK" = "$set_net" ]] && valid_check_ip="$valid_check_ip $cip"
done done
valid_check_ip="$valid_check_ip " valid_check_ip="$valid_check_ip "
@ -103,9 +106,10 @@ fallback_loop() {
main_loop() { main_loop() {
local set_ip set_net set_prefix local set_ip set_net set_prefix
config_get set_ip "main" set_ip config_get set_ip "main" set_ip
[[ "$set_ip" = "*/*" ]] || set_ip="$set_ip/32"
eval "$(ipcalc.sh "$set_ip" )";set_net=$NETWORK;set_prefix=$PREFIX;set_ip=$IP eval "$(ipcalc.sh "$set_ip" )";set_net=$NETWORK;set_prefix=$PREFIX;set_ip=$IP
[[ "$set_net" = 0.0.0.0 ]] && set_net=192.168.100.0 [[ "$set_net" = 0.0.0.0 ]] && set_net=192.168.100.0
[[ "$set_prefix" = 0 ]] && set_prefix=$DEFAULT_PREFIX [[ "$set_prefix" = 32 ]] && set_prefix=$DEFAULT_PREFIX
[[ "$set_ip" = 0.0.0.0 ]] && set_ip=192.168.100.3 [[ "$set_ip" = 0.0.0.0 ]] && set_ip=192.168.100.3
local ipaddr="$set_ip/$set_prefix" local ipaddr="$set_ip/$set_prefix"
while :; do while :; do
@ -133,6 +137,8 @@ main() {
fi fi
} }
[[ -n "$1" && "$1" -ge 0 && "$1" -lt 32 ]] && DEFAULT_PREFIX=$1 if [[ -n "$1" ]]; then
[[ "$1" -ge 0 && "$1" -lt 32 ]] && DEFAULT_PREFIX=$1
fi
main main

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_VERSION:=1.0.4-20230408 PKG_VERSION:=1.0.5-20241208
PKG_RELEASE:= PKG_RELEASE:=
PKG_MAINTAINER:=jjm2473 <jjm2473@gmail.com> PKG_MAINTAINER:=jjm2473 <jjm2473@gmail.com>

View File

@ -111,14 +111,15 @@ EOF
[[ "`uci -q get network.lan.proto`" = "static" ]] && { [[ "`uci -q get network.lan.proto`" = "static" ]] && {
local lan_ip="`uci -q get network.lan.ipaddr`" local lan_ip="`uci -q get network.lan.ipaddr`"
if [[ -n "$lan_ip" ]]; then if [[ -n "$lan_ip" ]]; then
if echo "$lan_ip" | grep -Fq '/'; then local netmask="`uci -q get network.lan.netmask`"
for bip in $lan_ip; do [[ -n "$netmask" ]] || netmask=255.255.255.255
eval "$(ipcalc.sh ${bip/\// } )";black_ip="$black_ip $IP/$PREFIX" for bip in $lan_ip; do
done if [[ "$bip" = "*/*" ]]; then
else eval "$(ipcalc.sh $bip )";black_ip="$black_ip $IP/$PREFIX"
local netmask="`uci -q get network.lan.netmask`" else
eval "$(ipcalc.sh "$lan_ip" "$netmask" )";black_ip="$black_ip $IP/$PREFIX" eval "$(ipcalc.sh $bip $netmask )";black_ip="$black_ip $IP/$PREFIX"
fi fi
done
fi fi
} }
@ -133,32 +134,31 @@ EOF
local vif local vif
for vif in lan wan; do for vif in lan wan; do
config_get ipaddr $vif ipaddr config_get ipaddr $vif ipaddr
[[ -z "$ipaddr" ]] || { [[ -n "$ipaddr" ]] || continue
for vip in $ipaddr; do for vip in $ipaddr; do
ok=1 ok=1
eval "$(ipcalc.sh ${vip/\// } )";vip="$IP";vip_p="$PREFIX" [[ "$vip" = "*/*" ]] || vip="$vip/24"
[[ "$vip_p" = 32 ]] && { eval "$(ipcalc.sh $vip )";vip="$IP";vip_p="$PREFIX"
[[ "$vip_p" = 32 ]] && {
logger -t 'ap_modem' -p DEBUG "vap_$vif skip $vip/$vip_p"
break
}
for bip in $black_ip; do
eval "$(ipcalc.sh "$bip" )";bip="$IP";
[[ "$PREFIX" -le "$vip_p" ]] || PREFIX=$vip_p
eval "$(ipcalc.sh "$vip/$PREFIX" )";vnet="$NETWORK";
eval "$(ipcalc.sh "$bip/$PREFIX" )";bnet="$NETWORK";
if [[ "$vnet" = "$bnet" ]]; then
logger -t 'ap_modem' -p DEBUG "vap_$vif skip $vip/$vip_p" logger -t 'ap_modem' -p DEBUG "vap_$vif skip $vip/$vip_p"
ok=0
break break
} fi
[[ "$vip_p" = 0 ]] && vip_p=24
for bip in $black_ip; do
eval "$(ipcalc.sh "$bip" )";bip="$IP";
[[ "$PREFIX" -le "$vip_p" ]] || PREFIX=$vip_p
eval "$(ipcalc.sh "$vip" "$PREFIX" )";vnet="$NETWORK";
eval "$(ipcalc.sh "$bip" "$PREFIX" )";bnet="$NETWORK";
if [[ "$vnet" = "$bnet" ]]; then
logger -t 'ap_modem' -p DEBUG "vap_$vif skip $vip/$vip_p"
ok=0
break
fi
done
[[ "$ok" = 1 ]] && {
uci add_list "network.vap_$vif.ipaddr=$vip/$vip_p"
black_ip="$black_ip $vip/$vip_p"
}
done done
} [[ "$ok" = 1 ]] && {
uci add_list "network.vap_$vif.ipaddr=$vip/$vip_p"
black_ip="$black_ip $vip/$vip_p"
}
done
done done
uci commit network uci commit network

View File

@ -2,7 +2,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_VERSION:=1.0.2-20241111 PKG_VERSION:=1.0.2-20241208
PKG_RELEASE:= PKG_RELEASE:=
LUCI_TITLE:=LuCI support for bmtedge LUCI_TITLE:=LuCI support for bmtedge
@ -13,6 +13,14 @@ define Package/luci-app-bmtedge/conffiles
/etc/config/bmtedge /etc/config/bmtedge
endef endef
# prerm
# postrm
define Package/luci-app-bmtedge/prerm
#!/bin/sh
docker rm -f bmtedge
exit 0
endef
include $(TOPDIR)/feeds/luci/luci.mk include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature # call BuildPackage - OpenWrt buildroot signature

18
luci-app-floatip/Makefile Normal file
View File

@ -0,0 +1,18 @@
# Copyright (C) 2016 Openwrt.org
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
include $(TOPDIR)/rules.mk
LUCI_TITLE:=LuCI support for floatip
LUCI_DEPENDS:=+floatip
LUCI_PKGARCH:=all
PKG_VERSION:=0.1.1-1
# PKG_RELEASE MUST be empty for luci.mk
PKG_RELEASE:=
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -0,0 +1,24 @@
module("luci.controller.floatip", package.seeall)
function index()
if not nixio.fs.access("/etc/config/floatip") then
return
end
entry({"admin", "services", "floatip"}, cbi("floatip"), _("FloatingGateway"), 20).dependent = true
entry({"admin", "services", "floatip_status"}, call("floatip_status"))
end
function floatip_status()
local sys = require "luci.sys"
local uci = require "luci.model.uci".cursor()
local status = {
running = (sys.call("pidof floatip.sh >/dev/null") == 0),
}
luci.http.prepare_content("application/json")
luci.http.write_json(status)
end

View File

@ -0,0 +1,50 @@
local m, s, o
m = Map("floatip", translate("FloatingGateway"), translate("FloatingGateway allows two gateway within one lan which can switch between each other in case of a failure."))
m:section(SimpleSection).template = "floatip_status"
s=m:section(NamedSection, "main", translate("Global settings"))
s.addremove=false
s.anonymous=true
o = s:option(Flag, "enabled", translate("Enable"))
o.rmempty = false
o = s:option(Value, "role", translate("Role"))
o.rmempty = false
o:value("main", translate("Preemptor"))
o:value("fallback", translate("Fallback"))
o = s:option(Value, "set_ip", translate("Floating Gateway IP"))
o.rmempty = false
function o.validate(self, value)
local ip, mask = value:match("(%d+%.%d+%.%d+%.%d+)/?(%d*)")
if not ip then
return nil, "Invalid format."
end
-- 验证 IP 地址格式
for octet in ip:gmatch("%d+") do
if tonumber(octet) < 0 or tonumber(octet) > 255 then
return nil, "IP address octets must be between 0 and 255"
end
end
-- 验证子网掩码(如果存在)
if mask ~= nil and mask ~= "" then
local netmask = tonumber(mask)
if netmask < 0 or netmask > 32 then
return nil, "Netmask must be between 0 and 32"
end
end
return value
end
o = s:option(Value, "check_ip", translate("Check IP"))
o.rmempty = false
o.datatype = "ipaddr"
o:depends("role", "fallback")
return m

View File

@ -0,0 +1,26 @@
<script type="text/javascript">//<![CDATA[
XHR.poll(5, '<%=url("admin/services/floatip_status")%>', null,
function(x, st)
{
var tb = document.getElementById('floatip_status');
if (st && tb)
{
if (st.running)
{
tb.innerHTML = '<br/><em style=\"color:green\"><%:The floatip service is running.%></em>';
}
else
{
tb.innerHTML = '<br/><em style=\"color:red\"><%:The floatip service is not running.%></em>';
}
}
}
);
//]]></script>
<fieldset class="cbi-section">
<legend><%:FloatIP Status%></legend>
<p id="floatip_status">
<em><%:Collecting data...%></em>
</p>
</fieldset>

View File

@ -0,0 +1,32 @@
msgid "FloatingGateway"
msgstr "浮动网关"
msgid "Running state"
msgstr "运行状态"
msgid "FloatingGateway allows two gateway within one lan which can switch between each other in case of a failure."
msgstr "浮动网关可以让你在内网有两个相互备份的网关,出现问题会相互切换。"
msgid "The FloatingGateway service is running."
msgstr "服务已启动"
msgid "The FloatingGateway service is not running."
msgstr "服务未启动"
msgid "FloatingGateway Status"
msgstr "服务状态"
msgid "Collecting data..."
msgstr "收集数据..."
msgid "Preemptor"
msgstr "旁路由"
msgid "Fallback"
msgstr "主路由"
msgid "Floating Gateway IP"
msgstr "浮动网关IP"
msgid "Check IP"
msgstr "旁路由 IP"

1
luci-app-floatip/po/zh_Hans Symbolic link
View File

@ -0,0 +1 @@
zh-cn

View File

@ -2,7 +2,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_VERSION:=1.1.4-20241002 PKG_VERSION:=1.1.4-20241208
PKG_RELEASE:= PKG_RELEASE:=
LUCI_TITLE:=LuCI support for wxedge LUCI_TITLE:=LuCI support for wxedge
@ -13,6 +13,14 @@ define Package/luci-app-wxedge/conffiles
/etc/config/wxedge /etc/config/wxedge
endef endef
# prerm
# postrm
define Package/luci-app-wxedge/prerm
#!/bin/sh
docker rm -f wxedge
exit 0
endef
include $(TOPDIR)/feeds/luci/luci.mk include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature # call BuildPackage - OpenWrt buildroot signature

View File

@ -2,14 +2,12 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=vlmcsd PKG_NAME:=vlmcsd
PKG_VERSION:=svn1113 PKG_VERSION:=svn1113
PKG_RELEASE:=3 PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/Wind4/vlmcsd/tar.gz/$(PKG_VERSION)? PKG_SOURCE_URL:=https://codeload.github.com/Wind4/vlmcsd/tar.gz/$(PKG_VERSION)?
PKG_HASH:=62f55c48f5de1249c2348ab6b96dabbe7e38899230954b0c8774efb01d9c42cc PKG_HASH:=62f55c48f5de1249c2348ab6b96dabbe7e38899230954b0c8774efb01d9c42cc
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=fuyumi <280604399@qq.com> PKG_MAINTAINER:=fuyumi <280604399@qq.com>
PKG_BUILD_PARALLEL:=1 PKG_BUILD_PARALLEL:=1
@ -20,7 +18,6 @@ define Package/vlmcsd
SECTION:=net SECTION:=net
CATEGORY:=Network CATEGORY:=Network
TITLE:=vlmcsd for OpenWRT TITLE:=vlmcsd for OpenWRT
URL:=http://forums.mydigitallife.info/threads/50234
DEPENDS:=+libpthread DEPENDS:=+libpthread
endef endef
@ -28,8 +25,10 @@ define Package/vlmcsd/description
vlmcsd is a KMS Emulator in C. vlmcsd is a KMS Emulator in C.
endef endef
MAKE_FLAGS += \ define Build/Prepare
-C $(PKG_BUILD_DIR) $(call Build/Prepare/Default)
rm $(PKG_BUILD_DIR)/GNUmakefile
endef
define Package/vlmcsd/install define Package/vlmcsd/install
$(INSTALL_DIR) $(1)/usr/bin $(INSTALL_DIR) $(1)/usr/bin

35
vlmcsd/src/Makefile Normal file
View File

@ -0,0 +1,35 @@
SRCDIR := src
BINDIR := bin
OBJDIR := build
TARGETS := $(BINDIR)/vlmcs $(BINDIR)/vlmcsd
.PHONY: all
all: $(BINDIR) $(TARGETS)
$(BINDIR)/vlmcs: $(OBJDIR)/vlmcs.o $(OBJDIR)/kmsdata-full.o $(OBJDIR)/crypto.o \
$(OBJDIR)/kms.o $(OBJDIR)/endian.o $(OBJDIR)/output.o \
$(OBJDIR)/shared_globals.o $(OBJDIR)/helpers.o \
$(OBJDIR)/network.o $(OBJDIR)/rpc.o \
$(OBJDIR)/crypto_internal.o $(OBJDIR)/dns_srv.o
$(CC) $(LDFLAGS) -o $@ $^
$(BINDIR)/vlmcsd: $(OBJDIR)/vlmcsd.o $(OBJDIR)/kmsdata.o $(OBJDIR)/crypto.o \
$(OBJDIR)/kms.o $(OBJDIR)/endian.o $(OBJDIR)/output.o \
$(OBJDIR)/shared_globals.o $(OBJDIR)/helpers.o \
$(OBJDIR)/network.o $(OBJDIR)/rpc.o \
$(OBJDIR)/crypto_internal.o
$(CC) $(LDFLAGS) -o $@ $^
$(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR)
$(CC) $(CFLAGS) -c $< -o $@
$(OBJDIR):
@mkdir -p $(OBJDIR)
$(BINDIR):
@mkdir -p $(BINDIR)
.PHONY: clean
clean:
@rm -rf $(OBJDIR) $(BINDIR)