pbr: 1.1.8-36 bugfixes

- drop load_environment_flag and always load environment on start, making
  restart command great again
- store/restore existing jshn namespace when using json()
- remove unneeded sleepCount in is_wan_up()
- move updated README inside files/

Signed-off-by: Stan Grishin <stangri@melmac.ca>
This commit is contained in:
Stan Grishin
2025-08-18 16:34:28 +00:00
parent b31b59907d
commit 0a512e8f0e
4 changed files with 23 additions and 25 deletions

View File

@@ -5,7 +5,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=pbr
PKG_VERSION:=1.1.8
PKG_RELEASE:=34
PKG_RELEASE:=36
PKG_LICENSE:=AGPL-3.0-or-later
PKG_MAINTAINER:=Stan Grishin <stangri@melmac.ca>

View File

@@ -1,18 +0,0 @@
# Policy-Based Routing (pbr)
[![OpenWrt](https://img.shields.io/badge/OpenWrt-Compatible-blueviolet)](https://openwrt.org)
[![Web UI](https://img.shields.io/badge/Web_UI-Available-blue)](https://docs.openwrt.melmac.ca/pbr/)
[![License](https://img.shields.io/badge/License-GPL--3.0-lightgrey)](https://github.com/stangri/pbr/blob/master/LICENSE)
Flexible policy-based routing (PBR) framework for OpenWrt.
Allows routing specific traffic (by IP, MAC, port, protocol, or domain) through a specific WAN, VPN, or tunnel.
## Features
- Route by IP, MAC, port, or domain name
- Works with WAN, VPNs (WireGuard, OpenVPN), or tunnels
- Lightweight shell-based implementation
- Optional Web UI integration via LuCI
**Full documentation:**
[https://docs.openwrt.melmac.ca/pbr/](https://docs.openwrt.melmac.ca/pbr/)

View File

@@ -1,3 +1,18 @@
# README
# Policy-Based Routing (pbr)
README is available at [https://docs.openwrt.melmac.net/pbr/](https://docs.openwrt.melmac.net/pbr/).
[![OpenWrt](https://img.shields.io/badge/OpenWrt-Compatible-blueviolet)](https://openwrt.org)
[![Web UI](https://img.shields.io/badge/Web_UI-Available-blue)](https://docs.openwrt.melmac.ca/pbr/)
[![License](https://img.shields.io/badge/License-GPL--3.0-lightgrey)](https://github.com/stangri/pbr/blob/master/LICENSE)
Flexible policy-based routing (PBR) framework for OpenWrt.
Allows routing specific traffic (by IP, MAC, port, protocol, or domain) through a specific WAN, VPN, or tunnel.
## Features
- Route by IP, MAC, port, or domain name
- Works with WAN, VPNs (WireGuard, OpenVPN), or tunnels
- Lightweight shell-based implementation
- Optional Web UI integration via LuCI
**Full documentation:**
[https://docs.openwrt.melmac.ca/pbr/](https://docs.openwrt.melmac.ca/pbr/)

View File

@@ -101,7 +101,6 @@ nft_set_policy=
nft_set_timeout=
# run-time
load_environment_flag=
aghConfigFile='/etc/AdGuardHome/AdGuardHome.yaml'
gatewaySummary=
wanIface4=
@@ -569,7 +568,6 @@ load_environment() {
return "$_ret"
}
local param="$1" validation_result="$2"
[ -z "$load_environment_flag" ] || return 0
case "$param" in
on_boot|on_start)
json init
@@ -607,7 +605,6 @@ load_environment() {
load_network "$param"
;;
esac
load_environment_flag=1
}
# shellcheck disable=SC2317
@@ -648,7 +645,7 @@ load_network() {
}
is_wan_up() {
local sleepCount='1' param="$1"
local param="$1"
if [ -z "$(uci_get network "$procd_wan_interface")" ]; then
json add error 'errorNoWanInterface' "$procd_wan_interface"
json add error 'errorNoWanInterfaceHint'
@@ -864,8 +861,10 @@ cleanup_sets() {
json() {
local status message stats i
local action="$1" param="$2" value="$3"; shift 3; local info="$*";
local _current_namespace="$_JSON_PREFIX"
[ "$param" = 'error' ] && param='errors'
[ "$param" = 'warning' ] && param='warnings'
json_set_namespace "${packageName}_"
{ json_load_file "$runningStatusFile" || json_init; } >/dev/null 2>&1
case "$action" in
'get')
@@ -882,6 +881,7 @@ json() {
fi
printf "%b" "$i"
json_select ..
json_set_namespace "$_current_namespace"
return
;;
'add')
@@ -903,6 +903,7 @@ json() {
mkdir -p "${runningStatusFile%/*}"
json_dump > "$runningStatusFile"
sync
json_set_namespace "$_current_namespace"
}
resolver() {