mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Get gateway from ubus
This commit is contained in:
parent
33ddb440b8
commit
bbf0d314e3
4 changed files with 7 additions and 2 deletions
|
@ -23,7 +23,7 @@ o.default = "2"
|
|||
o.datatype = "range(1, 100)"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(ListValue, "type", translate("Type"), translate("Always ping gateway, then test connection by ping or dns. None mode only ping gateway"))
|
||||
o = s:option(ListValue, "type", translate("Type"), translate("Always ping gateway, then test connection by ping or dns. None mode only ping gateway."))
|
||||
o:value("ping","ping")
|
||||
o:value("dns","dns")
|
||||
o:value("none","none")
|
||||
|
|
|
@ -57,7 +57,8 @@ interface_multipath_settings() {
|
|||
else
|
||||
network_get_ipaddr $config ipaddr
|
||||
ipaddr= $(ip -4 addr show dev $iface | grep inet | awk '{print $2}' | cut -d/ -f1 | tr -d "\n")
|
||||
gateway=$(ip -4 r list dev $iface | grep -v default | awk '/proto static/ {print $1}' | tr -d "\n")
|
||||
gateway=$(ip -4 r list dev "$OMR_TRACKER_DEVICE" | grep -v default | awk '/proto static/ {print $1}' | tr -d "\n")
|
||||
[ -z "$gateway" ] && gateway=$(ubus call network.interface.wan1 status | jsonfilter -e '@.route[0].nexthop' | tr -d "\n")
|
||||
netmask=$(ip -4 addr show dev $iface | grep inet | awk '{print $2}' | cut -d/ -f2 | tr -d "\n")
|
||||
network=`ipcalc.sh $ipaddr $netmask | sed -n '/NETWORK=/{;s/.*=//;s/ .*//;p;}'`
|
||||
fi
|
||||
|
|
|
@ -19,6 +19,7 @@ define Package/$(PKG_NAME)
|
|||
CATEGORY:=Network
|
||||
TITLE:=OpenMPTCProuter tracker
|
||||
PKGARCH:=all
|
||||
DEPENDS:=+bind-dig
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
|
|
|
@ -128,6 +128,9 @@ while true; do
|
|||
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
||||
OMR_TRACKER_DEVICE_GATEWAY=$(ip -4 r list dev "$OMR_TRACKER_DEVICE" | grep -v default | awk '/proto static/ {print $1}' | tr -d "\n")
|
||||
fi
|
||||
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
||||
OMR_TRACKER_DEVICE_GATEWAY=$(ubus call network.interface.wan1 status | jsonfilter -e '@.route[0].nexthop' | tr -d "\n")
|
||||
fi
|
||||
|
||||
# execute specific tracker
|
||||
if [ -n "$OMR_TRACKER_DEVICE_IP" ] && [ -n "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue