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

Fix omr-6in4

This commit is contained in:
Ycarus 2018-06-07 22:43:16 +02:00
parent 00ca958e6d
commit 613042b0a0
2 changed files with 10 additions and 12 deletions

View file

@ -1,28 +1,26 @@
#!/bin/sh /etc/rc.common #!/bin/sh /etc/rc.common
# Copyright (C) 2010-2014 OpenWrt.org # Copyright (C) 2018 Ycarus (Yannick Chabanois) <ycarus@zugaina.org>
START=99 START=99
USE_PROCD=1 USE_PROCD=1
service_triggers() { service_triggers() {
procd_add_interface_trigger "glorytun" "omrvpn" procd_add_interface_trigger "omrvpn"
} }
reload_service() { reload_service() {
iface=$(uci -q get glorytun.vpn.dev) iface=$(uci -q get glorytun.vpn.dev)
[ -z "$iface" ] && exit 0 addr=$(ubus call network.interface.omrvpn status | jsonfilter -e '@["ipv4-address"][0].address | tr -d "\n")
addr=$(ip -4 addr show dev $iface | grep inet | awk '{print $2}' | cut -d/ -f1 | tr -d "\n") [ -z "$addr" ] && [ -n "$iface" ] && addr=$(ip -4 addr show dev $iface | grep inet | awk '{print $2}' | cut -d/ -f1 | tr -d "\n")
peer=$(ip -4 r list dev $iface | grep kernel | awk '/proto kernel/ {print $1}' | tr -d "\n") peer=$(ubus call network.interface.omrvpn status | jsonfilter -e '@.route[0].nexthop' | tr -d "\n")
[ -z "$peer" ] && [ -n "$iface" ] && peer=$(ip -4 r list dev $iface | grep kernel | awk '/proto kernel/ {print $1}' | tr -d "\n")
[ -z "$addr" ] && exit 0
[ -z "$peer" ] && exit 0
if [ "$addr" != "$(uci -q get network.omr6in4.ipaddr)" ] || [ "$peer" != "$(uci -q get network.omr6in4.peeraddr)" ]; then if [ "$addr" != "$(uci -q get network.omr6in4.ipaddr)" ] || [ "$peer" != "$(uci -q get network.omr6in4.peeraddr)" ]; then
uci -q batch <<-EOF uci -q batch <<-EOF
set network.omr6in4.ipaddr=$addr set network.omr6in4.ipaddr=$addr
set network.omr6in4.peeraddr=$peer set network.omr6in4.peeraddr=$peer
EOF EOF
#if [ "$(uci -q get glorytun.vpn.proto)" = "udp" ]; then
# uci -q set network.omr6in4.gateway=fe80::a00:101
#elif [ "$(uci -q get glorytun.vpn.proto)" = "tcp" ]; then
# uci -q set network.omr6in4.gateway=fe80::a00:1
#fi
uci -q commit network uci -q commit network
ifup omr6in4 ifup omr6in4
fi fi

View file

@ -8,8 +8,8 @@ if [ "$(uci -q show network | grep omr6in4)" = "" ]; then
set network.omr6in4.proto=6in4 set network.omr6in4.proto=6in4
set network.omr6in4.ip4table=vpn set network.omr6in4.ip4table=vpn
set network.omr6in4.multipath=off set network.omr6in4.multipath=off
set network.omr6in4.ipaddr=10.0.0.2 set network.omr6in4.ipaddr=10.255.255.2
set network.omr6in4.peeraddr=10.0.0.1 set network.omr6in4.peeraddr=10.255.255.1
set network.omr6in4.gateway=fe80::a00:1 set network.omr6in4.gateway=fe80::a00:1
commit network commit network
add_list firewall.zone_vpn.network=omr6in4 add_list firewall.zone_vpn.network=omr6in4