1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Merge branch 'test' into develop

This commit is contained in:
suyuan 2021-08-01 11:56:17 +08:00
commit 2012fe521c
8 changed files with 456 additions and 59 deletions

View file

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=iperf
PKG_VERSION:=3.10.1
PKG_RELEASE:=1
PKG_RELEASE:=10
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://downloads.es.net/pub/iperf

View file

@ -10,10 +10,10 @@ include $(TOPDIR)/rules.mk
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://gitlab.freedesktop.org/mobile-broadband/libqmi.git
PKG_SOURCE_VERSION:=29fab8a1d4496ca5a1d32bb486013b1868a718ba
PKG_SOURCE_VERSION:=311af7e04cd16a732ec799969b1e8d9c5334ac27
PKG_NAME:=libqmi
PKG_VERSION:=1.29.3-$(PKG_SOURCE_VERSION)
PKG_RELEASE:=10
PKG_RELEASE:=11
PKG_FIXUP:=autoreconf
PKG_MAINTAINER:=Nicholas Smith <nicholas.smith@telcoantennas.com.au>

View file

@ -292,12 +292,24 @@ function wizard_add()
ucic:set("network",intf,"masterintf",masterintf)
elseif typeintf == "" and ifname ~= "" and (proto == "static" or proto == "dhcp" or proto == "dhcpv6") then
ucic:set("network",intf,"device",ifname)
ucic:set("network",intf .. "_dev","device")
ucic:set("network",intf .. "_dev","name",ifname)
elseif typeintf == "" and device ~= "" and proto == "ncm" then
ucic:set("network",intf,"device",device_ncm)
ucic:set("network",intf .. "_dev","device")
ucic:set("network",intf .. "_dev","name",device_ncm)
elseif typeintf == "" and device ~= "" and proto == "qmi" then
ucic:set("network",intf,"device",device_qmi)
ucic:set("network",intf .. "_dev","device")
ucic:set("network",intf .. "_dev","name",device_qmi)
elseif typeintf == "" and device ~= "" and proto == "modemmanager" then
ucic:set("network",intf,"device",device_manager)
ucic:set("network",intf .. "_dev","device")
ucic:set("network",intf .. "_dev","name",device_manager)
elseif typeintf == "" and ifname ~= "" and proto == "static" then
ucic:set("network",intf,"device",ifname)
ucic:set("network",intf .. "_dev","device")
ucic:set("network",intf .. "_dev","name",ifname)
end
if proto == "pppoe" then
ucic:set("network",intf,"pppd_options","persist maxfail 0")

View file

@ -6,9 +6,8 @@
# Released under GPL 3 or later
if [ -d "/proc/sys/net/mptcp" ]; then
if [ `cat /proc/sys/net/mptcp/mptcp_enabled` = 0 ]; then
if ([ -f /proc/sys/net/mptcp/mptcp_enabled ] && [ `cat /proc/sys/net/mptcp/mptcp_enabled` = 0 ]) || ([ -f /proc/sys/net/mptcp/enabled ] && [ `cat /proc/sys/net/mptcp/enabled` = 0 ]); then
echo "MPTCP is disabled!"
echo "Please set net.mptcp.mptcp_enabled = 1"
exit 1
fi
else
@ -43,12 +42,28 @@ case $1 in
cat /proc/net/mptcp_fullmesh
exit 0;;
"-k")
echo Enabled: `cat /proc/sys/net/mptcp/mptcp_enabled`
echo Path Manager: `cat /proc/sys/net/mptcp/mptcp_path_manager`
echo Use checksum: `cat /proc/sys/net/mptcp/mptcp_checksum`
echo Scheduler: `cat /proc/sys/net/mptcp/mptcp_scheduler`
echo Syn retries: `cat /proc/sys/net/mptcp/mptcp_syn_retries`
echo Debugmode: `cat /proc/sys/net/mptcp/mptcp_debug`
if [ -f /proc/sys/net/mptcp/mptcp_enabled ]; then
echo Enabled: `cat /proc/sys/net/mptcp/mptcp_enabled`
elif [ -f /proc/sys/net/mptcp/enabled ]; then
echo Enabled: `cat /proc/sys/net/mptcp/enabled`
fi
if [ -f /proc/sys/net/mptcp/mptcp_path_manager ]; then
echo Path Manager: `cat /proc/sys/net/mptcp/mptcp_path_manager`
fi
if [ -f /proc/sys/net/mptcp/mptcp_checksum ]; then
echo Use checksum: `cat /proc/sys/net/mptcp/mptcp_checksum`
else
echo Use checksum: `cat /proc/sys/net/mptcp/checksum_enabled`
fi
if [ -f /proc/sys/net/mptcp/mptcp_scheduler ]; then
echo Scheduler: `cat /proc/sys/net/mptcp/mptcp_scheduler`
fi
if [ -f /proc/sys/net/mptcp/mptcp_syn_retries ]; then
echo Syn retries: `cat /proc/sys/net/mptcp/mptcp_syn_retries`
fi
if [ -f /proc/sys/net/mptcp/mptcp_debug ]; then
echo Debugmode: `cat /proc/sys/net/mptcp/mptcp_debug`
fi
echo
echo See http://multipath-tcp.org/ for details
exit 0 ;;
@ -70,33 +85,65 @@ TYPE="$2"
exit 1
}
FLAG_PATH="/sys/class/net/$DEVICE/flags"
IFF=`cat $FLAG_PATH`
if [ -f /proc/sys/net/mptcp/mptcp_enabled ]; then
FLAG_PATH="/sys/class/net/$DEVICE/flags"
IFF=`cat $FLAG_PATH`
IFF_OFF="0x80000"
IFF_ON="0x00"
IFF_BACKUP="0x100000"
IFF_HANDOVER="0x200000"
IFF_MASK="0x380000"
IFF_OFF="0x80000"
IFF_ON="0x00"
IFF_BACKUP="0x100000"
IFF_HANDOVER="0x200000"
IFF_MASK="0x380000"
case $TYPE in
"off") FLAG=$IFF_OFF;;
"on") FLAG=$IFF_ON;;
"backup") FLAG=$IFF_BACKUP;;
"handover") FLAG=$IFF_HANDOVER;;
"")
IFF=`printf "0x%02x" $(($IFF&$IFF_MASK))`
case "$IFF" in
$IFF_OFF) echo $DEVICE is deactivated;;
$IFF_ON) echo $DEVICE is in default mode;;
$IFF_BACKUP) echo $DEVICE is in backup mode;;
$IFF_HANDOVER) echo $DEVICE is in handover mode;;
*) echo "Unkown state!" && exit 1;;
esac
exit 0;;
*) echo "Unkown flag! Use 'multipath -h' for help" && exit 1;;
esac
case $TYPE in
"off") FLAG=$IFF_OFF;;
"on") FLAG=$IFF_ON;;
"backup") FLAG=$IFF_BACKUP;;
"handover") FLAG=$IFF_HANDOVER;;
"")
IFF=`printf "0x%02x" $(($IFF&$IFF_MASK))`
case "$IFF" in
$IFF_OFF) echo $DEVICE is deactivated;;
$IFF_ON) echo $DEVICE is in default mode;;
$IFF_BACKUP) echo $DEVICE is in backup mode;;
$IFF_HANDOVER) echo $DEVICE is in handover mode;;
*) echo "Unkown state!" && exit 1;;
esac
exit 0;;
*) echo "Unkown flag! Use 'multipath -h' for help" && exit 1;;
esac
printf "0x%02x" $(($(($IFF^$(($IFF&$IFF_MASK))))|$FLAG)) > $FLAG_PATH
printf "0x%02x" $(($(($IFF^$(($IFF&$IFF_MASK))))|$FLAG)) > $FLAG_PATH
else
ID=$(ip mptcp endpoint show | grep "dev $DEVICE" | awk '{print $3}')
IFF=$(ip mptcp endpoint show | grep "dev $DEVICE" | awk '{print $4}')
case $TYPE in
"off")
[ -n "$ID" ] && ip mptcp endpoint delete id $ID
exit 0;;
"on")
[ -n "$ID" ] && ip mptcp endpoint delete id $ID
ip mptcp endpoint add $IP dev $DEVICE subflow
exit 0;;
"signal")
[ -n "$ID" ] && ip mptcp endpoint delete id $ID
ip mptcp endpoint add $IP dev $DEVICE signal subflow
exit 0;;
"backup")
[ -n "$ID" ] && ip mptcp endpoint delete id $ID
ip mptcp endpoint add $IP dev $DEVICE backup
exit 0;;
"")
case "$IFF" in
"") echo $DEVICE is deactivated;;
"subflow") echo $DEVICE is in default mode;;
"backup") echo $DEVICE is in backup mode;;
"signal") echo $DEVICE is in signal mode;;
*) echo "$DEVICE Unkown state!" && exit 1;;
esac
exit 0;;
*) echo "Unkown flag! Use 'multipath -h' for help" && exit 1;;
esac
fi

View file

@ -834,17 +834,17 @@ if [ "$OMR_TRACKER_INTERFACE" = "glorytun" ] || [ "$OMR_TRACKER_INTERFACE" = "om
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE="interface"
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.latency="$OMR_TRACKER_LATENCY"
if [ "$(uci -q get glorytun.vpn.enable)" != "1" ] || [ "$(uci -q get glorytun-udp.vpn.enable)" != "1" ]; then
if [ -n "$(uci -q get network.$OMR_TRACKER_INTERFACE.mtu)" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
mtu=$(uci -q get network.$OMR_TRACKER_INTERFACE.mtu)
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mtu=$mtu
if [ -n "$(uci -q get network.${OMR_TRACKER_INTERFACE}_dev.mtu)" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
mtu=$(uci -q get network.${OMR_TRACKER_INTERFACE}_dev.mtu)
uci -q set openmptcprouter.${OMR_TRACKER_INTERFACE}.mtu=$mtu
[ -n "$mtu" ] && ip link set dev $OMR_TRACKER_DEVICE mtu $mtu > /dev/null 2>&1
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.lc=$(date +"%s")
elif [ -z "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.mtu)" ] && [ -n "$OMR_TRACKER_DEVICE_IP" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
elif [ -z "$(uci -q get openmptcprouter.${OMR_TRACKER_INTERFACE}.mtu)" ] && [ -n "$OMR_TRACKER_DEVICE_IP" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
if [ -n "$serverip" ] && [ "$serverip" != "127.0.0.1" ]; then
local mtu=$(omr-mtu $OMR_TRACKER_DEVICE_IP $serverip)
#local mtu=$(omr-mtu $OMR_TRACKER_DEVICE_IP 8.8.8.8)
[ -n "$mtu" ] && {
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mtu=$mtu
uci -q set openmptcprouter.${OMR_TRACKER_INTERFACE}.mtu=$mtu
ip link set dev $OMR_TRACKER_DEVICE mtu $mtu > /dev/null 2>&1
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.lc=$(date +"%s")
}
@ -1188,8 +1188,8 @@ if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc)" = "" ] || [ $(($(
[ -n "$omrtracebox" ] && [ -z "$(echo $omrtracebox | grep error)" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mptcp_status="$omrtracebox"
}
if [ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ "$(uci -q get glorytun.vpn.enable)" != "1" ] && [ "$(uci -q get glorytun-udp.vpn.enable)" != "1" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
if [ -n "$(uci -q get network.$OMR_TRACKER_INTERFACE.mtu)" ]; then
mtu=$(uci -q get network.$OMR_TRACKER_INTERFACE.mtu)
if [ -n "$(uci -q get network.${OMR_TRACKER_INTERFACE}_dev.mtu)" ]; then
mtu=$(uci -q get network.${OMR_TRACKER_INTERFACE}_dev.mtu)
[ -n "$mtu" ] && {
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mtu=$mtu
ip link set dev $OMR_TRACKER_DEVICE mtu $mtu > /dev/null 2>&1
@ -1252,10 +1252,10 @@ if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc)" = "" ] || [ $(($(
[ -n "$omrtracebox" ] && [ -z "$(echo $omrtracebox | grep error)" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mptcp_status="$omrtracebox"
}
if [ "$OMR_TRACKER_INTERFACE" != "omrvpn" ] && [ "$(uci -q get glorytun.vpn.enable)" != "1" ] && [ "$(uci -q get glorytun-udp.vpn.enable)" != "1" ] && [ -n "$OMR_TRACKER_DEVICE" ]; then
if [ -n "$(uci -q get network.$OMR_TRACKER_INTERFACE.mtu)" ]; then
mtu=$(uci -q get network.$OMR_TRACKER_INTERFACE.mtu)
if [ -n "$(uci -q get network.${OMR_TRACKER_INTERFACE}_dev.mtu)" ]; then
mtu=$(uci -q get network.${OMR_TRACKER_INTERFACE}_dev.mtu)
[ -n "$mtu" ] && {
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.mtu=$mtu
uci -q set openmptcprouter.${OMR_TRACKER_INTERFACE}.mtu=$mtu
ip link set dev $OMR_TRACKER_DEVICE mtu $mtu > /dev/null 2>&1
}
elif [ -n "$OMR_TRACKER_DEVICE_IP" ]; then

View file

@ -884,6 +884,7 @@ _vps_firewall_redirect_port() {
config_get v2ray $1 v2ray "0"
config_get name $1 name
config_get dmz $1 dmz "0"
config_get target $1 target "REDIRECT"
if [ -z "$src_dport" ] && [ -n "$dest_port" ]; then
src_dport=$dest_port
fi
@ -918,42 +919,74 @@ _vps_firewall_redirect_port() {
iptables-save --counters | sed "s:-d $src_dip/32::g" | iptables-restore -w
}
[ -n "$src_ip" ] && comment=" from $src_ip"
checkfw=$(echo "$vpsfwlist" | grep "# OMR $username redirect router $src_dport port $protoi${comment}")
if [ "$target" = "ACCEPT" ]; then
checkfw=$(echo "$vpsfwlist" | grep "# OMR $username open router $src_dport port $protoi${comment}")
else
checkfw=$(echo "$vpsfwlist" | grep "# OMR $username redirect router $src_dport port $protoi${comment}")
fi
fi
else
if [ "$src_dip" = "" ] && [ "$src_ip" = "" ]; then
checkfw=$(echo "$vpsfw6list" | grep "$src_dport # OMR $username redirect router $src_dport port $protoi")
if [ "$target" = "ACCEPT" ]; then
checkfw=$(echo "$vpsfw6list" | grep "$src_dport # OMR $username open router $src_dport port $protoi")
else
checkfw=$(echo "$vpsfw6list" | grep "$src_dport # OMR $username redirect router $src_dport port $protoi")
fi
else
comment=""
[ -n "$src_dip" ] && comment=" to $src_dip"
[ -n "$src_ip" ] && comment=" from $src_ip"
checkfw=$(echo "$vpsfw6list" | grep "# OMR $username redirect router $src_dport port $protoi${comment}")
if [ "$target" = "ACCEPT" ]; then
checkfw=$(echo "$vpsfw6list" | grep "# OMR $username open router $src_dport port $protoi${comment}")
else
checkfw=$(echo "$vpsfw6list" | grep "# OMR $username redirect router $src_dport port $protoi${comment}")
fi
fi
fi
if [ "$checkfw" = "" ]; then
settings='{"name" : "router '$src_dport'","port" : "'$src_dport'","source_dip" : "'$src_dip'","source_ip" : "'$src_ip'","proto" : "'$protoi'","fwtype" : "DNAT","ipproto" : "'$family'"}'
settings='{"name" : "router '$src_dport'","port" : "'$src_dport'","source_dip" : "'$src_dip'","source_ip" : "'$src_ip'","proto" : "'$protoi'","fwtype" : "'$target'","ipproto" : "'$family'"}'
_set_json "shorewallopen" "$settings"
fi
if [ "$family" = "ipv4" ]; then
if [ "$src_dip" = "" ] && [ "$src_ip" = "" ]; then
vpsfwlist=$(echo "$vpsfwlist" | grep -v "$src_dport # OMR $username redirect router $src_dport port $protoi")
[ "$username" = "openmptcprouter" ] && vpsfwlist=$(echo "$vpsfwlist" | grep -v "$src_dport # OMR redirect router $src_dport port $protoi")
if [ "$target" = "ACCEPT" ]; then
vpsfwlist=$(echo "$vpsfwlist" | grep -v "$src_dport # OMR $username open router $src_dport port $protoi")
[ "$username" = "openmptcprouter" ] && vpsfwlist=$(echo "$vpsfwlist" | grep -v "$src_dport # OMR open router $src_dport port $protoi")
else
vpsfwlist=$(echo "$vpsfwlist" | grep -v "$src_dport # OMR $username redirect router $src_dport port $protoi")
[ "$username" = "openmptcprouter" ] && vpsfwlist=$(echo "$vpsfwlist" | grep -v "$src_dport # OMR redirect router $src_dport port $protoi")
fi
else
comment=""
[ -n "$src_dip" ] && comment=" to $src_dip"
[ -n "$src_ip" ] && comment=" from $src_ip"
vpsfwlist=$(echo "$vpsfwlist" | grep -v "# OMR $username redirect router $src_dport port $protoi${comment}")
[ "$username" = "openmptcprouter" ] && vpsfwlist=$(echo "$vpsfwlist" | grep -v "# OMR redirect router $src_dport port $protoi${comment}")
if [ "$target" = "ACCEPT" ]; then
vpsfwlist=$(echo "$vpsfwlist" | grep -v "# OMR $username open router $src_dport port $protoi${comment}")
[ "$username" = "openmptcprouter" ] && vpsfwlist=$(echo "$vpsfwlist" | grep -v "# OMR open router $src_dport port $protoi${comment}")
else
vpsfwlist=$(echo "$vpsfwlist" | grep -v "# OMR $username redirect router $src_dport port $protoi${comment}")
[ "$username" = "openmptcprouter" ] && vpsfwlist=$(echo "$vpsfwlist" | grep -v "# OMR redirect router $src_dport port $protoi${comment}")
fi
fi
else
if [ "$src_dip" = "" ] && [ "$src_ip" = "" ]; then
vpsfw6list=$(echo "$vpsfw6list" | grep -v "$src_dport # OMR $username redirect router $src_dport port $protoi")
[ "$username" = "openmptcprouter" ] && vpsfw6list=$(echo "$vpsfw6list" | grep -v "$src_dport # OMR redirect router $src_dport port $protoi")
if [ "$target" = "ACCEPT" ]; then
vpsfw6list=$(echo "$vpsfw6list" | grep -v "$src_dport # OMR $username open router $src_dport port $protoi")
[ "$username" = "openmptcprouter" ] && vpsfw6list=$(echo "$vpsfw6list" | grep -v "$src_dport # OMR open router $src_dport port $protoi")
else
vpsfw6list=$(echo "$vpsfw6list" | grep -v "$src_dport # OMR $username redirect router $src_dport port $protoi")
[ "$username" = "openmptcprouter" ] && vpsfw6list=$(echo "$vpsfw6list" | grep -v "$src_dport # OMR redirect router $src_dport port $protoi")
fi
else
[ -n "$src_dip" ] && comment=" to $src_dip"
[ -n "$src_ip" ] && comment=" from $src_ip"
vpsfw6list=$(echo "$vpsfw6list" | grep -v "# OMR $username redirect router $src_dport port $protoi${comment}")
[ "$username" = "openmptcprouter" ] && vpsfw6list=$(echo "$vpsfw6list" | grep -v "# OMR redirect router $src_dport port $protoi${comment}")
if [ "$target" = "ACCEPT" ]; then
vpsfw6list=$(echo "$vpsfw6list" | grep -v "# OMR $username open router $src_dport port $protoi${comment}")
[ "$username" = "openmptcprouter" ] && vpsfw6list=$(echo "$vpsfw6list" | grep -v "# OMR open router $src_dport port $protoi${comment}")
else
vpsfw6list=$(echo "$vpsfw6list" | grep -v "# OMR $username redirect router $src_dport port $protoi${comment}")
[ "$username" = "openmptcprouter" ] && vpsfw6list=$(echo "$vpsfw6list" | grep -v "# OMR redirect router $src_dport port $protoi${comment}")
fi
fi
fi
else

View file

@ -0,0 +1,305 @@
#!/bin/sh
. /lib/functions.sh
_setup_macaddr() {
uci -q get "network.$1.macaddr" >/dev/null && return
uci -q set "network.$1.macaddr=$2"
}
_setup_macvlan() {
uci -q get "network.$1_dev.ifname" >/dev/null && return
# do not create macvlan for vlan
local _ifname
_ifname=$(uci -q get "network.$1.device")
case "$_ifname" in
eth*.*) return ;;
esac
uci -q batch <<-EOF
set network.$1_dev=device
set network.$1_dev.name=$1
set network.$1_dev.type=macvlan
set network.$1_dev.ifname=$_ifname
set network.$1_dev.mode='vepa'
set network.$1.device=$1
set network.$1.type=macvlan
set network.$1.masterintf=$_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.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
uci -q set network.$1.multipath=on
fi
if [ "$(uci -q get openmptcprouter.$1.multipath)" = "handover" ]; then
uci -q set openmptcprouter.$1.multipath=on
fi
}
_setup_multipath_off() {
uci -q get "network.$1.multipath" >/dev/null && return
uci -q set "network.$1.multipath=off"
}
_setup_wan_interface() {
uci -q batch <<-EOF
set network.$1=interface
set network.$1.device=$2
set network.$1.proto=static
set network.$1.ip4table=wan
set network.$1.multipath=$3
set network.$1.defaultroute=0
set network.$1_dev=device
set network.$1_dev.name=$2
commit network
add_list firewall.@zone[1].network=$1
commit firewall
EOF
[ -n "$4" ] && uci -q set network.$1.type=$4
}
config_load network
#config_foreach _setup_macvlan_update interface
config_foreach _setup_mptcp_handover_to_on interface
if [ "$(uci -q show network.lan | grep multipath)" != "" ]; then
exit 0
fi
lanif="eth0"
if [ "$(grep rockchip /etc/os-release)" != "" ]; then
lanif="eth1"
elif [ -d /sys/class/net/lan0 -o -n "$(ip link | grep ' lan0')" ] && [ -d /sys/class/net/wan -o -n "$(ip link | grep ' wan@')" -o -n "$(ip link | grep ' wan:')" ]; then
lanif="wan"
elif [ -d /sys/class/net/lan1 -o -n "$(ip link | grep ' lan1')" ] && [ -d /sys/class/net/wan -o -n "$(ip link | grep ' wan@')" -o -n "$(ip link | grep ' wan:')" ]; then
lanif="wan"
elif [ -d /sys/class/net/lan ] || [ -n "$(ip link | grep ' lan')" ]; then
lanif="lan"
elif [ "$(swconfig list 2>&1 | grep switch0)" != "" ] && [ -d '/sys/class/net/eth1.5' ]; then
lanif="eth1.5"
uci -q batch <<-EOF
set network.@switch_vlan[0]=switch_vlan
set network.@switch_vlan[0].device='switch0'
set network.@switch_vlan[0].vlan=1
set network.@switch_vlan[0].vid=1
set network.@switch_vlan[0].ports='3 5t'
add network switch_vlan
set network.@switch_vlan[1].device='switch0'
set network.@switch_vlan[1].vlan=2
set network.@switch_vlan[1].vid=2
set network.@switch_vlan[1].ports='2 5t'
add network switch_vlan
set network.@switch_vlan[2].device='switch0'
set network.@switch_vlan[2].vlan=3
set network.@switch_vlan[2].vid=3
set network.@switch_vlan[2].ports='1 5t'
add network switch_vlan
set network.@switch_vlan[3].device='switch0'
set network.@switch_vlan[3].vlan=4
set network.@switch_vlan[3].vid=4
set network.@switch_vlan[3].ports='0 5t'
add network switch_vlan
set network.@switch_vlan[4].device='switch0'
set network.@switch_vlan[4].vlan=5
set network.@switch_vlan[4].vid=5
set network.@switch_vlan[4].ports='4 6t'
EOF
elif [ "$(swconfig list 2>&1 | grep switch0)" != "" ] && [ -d /sys/class/net/eth1 ]; then
lanif="eth1"
elif [ ! -d /sys/class/net/eth1 ] && [ -d /sys/class/net/eth0 ]; then
lanif="eth0"
fi
uci -q batch <<-EOF
delete network.lan.type
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.device=${lanif}
set network.lan.metric=2048
set network.lan.ipv6=0
set network.lan.delegate=0
EOF
uci -q batch <<-EOF
delete network.none
delete network.wan
delete network.if6rd
reorder network.loopback=0
reorder network.globals=1
reorder network.lan=2
set network.globals.multipath=enable
EOF
# Set the ip rule for the lan with a pref of 100
uci -q show network.lan_rule >/dev/null || \
uci -q batch <<-EOF
set network.lan_rule=rule
set network.lan_rule.lookup=lan
set network.lan_rule.priority=100
EOF
if [ "$(uci -q get network.vpn0.proto)" = "none" ]; then
uci -q delete network.vpn0
fi
config_load network
config_foreach _setup_multipath_off interface
# Add the lan as a named routing table
if ! grep -s -q "lan" /etc/iproute2/rt_tables; then
echo "50 lan" >> /etc/iproute2/rt_tables
fi
uci -q set network.lan.ip4table='lan'
#uci -q set "network.lan.ip6assign=64"
# Create WAN interfaces
if [ "$(uci -q show network.wan1 | grep multipath)" = "" ] && [ -z "$(uci -q get network.wan1.multipath)" ]; then
if [ "$(grep rockchip /etc/os-release)" != "" ]; then
_setup_wan_interface wan1 eth0 master macvlan
_setup_wan_interface wan2 eth0 on macvlan
_setup_macvlan wan1
_setup_macvlan wan2
elif [ "$(swconfig list 2>&1 | grep switch0)" != "" ]; then
_setup_wan_interface wan1 eth0.1 master
_setup_wan_interface wan2 eth0.2 on
_setup_wan_interface wan3 eth0.3 on
_setup_wan_interface wan4 eth0.4 on
elif [ -d /sys/class/net/wan ] || [ -n "$(ip link | grep ' wan:')" ] || [ -n "$(ip link | grep ' wan@')" ]; then
if [ -d /sys/class/net/lan0 -o -n "$(ip link | grep ' lan0')" ] && [ -d /sys/class/net/lan1 -o -n "$(ip link | grep ' lan1')" ]; then
_setup_wan_interface wan1 lan0 master
_setup_wan_interface wan2 lan1 on
_macaddr=$(uci -q get "network.lan0.macaddr")
_setup_macaddr "wan1" "${_macaddr:-$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | md5sum | sed -e 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5:\6/' -e 's/^\(.\)[13579bdf]/\10/')}"
_macaddr=$(uci -q get "network.lan1.macaddr")
_setup_macaddr "wan2" "${_macaddr:-$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | md5sum | sed -e 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5:\6/' -e 's/^\(.\)[13579bdf]/\10/')}"
if [ -d /sys/class/net/lan2 ] || [ -n "$(ip link | grep ' lan2')" ]; then
_setup_wan_interface wan3 lan2 on
_macaddr=$(uci -q get "network.lan2.macaddr")
_setup_macaddr "wan3" "${_macaddr:-$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | md5sum | sed -e 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5:\6/' -e 's/^\(.\)[13579bdf]/\10/')}"
if [ -d /sys/class/net/lan3 ] || [ -n "$(ip link | grep ' lan3')" ]; then
_setup_wan_interface wan4 lan3 on
_macaddr=$(uci -q get "network.lan3.macaddr")
_setup_macaddr "wan4" "${_macaddr:-$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | md5sum | sed -e 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5:\6/' -e 's/^\(.\)[13579bdf]/\10/')}"
fi
fi
elif [ -d /sys/class/net/lan1 -o -n "$(ip link | grep ' lan1')" ] && [ -d /sys/class/net/lan2 -o -n "$(ip link | grep ' lan2')" ]; then
_setup_wan_interface wan1 lan1 master
_setup_wan_interface wan2 lan2 on
_macaddr=$(uci -q get "network.lan1.macaddr")
_setup_macaddr "wan1" "${_macaddr:-$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | md5sum | sed -e 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5:\6/' -e 's/^\(.\)[13579bdf]/\10/')}"
_macaddr=$(uci -q get "network.lan2.macaddr")
_setup_macaddr "wan2" "${_macaddr:-$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | md5sum | sed -e 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5:\6/' -e 's/^\(.\)[13579bdf]/\10/')}"
if [ -d /sys/class/net/lan3 ] || [ -n "$(ip link | grep ' lan3')" ]; then
_setup_wan_interface wan3 lan3 on
_macaddr=$(uci -q get "network.lan3.macaddr")
_setup_macaddr "wan3" "${_macaddr:-$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | md5sum | sed -e 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5:\6/' -e 's/^\(.\)[13579bdf]/\10/')}"
if [ -d /sys/class/net/lan4 ] || [ -n "$(ip link | grep ' lan4')" ]; then
_setup_wan_interface wan4 lan4 on
_macaddr=$(uci -q get "network.lan4.macaddr")
_setup_macaddr "wan4" "${_macaddr:-$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | md5sum | sed -e 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5:\6/' -e 's/^\(.\)[13579bdf]/\10/')}"
fi
fi
else
_setup_wan_interface wan1 wan master macvlan
_setup_wan_interface wan2 wan on macvlan
_setup_macvlan wan1
_setup_macvlan wan2
fi
elif [ -d /sys/class/net/wan1 ] || [ -n "$(ip link | grep ' wan1')" ]; then
if [ -d /sys/class/net/wan2 ] || [ -n "$(ip link | grep ' wan2')" ]; then
_setup_wan_interface wan1 wan1 master
_setup_wan_interface wan2 wan2 on
_macaddr=$(uci -q get "network.wan1.macaddr")
_setup_macaddr "wan1" "${_macaddr:-$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | md5sum | sed -e 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5:\6/' -e 's/^\(.\)[13579bdf]/\10/')}"
_macaddr=$(uci -q get "network.wan2.macaddr")
_setup_macaddr "wan2" "${_macaddr:-$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | md5sum | sed -e 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5:\6/' -e 's/^\(.\)[13579bdf]/\10/')}"
if [ -d /sys/class/net/wan3 ] || [ -n "$(ip link | grep ' wan3')" ]; then
_setup_wan_interface wan3 wan3 on
_macaddr=$(uci -q get "network.wan3.macaddr")
_setup_macaddr "wan3" "${_macaddr:-$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | md5sum | sed -e 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5:\6/' -e 's/^\(.\)[13579bdf]/\10/')}"
if [ -d /sys/class/net/wan4 ] || [ -n "$(ip link | grep ' wan4')" ]; then
_setup_wan_interface wan4 wan4 on
_macaddr=$(uci -q get "network.wan4.macaddr")
_setup_macaddr "wan4" "${_macaddr:-$(dd if=/dev/urandom bs=1024 count=1 2>/dev/null | md5sum | sed -e 's/^\(..\)\(..\)\(..\)\(..\)\(..\)\(..\).*$/\1:\2:\3:\4:\5:\6/' -e 's/^\(.\)[13579bdf]/\10/')}"
fi
fi
else
_setup_wan_interface wan1 wan1 master macvlan
_setup_wan_interface wan2 wan1 on macvlan
_setup_macvlan wan1
_setup_macvlan wan2
fi
elif [ -d /sys/class/net/eth1 ] || [ -n "$(ip link | grep ' eth1:')" ]; then
if [ -d /sys/class/net/eth2 ] || [ -n "$(ip link | grep ' eth2:')" ]; then
_setup_wan_interface wan1 eth1 master
_setup_wan_interface wan2 eth2 on
if [ -d /sys/class/net/eth3 ] || [ -n "$(ip link | grep ' eth3:')" ]; then
_setup_wan_interface wan3 eth3 on
fi
if [ -d /sys/class/net/eth4 ] || [ -n "$(ip link | grep ' eth4:')" ]; then
_setup_wan_interface wan4 eth4 on
fi
if [ -d /sys/class/net/eth5 ] || [ -n "$(ip link | grep ' eth5:')" ]; then
_setup_wan_interface wan5 eth5 on
fi
if [ -d /sys/class/net/eth6 ] || [ -n "$(ip link | grep ' eth6:')" ]; then
_setup_wan_interface wan6 eth6 on
fi
if [ -d /sys/class/net/eth7 ] || [ -n "$(ip link | grep ' eth7:')" ]; then
_setup_wan_interface wan7 eth7 on
fi
if [ -d /sys/class/net/eth8 ] || [ -n "$(ip link | grep ' eth8:')" ]; then
_setup_wan_interface wan8 eth8 on
fi
else
_setup_wan_interface wan1 eth1 master macvlan
_setup_wan_interface wan2 eth1 on macvlan
_setup_macvlan wan1
_setup_macvlan wan2
fi
elif [ -d /sys/class/net/eth0.1 ] && [ -d /sys/class/net/eth0.2 ]; then
_setup_wan_interface wan1 eth0.1 master
_setup_wan_interface wan2 eth0.2 on
else
_setup_wan_interface wan1 eth0 master macvlan
_setup_wan_interface wan2 eth0 on macvlan
_setup_macvlan wan1
_setup_macvlan wan2
fi
#uci -q batch <<-EOF
#add network route6
#set network.@route6[-1].interface='lan'
#set network.@route6[-1].target='::/0'
#EOF
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
exit 0

View file

@ -2,7 +2,7 @@
if [ "$(uci -q get wifi-iface.radio0)" != "" ] && [ "$(uci -q get wifi-iface.default_radio0.key)" = "12345678" ]; then
if [ "$(uci -q get wifi-device.radio0.country)" = "" ]; then
uci -q batch <<-EOF >/dev/null
set wifi-device.radio0.country='00'
set wifi-device.radio0.country='FR'
commit wifi-device
EOF
fi