mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Support interfaces where ifname is not defined in config
This commit is contained in:
parent
de107813d1
commit
9919f87f20
4 changed files with 14 additions and 0 deletions
|
@ -268,6 +268,11 @@ function get_ip(interface)
|
|||
return ip
|
||||
end
|
||||
|
||||
function get_device(interface)
|
||||
local dump = require("luci.util").ubus("network.interface.%s" % interface, "status", {})
|
||||
return dump['l3_device']
|
||||
end
|
||||
|
||||
function get_gateway(interface)
|
||||
local gateway = ""
|
||||
local dump = nil
|
||||
|
@ -332,6 +337,9 @@ function interfaces_status()
|
|||
mArray.openmptcprouter["tun_service"] = true
|
||||
mArray.openmptcprouter["tun_ip"] = get_ip("omrvpn")
|
||||
local tun_dev = uci:get("network","omrvpn","ifname")
|
||||
if tun_dev == "" then
|
||||
tun_dev = get_device("omrvpn")
|
||||
end
|
||||
if tun_dev ~= "" then
|
||||
local peer = get_gateway("omrvpn")
|
||||
if peer == "" then
|
||||
|
@ -418,6 +426,9 @@ function interfaces_status()
|
|||
--if interface == "lo" then return end
|
||||
|
||||
local ifname = section['ifname'] or ""
|
||||
if ifname == "" then
|
||||
ifname = get_device(interface)
|
||||
end
|
||||
--if multipath == "off" and not ifname:match("^tun.*") then return end
|
||||
if multipath == "off" then return end
|
||||
|
||||
|
|
|
@ -38,6 +38,7 @@ interface_multipath_settings() {
|
|||
local intf="$2"
|
||||
|
||||
config_get iface "$config" ifname
|
||||
[ -z "$iface"] && iface=$(ifstatus "$config" | jsonfilter -e '@["l3_device"]')
|
||||
count=$(($count+1))
|
||||
id=$count
|
||||
[ -n "$intf" ] && [ "$iface" != "$intf" ] && return 0
|
||||
|
|
|
@ -7,6 +7,7 @@ set_route() {
|
|||
PREVINTERFACE=$2
|
||||
multipath_config=$(uci -q get network.$INTERFACE.multipath || echo "off")
|
||||
interface_if=$(uci -q get network.$INTERFACE.ifname)
|
||||
[ -z "$interface_if" ] && interface_if=$(ifstatus "$INTERFACE" | jsonfilter -e '@["l3_device"]')
|
||||
multipath_current_config=$(multipath $interface_if | grep deactivated)
|
||||
if [ "$multipath_config" != "off" ] && [ "$SETROUTE" != true ] && [ "$INTERFACE" != "$PREVINTERFACE" ] && [ "$multipath_current_config" = "" ]; then
|
||||
#if [ "$multipath_config" != "off" ] && [ "$SETROUTE" != true ]; then
|
||||
|
|
|
@ -42,6 +42,7 @@ _launch_tracker() {
|
|||
|
||||
local ifname ip4table
|
||||
config_get ifname "$1" ifname
|
||||
[ -z "$ifname" ] && ifname=$(ifstatus "$1" | jsonfilter -e '@["l3_device"]')
|
||||
|
||||
config_get multipath "$1" multipath
|
||||
config_get gateway "$1" gateway
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue