natmap: add forward_port option 20150/head
authorRichard Yu <yurichard3839@gmail.com>
Wed, 21 Dec 2022 09:50:18 +0000 (17:50 +0800)
committerRichard Yu <yurichard3839@gmail.com>
Wed, 21 Dec 2022 09:50:18 +0000 (17:50 +0800)
The bind port (-b) can be used with forward port (-p),
so expose this option in config file.

Signed-off-by: Richard Yu <yurichard3839@gmail.com>
net/natmap/Makefile
net/natmap/files/natmap.config
net/natmap/files/natmap.init

index 7c09f17165f3812f510b0757cf056c010d2c9334..3c2991df83f44d494468a7f6159a0de895fab061 100644 (file)
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=natmap
 PKG_VERSION:=20221203
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://github.com/heiher/natmap/releases/download/$(PKG_VERSION)
index 71931f6c5684580943c99ab6b385c197d7d429c8..01328c1bbc60f3b55d2e747a7ae3e07838299e1f 100644 (file)
@@ -8,5 +8,6 @@ config natmap
        option http_server 'example.com'
        option port '8080'
        option forward_target ''
+       option forward_port ''
        option notify_script ''
 
index a9ff90539103c6a5cbef99a0c0bc79ac10cc5275..3688880b3e1d3b9a4020d67028811b6ad1ec8697 100644 (file)
@@ -26,6 +26,7 @@ validate_section_natmap() {
                'http_server:host' \
                'port:port' \
                'forward_target:host' \
+               'forward_port:port' \
                'notify_script:file'
 }
 
@@ -39,15 +40,16 @@ natmap_instance() {
 
        procd_open_instance "$1"
        procd_set_param command "$PROG" \
-               ${interval:+-k $interval} \
+               ${interval:+-k "$interval"} \
                ${stun_server:+-s "$stun_server"} \
-               ${http_server:+-h "$http_server"}
+               ${http_server:+-h "$http_server"} \
+               ${port:+-b "$port"} \
 
        [ "${family}" = ipv4 ] && procd_append_param command -4
        [ "${family}" = ipv6 ] && procd_append_param command -6
        [ "${udp_mode}" = 1 ] && procd_append_param command -u
 
-       [ -n "$interface" ] && {
+       [ -n "${interface}" ] && {
                local ifname
 
                network_get_device ifname "$interface" || ifname="$interface"
@@ -55,11 +57,7 @@ natmap_instance() {
                procd_append_param netdev "$ifname"
        }
 
-       if [ -n "$forward_target" ]; then
-               procd_append_param command -t "$forward_target" -p $port
-       else
-               procd_append_param command -b $port
-       fi
+       [ -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_append_param command -e /usr/lib/natmap/update.sh