Skip to content

Commit

Permalink
siproxd: improve network device resolution
Browse files Browse the repository at this point in the history
Resolve network devices by first trying 'network_get_device' (L3) and
falling back to 'network_get_physdev' (L2) on failure. This allows using
Wireguard interfaces without error.

Fixes: openwrt#800
Signed-off-by: Tony Ambardar <itugrok@yahoo.com>
  • Loading branch information
guidosarducci committed Nov 22, 2023
1 parent b28229f commit 8a0e178
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion net/siproxd/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=siproxd
PKG_RELEASE:=1
PKG_RELEASE:=2

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/hb9xar/siproxd.git
Expand Down
12 changes: 9 additions & 3 deletions net/siproxd/files/siproxd.init
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ append_conf() {
echo $* >> "$CONF_DIR/siproxd-$sec.conf"
}

# Resolve network device by layer 3 first, then layer 2

siproxd_get_device() {
network_get_device $1 $2 || network_get_physdev $1 $2
}

# Use user-friendly network names (e.g. "wan", "lan") from options
# 'interface_inbound' and 'interface_outbound', but use standard siproxd
# parameters 'if_inbound' and 'if_outbound' if explicitly set.
Expand All @@ -51,9 +57,8 @@ setup_networks() {
config_get _int_inbound "$sec" interface_inbound
config_get _int_outbound "$sec" interface_outbound

. /lib/functions/network.sh
network_get_physdev _dev_inbound $_int_inbound
network_get_physdev _dev_outbound $_int_outbound
siproxd_get_device _dev_inbound $_int_inbound
siproxd_get_device _dev_outbound $_int_outbound

default_conf if_inbound $_dev_inbound
default_conf if_outbound $_dev_outbound
Expand Down Expand Up @@ -165,6 +170,7 @@ start_service() {
chmod 755 "$CONF_DIR" "$REG_DIR" "$PID_DIR"
chown "$SIPROXD_UID:$SIPROXD_GID" "$REG_DIR"

. /lib/functions/network.sh
siproxd_cb
config_load 'siproxd'
}

0 comments on commit 8a0e178

Please sign in to comment.