mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Update openmptcprouter script and config to use device setting instead of ifname
This commit is contained in:
parent
c5945ec683
commit
ea3a4840c4
7 changed files with 33 additions and 31 deletions
|
@ -68,7 +68,7 @@ mptcp_over_vpn() {
|
|||
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set network.ovpn${interface}=interface
|
||||
set network.ovpn${interface}.ifname="tun${id}"
|
||||
set network.ovpn${interface}.device="tun${id}"
|
||||
set network.ovpn${interface}.defaultroute='0'
|
||||
set network.ovpn${interface}.peerdns='0'
|
||||
set network.ovpn${interface}.proto='none'
|
||||
|
|
|
@ -539,7 +539,7 @@ _get_gre_tunnel() {
|
|||
set network.oip${i}.label="Tunnel for $publicaddr"
|
||||
set network.oip${i}.proto=static
|
||||
set network.oip${i}.nohostroute='1'
|
||||
set network.oip${i}.ifname="@oip${i}gre"
|
||||
set network.oip${i}.device="@oip${i}gre"
|
||||
set network.oip${i}.ipv6='0'
|
||||
set network.oip${i}.defaultroute='0'
|
||||
set network.oip${i}.multipath='off'
|
||||
|
@ -823,7 +823,7 @@ _set_vpn_ip() {
|
|||
local settings
|
||||
[ -z "$vps_config" ] && vps_config=$(_get_json "config")
|
||||
[ -z "$vps_config" ] && return
|
||||
vpnifname="$(uci -q get network.omrvpn.ifname)"
|
||||
vpnifname="$(uci -q get network.omrvpn.device)"
|
||||
vpnip_local_current="$(echo "$vps_config" | jsonfilter -q -e '@.vpn.remoteip')"
|
||||
vpnip_local=$(ip -4 -br addr ls dev ${vpnifname} | awk -F'[ /]+' '{print $3}')
|
||||
vpnip_remote_current="$(echo "$vps_config" | jsonfilter -q -e '@.vpn.localip')"
|
||||
|
@ -850,7 +850,7 @@ _set_client2client() {
|
|||
[ -z "$vps_config" ] && vps_config=$(_get_json "config")
|
||||
[ -z "$vps_config" ] && return
|
||||
c2cips="$(echo "$vps_config" | jsonfilter -q -e '@.client2client.lanips[0]')"
|
||||
vpnifname="$(uci -q get network.omrvpn.ifname)"
|
||||
vpnifname="$(uci -q get network.omrvpn.device)"
|
||||
vpnip_local=$(ip -4 -br addr ls dev ${vpnifname} | awk -F'[ /]+' '{print $3}' | tr -d "\n")
|
||||
vpnip_remote=$(ip -4 r list dev ${vpnifname} | grep via | grep -v default | grep -v / | grep -v metric | awk '{print $1}' | tr -d "\n")
|
||||
for lanip in $c2cips; do
|
||||
|
|
|
@ -77,7 +77,7 @@ start_service()
|
|||
set network.omrvpn.updelay='20'
|
||||
set network.omrvpn.use_carrier='1'
|
||||
set network.omrvpn.mtu='1440'
|
||||
set network.omrvpn.ifname= 'bonding-omrvpn'
|
||||
set network.omrvpn.device= 'bonding-omrvpn'
|
||||
set network.omrvpn.force_link='1'
|
||||
commit network
|
||||
EOF
|
||||
|
|
|
@ -11,7 +11,7 @@ _setup_macvlan() {
|
|||
|
||||
# do not create macvlan for vlan
|
||||
local _ifname
|
||||
_ifname=$(uci -q get "network.$1.ifname")
|
||||
_ifname=$(uci -q get "network.$1.device")
|
||||
case "$_ifname" in
|
||||
eth*.*) return ;;
|
||||
esac
|
||||
|
@ -21,26 +21,24 @@ _setup_macvlan() {
|
|||
set network.$1_dev.name=$1
|
||||
set network.$1_dev.type=macvlan
|
||||
set network.$1_dev.ifname=$_ifname
|
||||
set network.$1.ifname=$1
|
||||
set network.$1_dev.mode='vepa'
|
||||
set network.$1.device=$1
|
||||
set network.$1.type=macvlan
|
||||
set network.$1.masterintf=$_ifname
|
||||
set macvlan.$1=macvlan
|
||||
set macvlan.$1.name=$1
|
||||
set macvlan.$1.ifname=$_ifname
|
||||
EOF
|
||||
_macaddr=$(uci -q get "network.$1.macaddr")
|
||||
_setup_macaddr "$1_dev" "${_macaddr:-auto$(date +%s)}"
|
||||
}
|
||||
|
||||
_setup_macvlan_update() {
|
||||
uci -q get "network.$1_dev.ifname" >/dev/null || return
|
||||
|
||||
uci -q batch <<-EOF
|
||||
set macvlan.$1=macvlan
|
||||
set macvlan.$1.ifname=$_ifname
|
||||
commit macvlan
|
||||
EOF
|
||||
}
|
||||
#_setup_macvlan_update() {
|
||||
# uci -q get "network.$1_dev.device" >/dev/null || return
|
||||
#
|
||||
# uci -q batch <<-EOF
|
||||
# set macvlan.$1=macvlan
|
||||
# set macvlan.$1.device=$_ifname
|
||||
# commit macvlan
|
||||
# EOF
|
||||
#}
|
||||
|
||||
_setup_mptcp_handover_to_on() {
|
||||
if [ "$(uci -q get network.$1.multipath)" = "handover" ]; then
|
||||
|
@ -59,7 +57,7 @@ _setup_multipath_off() {
|
|||
_setup_wan_interface() {
|
||||
uci -q batch <<-EOF
|
||||
set network.$1=interface
|
||||
set network.$1.ifname=$2
|
||||
set network.$1.device=$2
|
||||
set network.$1.proto=static
|
||||
set network.$1.ip4table=wan
|
||||
set network.$1.multipath=$3
|
||||
|
@ -72,7 +70,7 @@ _setup_wan_interface() {
|
|||
}
|
||||
|
||||
config_load network
|
||||
config_foreach _setup_macvlan_update interface
|
||||
#config_foreach _setup_macvlan_update interface
|
||||
config_foreach _setup_mptcp_handover_to_on interface
|
||||
|
||||
if [ "$(uci -q show network.lan | grep multipath)" != "" ]; then
|
||||
|
@ -128,7 +126,7 @@ set network.lan=interface
|
|||
set network.lan.proto=static
|
||||
set network.lan.ipaddr=192.168.100.1
|
||||
set network.lan.netmask=255.255.255.0
|
||||
set network.lan.ifname=${lanif}
|
||||
set network.lan.device=${lanif}
|
||||
set network.lan.metric=2048
|
||||
set network.lan.ipv6=0
|
||||
set network.lan.delegate=0
|
||||
|
@ -295,6 +293,10 @@ fi
|
|||
# Replace omrip to oip in config for old config
|
||||
sed -i 's/omrip/oip/g' /etc/config/*
|
||||
|
||||
# Fix config from ifname to device for loopback
|
||||
uci -q delete network.loopback.ifname
|
||||
uci -q set network.loopback.device='lo'
|
||||
|
||||
uci -q commit macvlan
|
||||
uci -q commit network
|
||||
rm -f /tmp/luci-indexcache
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
#!/bin/sh
|
||||
if [ "$(uci -q get openmptcprouter.latest_versions)" = "" ]; then
|
||||
wanintf="$(uci -q get network.wan1.ifname)"
|
||||
wanintf="$(uci -q get network.wan1.device)"
|
||||
if [ "$(uci -q get vnstat.@vnstat[-1].interface | grep $wanintf)" = "" ]; then
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete vnstat.@vnstat[-1]
|
||||
add vnstat vnstat
|
||||
set vnstat.@vnstat[-1].interface=$wanintf
|
||||
EOF
|
||||
wanintf="$(uci -q get network.wan2.ifname)"
|
||||
wanintf="$(uci -q get network.wan2.device)"
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
add_list vnstat.@vnstat[-1].interface=$wanintf
|
||||
EOF
|
||||
if [ "$(uci -q get network.wan3)" != "" ]; then
|
||||
wanintf="$(uci -q get network.wan3.ifname)"
|
||||
wanintf="$(uci -q get network.wan3.device)"
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
add_list vnstat.@vnstat[-1].interface=$wanintf
|
||||
EOF
|
||||
fi
|
||||
if [ "$(uci -q get network.wan4)" != "" ]; then
|
||||
wanintf="$(uci -q get network.wan4.ifname)"
|
||||
wanintf="$(uci -q get network.wan4.device)"
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
add_list vnstat.@vnstat[-1].interface=$wanintf
|
||||
EOF
|
||||
|
|
|
@ -5,7 +5,7 @@ if [ "$(uci -q get network.omrvpn)" = "" ]; then
|
|||
delete network.glorytun
|
||||
delete network.omrvpn
|
||||
set network.omrvpn=interface
|
||||
set network.omrvpn.ifname=tun0
|
||||
set network.omrvpn.device=tun0
|
||||
set network.omrvpn.proto=dhcp
|
||||
set network.omrvpn.ip4table=vpn
|
||||
set network.omrvpn.multipath=off
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/bin/sh
|
||||
if [ "$(uci -q get openmptcprouter.settings.version)" = "" ]; then
|
||||
if [ "$(uci -q get sqm.wan1)" = "" ]; then
|
||||
wan1="$(uci -q get network.wan1.ifname)"
|
||||
wan2="$(uci -q get network.wan2.ifname)"
|
||||
wan1="$(uci -q get network.wan1.device)"
|
||||
wan2="$(uci -q get network.wan2.device)"
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
delete sqm.eth1
|
||||
set sqm.wan1=queue
|
||||
|
@ -34,7 +34,7 @@ if [ "$(uci -q get openmptcprouter.settings.version)" = "" ]; then
|
|||
commit sqm
|
||||
EOF
|
||||
if [ "$(uci -q get network.wan3)" != "" ]; then
|
||||
wan3="$(uci -q get network.wan3.ifname)"
|
||||
wan3="$(uci -q get network.wan3.device)"
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set sqm.wan3=queue
|
||||
set sqm.wan3.qdisc="fq_codel"
|
||||
|
@ -53,7 +53,7 @@ if [ "$(uci -q get openmptcprouter.settings.version)" = "" ]; then
|
|||
EOF
|
||||
fi
|
||||
if [ "$(uci -q get network.wan4)" != "" ]; then
|
||||
wan4="$(uci -q get network.wan4.ifname)"
|
||||
wan4="$(uci -q get network.wan4.device)"
|
||||
uci -q batch <<-EOF >/dev/null
|
||||
set sqm.wan4=queue
|
||||
set sqm.wan4.qdisc="fq_codel"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue