Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] natmap: add dynamic firewall rules support #24036

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions net/natmap/files/natmap-update.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
#!/bin/sh

. /usr/share/libubox/jshn.sh
[ -z "${CONFIG_SECTION_ID}" ] && exit 1
export -n CONFIG_SECTION_ID

(
. /usr/share/libubox/jshn.sh

json_init
json_add_string ip "$1"
json_add_int port "$2"
json_add_int inner_port "$4"
json_add_string protocol "$5"
json_dump > /var/run/natmap/$PPID.json
json_dump > "/var/run/natmap/${CONFIG_SECTION_ID}.json"
)

[ -n "${NOTIFY_SCRIPT}" ] && {
export -n NOTIFY_SCRIPT
exec "${NOTIFY_SCRIPT}" "$@"
}
. /lib/functions.sh

NOTIFY_SCRIPT="$(uci_get natmap "${CONFIG_SECTION_ID}" notify_script)"
[ "$?" -eq 0 ] && [ -n "${NOTIFY_SCRIPT}" ] && exec "${NOTIFY_SCRIPT}" "$@"
2 changes: 1 addition & 1 deletion net/natmap/files/natmap.init
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ natmap_instance() {

[ -n "${forward_target}" ] && procd_append_param command -t "$forward_target" -p "$forward_port"

[ -n "${notify_script}" ] && procd_set_param env "NOTIFY_SCRIPT=${notify_script}"
procd_set_param env "CONFIG_SECTION_ID=$1"
procd_append_param command -e /usr/lib/natmap/update.sh

procd_set_param respawn
Expand Down