🐶 Sync 2026-10-03 23:38:36

This commit is contained in:
github-actions[bot] committed 2026-10-03 23:38:36 +08:00
1 parent b63935e763
commit d0f1c561e1
187 files changed
+1472 -443

No files matched your search

+14 -4
View File
@@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=natflow
PKG_VERSION:=20260930
PKG_RELEASE:=87
PKG_RELEASE:=88
PKG_SOURCE:=$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=https://github.com/ptpt52/natflow.git
@@ -53,14 +53,24 @@ endef
define Package/natflow-boot
CATEGORY:=X
SUBMENU:=Fast Forward Stacks
TITLE:=natflow boot init scripts
TITLE:=natflow boot system scripts
PKGARCH:=all
DEPENDS:= +kmod-natflow
endef
define Package/natflow-boot/install
$(INSTALL_DIR) $(1)/etc/init.d
define Package/natflow-boot/conffiles
/etc/config/natflow
endef
define Package/natflow-boot/nstall
$(INSTALL_DIR) $(1)/etc/init.d \
$(1)/etc/config \
$(1)/etc/hotplug.d/iface \
$(1)/etc/hotplug.d/net
$(INSTALL_BIN) ./files/natflow-boot.init $(1)/etc/init.d/natflow-boot
$(INSTALL_CONF) ./files/natflow-boot.config $(1)/etc/config/natflow
$(INSTALL_BIN) ./files/natflow-boot.hotplug $(1)/etc/hotplug.d/iface/90-natflow
$(INSTALL_BIN) ./files/natflow-boot.hotplug $(1)/etc/hotplug.d/net/90-natflow
endef
$(eval $(call KernelPackage,natflow))
+32
View File
@@ -0,0 +1,32 @@
config natflow 'main'
option enabled '1'
option debug '3'
option hwnat '0'
# option hwnat_wed_disabled '0'
# option delay_pkts '0'
# option go_slowpath_if_no_qos '0'
# option ifname_group_type '0'
# list ifname_group 'eth0'
# option tc_classid_mode '1'
config zone
option type 'lan'
option id '1'
option ifname 'br-lan'
config zone
option type 'wan'
option id '2'
option ifname 'pppoe-wan' # можно префикс: 'eth+'
# config vline
# option type 'vline' # vline | relay
# option src 'br-lan'
# option dst 'usb0'
# option family 'ipv6' # ipv4 | ipv6 | all
# config qos
# option user '192.168.1.0/24'
# option proto 'tcp'
# option rxbytes '1310720'
# option txbytes '655360'
+65
View File
@@ -0,0 +1,65 @@
#!/bin/sh
# ifup (iface) / add (net) -> reload natflow, if device conifg defined
[ -c /dev/natflow_ctl ] || exit 0
case "$ACTION" in
ifup|add) ;;
*) exit 0 ;;
esac
DEV="${DEVICE:-${DEVICENAME:-$INTERFACE}}"
[ -n "$DEV" ] || exit 0
/etc/init.d/natflow-boot enabled || exit 0
. /lib/functions.sh
config_load natflow
config_get_bool enabled main enabled 1
[ "$enabled" -eq 1 ] || exit 0
match=0
# pattern с '+' end prefix (some in natflow_zone_ctl): eth+
dev_match() {
case "$1" in
*+)
case "$DEV" in
"${1%+}"*) return 0 ;;
esac
;;
"$DEV")
return 0
;;
esac
return 1
}
chk_zone() {
local i
config_get i "$1" ifname
dev_match "$i" && match=1
}
chk_vline() {
local s d
config_get s "$1" src
config_get d "$1" dst
{ dev_match "$s" || dev_match "$d"; } && match=1
}
chk_grp() {
dev_match "$1" && match=1
}
config_foreach chk_zone zone
config_foreach chk_vline vline
config_list_foreach main ifname_group chk_grp
[ "$match" -eq 1 ] || exit 0
lock /var/lock/natflow-hotplug
logger -t natflow "hotplug: $ACTION $DEV, reload"
/etc/init.d/natflow-boot reload
lock -u /var/lock/natflow-hotplug
+116 -3
View File
@@ -3,11 +3,124 @@
START=95
CTL=/dev/natflow_ctl
ZONE=/dev/natflow_zone_ctl
QOS=/dev/natflow_qos_ctl
# opt <dev> <key> <value>: пишет key=value, только если value не пустой
opt() {
[ -n "$3" ] && echo "$2=$3" >"$1"
}
apply_zone() {
local cfg="$1" type id ifname
config_get type "$cfg" type
config_get id "$cfg" id
config_get ifname "$cfg" ifname
case "$type" in
lan|wan) ;;
*) return 0 ;;
esac
[ -n "$id" ] && [ -n "$ifname" ] || return 0
echo "${type}_zone $id=$ifname" >"$ZONE"
}
apply_vline() {
local cfg="$1" type src dst family disabled
config_get_bool disabled "$cfg" disabled 0
[ "$disabled" -eq 0 ] || return 0
config_get type "$cfg" type vline
config_get src "$cfg" src
config_get dst "$cfg" dst
config_get family "$cfg" family all
case "$type" in
vline|relay) ;;
*) return 0 ;;
esac
[ -n "$src" ] && [ -n "$dst" ] || return 0
echo "${type}_add=$src,$dst,$family" >"$CTL"
}
apply_qos() {
local cfg="$1" disabled user user_port remote remote_port proto rxbytes txbytes
config_get_bool disabled "$cfg" disabled 0
[ "$disabled" -eq 0 ] || return 0
config_get user "$cfg" user
config_get user_port "$cfg" user_port
config_get remote "$cfg" remote
config_get remote_port "$cfg" remote_port
config_get proto "$cfg" proto
config_get rxbytes "$cfg" rxbytes 0
config_get txbytes "$cfg" txbytes 0
echo "add user=$user,user_port=$user_port,remote=$remote,remote_port=$remote_port,proto=$proto,rxbytes=$rxbytes,txbytes=$txbytes" >"$QOS"
}
ifgroup_add() {
echo "ifname_group_add=$1" >"$CTL"
}
start() {
echo debug=3 >/dev/natflow_ctl
echo disabled=0 >/dev/natflow_ctl
local enabled debug hwnat hwnat_wed_disabled delay_pkts
local go_slowpath_if_no_qos ifname_group_type tc_classid_mode
config_load natflow
config_get_bool enabled main enabled 1
[ "$enabled" -eq 1 ] || { stop; return 0; }
config_get debug main debug 3
config_get hwnat main hwnat
config_get hwnat_wed_disabled main hwnat_wed_disabled
config_get delay_pkts main delay_pkts
config_get go_slowpath_if_no_qos main go_slowpath_if_no_qos
config_get ifname_group_type main ifname_group_type
config_get tc_classid_mode main tc_classid_mode
echo "debug=$debug" >"$CTL"
opt "$CTL" hwnat "$hwnat"
opt "$CTL" hwnat_wed_disabled "$hwnat_wed_disabled"
opt "$CTL" delay_pkts "$delay_pkts"
opt "$CTL" go_slowpath_if_no_qos "$go_slowpath_if_no_qos"
if [ -n "$ifname_group_type" ]; then
echo "ifname_group_clear" >"$CTL"
echo "ifname_group_type=$ifname_group_type" >"$CTL"
config_list_foreach main ifname_group ifgroup_add
fi
# zones
echo "clean" >"$ZONE"
config_foreach apply_zone zone
echo "update_match" >"$ZONE"
# qos
echo "clear" >"$QOS"
opt "$QOS" tc_classid_mode "$tc_classid_mode"
config_foreach apply_qos qos
# vline/relay
echo "vline_clear" >"$CTL"
config_foreach apply_vline vline
echo "vline_apply" >"$CTL"
echo "update_magic" >"$CTL"
echo "disabled=0" >"$CTL"
}
stop() {
echo disabled=1 >/dev/natflow_ctl
echo "disabled=1" >"$CTL"
}
reload() {
start
}