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

More check and less errors in logs

This commit is contained in:
Ycarus 2018-12-17 17:00:48 +01:00
parent b874efae5d
commit 2dc68b960b
2 changed files with 15 additions and 7 deletions

View file

@ -88,7 +88,7 @@ interface_multipath_settings() {
config_get ipaddr $config ipaddr config_get ipaddr $config ipaddr
config_get gateway $config gateway config_get gateway $config gateway
config_get netmask $config netmask config_get netmask $config netmask
network=`ipcalc.sh $ipaddr $netmask | sed -n '/NETWORK=/{;s/.*=//;s/ .*//;p;}'` [ -n "$îpaddr" ] && [ -n "$netmask" ] && network=`ipcalc.sh $ipaddr $netmask | sed -n '/NETWORK=/{;s/.*=//;s/ .*//;p;}'`
else else
network_get_ipaddr $config ipaddr network_get_ipaddr $config ipaddr
ipaddr=$(ip -4 addr show dev $iface | grep inet | awk '{print $2}' | cut -d/ -f1 | tr -d "\n") ipaddr=$(ip -4 addr show dev $iface | grep inet | awk '{print $2}' | cut -d/ -f1 | tr -d "\n")
@ -103,7 +103,7 @@ interface_multipath_settings() {
fi fi
netmask=$(ip -4 addr show dev $iface | grep peer | awk '{print $4}' | cut -d/ -f2 | tr -d "\n") netmask=$(ip -4 addr show dev $iface | grep peer | awk '{print $4}' | cut -d/ -f2 | tr -d "\n")
[ -z "$netmask" ] && netmask=$(ip -4 addr show dev $iface | grep inet | awk '{print $2}' | cut -d/ -f2 | tr -d "\n") [ -z "$netmask" ] && 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;}'` [ -n "$ipaddr" ] && [ -n "$netmask" ] && network=`ipcalc.sh $ipaddr $netmask | sed -n '/NETWORK=/{;s/.*=//;s/ .*//;p;}'`
fi fi
ip rule del table $id > /dev/null 2>&1 ip rule del table $id > /dev/null 2>&1
ip route flush $id > /dev/null 2>&1 ip route flush $id > /dev/null 2>&1

View file

@ -97,6 +97,11 @@ del_ss_route() {
fi fi
} }
dns_flush() {
unbound-control flush-negative >/dev/null 2>&1
unbound-control flush-bogus >/dev/null 2>&1
}
if [ -n "$RANDOM" ]; then if [ -n "$RANDOM" ]; then
sleep `expr $RANDOM % 10` sleep `expr $RANDOM % 10`
else else
@ -173,7 +178,7 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ]; then
config_foreach set_route interface $OMR_TRACKER_INTERFACE config_foreach set_route interface $OMR_TRACKER_INTERFACE
#config_load shadowsocks-libev #config_load shadowsocks-libev
#config_foreach del_ss_route server all #config_foreach del_ss_route server all
if [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get shadowsocks-libev.ss_rules.redir_udp)" = "" ] && [ "$(uci -q get shadowsocks-libev.hi2.mode)" = "tcp_and_udp" ]; then if [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ "$(uci -q get openmptcprouter.omr.shadowsocks)" = "up" ] && [ "$(uci -q get shadowsocks-libev.ss_rules.redir_udp)" = "" ] && [ "$(uci -q get shadowsocks-libev.hi2.mode)" = "tcp_and_udp" ]; then
_log "Tunnel down use ShadowSocks for UDP" _log "Tunnel down use ShadowSocks for UDP"
uci -q set shadowsocks-libev.ss_rules.redir_udp='hi2' uci -q set shadowsocks-libev.ss_rules.redir_udp='hi2'
if /etc/init.d/shadowsocks-libev rules_exist ; then if /etc/init.d/shadowsocks-libev rules_exist ; then
@ -182,6 +187,7 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ]; then
fi fi
fi fi
fi fi
dns_flush
exit 0 exit 0
fi fi
@ -232,6 +238,7 @@ if [ "$OMR_TRACKER_PREV_STATUS" != "" ] && [ "$OMR_TRACKER_PREV_STATUS" != "$OMR
[ "$mail_alert" = "1" ] && echo -e "Subject: OpenMPTCProuter: $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE) is up\n\nOpenMPTCProuter detected that connection $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE) is up again." | sendmail $(uci -q get mail.default.to) [ "$mail_alert" = "1" ] && echo -e "Subject: OpenMPTCProuter: $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE) is up\n\nOpenMPTCProuter detected that connection $OMR_TRACKER_INTERFACE ($OMR_TRACKER_DEVICE) is up again." | sendmail $(uci -q get mail.default.to)
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.state='up' uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.state='up'
uci -q commit openmptcprouter uci -q commit openmptcprouter
dns_flush
fi fi
multipath_config=$(uci -q get "network.$OMR_TRACKER_INTERFACE.multipath" || echo "off") multipath_config=$(uci -q get "network.$OMR_TRACKER_INTERFACE.multipath" || echo "off")
@ -350,6 +357,7 @@ if [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.lc)" = "" ] || [ $(($(
fi fi
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.state='up' uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.state='up'
uci -q commit openmptcprouter uci -q commit openmptcprouter
dns_flush
fi fi
[ -n "$OMR_TRACKER_LATENCY" ] && { [ -n "$OMR_TRACKER_LATENCY" ] && {
@ -370,23 +378,23 @@ fi
if [ "$(pgrep ss-redir)" = "" ] && [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "0" ]; then if [ "$(pgrep ss-redir)" = "" ] && [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "0" ]; then
_log "Can't find Shadowsocks, restart it..." _log "Can't find Shadowsocks, restart it..."
/etc/init.d/shadowsocks-libev restart /etc/init.d/shadowsocks-libev restart
sleep 10 sleep 5
fi fi
if [ "$(pgrep glorytun)" = "" ] && [ "$(uci -q get glorytun.vpn.enabled)" = "1" ]; then if [ "$(pgrep glorytun)" = "" ] && [ "$(uci -q get glorytun.vpn.enabled)" = "1" ]; then
_log "Can't find Glorytun, restart it..." _log "Can't find Glorytun, restart it..."
/etc/init.d/glorytun restart /etc/init.d/glorytun restart
/etc/init.d/glorytun-udp restart /etc/init.d/glorytun-udp restart
sleep 10 sleep 5
fi fi
if [ "$(pgrep openvpn)" = "" ] && [ "$(uci -q get openvpn.omr.enabled)" != "0" ]; then if [ "$(pgrep openvpn)" = "" ] && [ "$(uci -q get openvpn.omr.enabled)" != "0" ]; then
_log "Can't find OpenVPN, restart it..." _log "Can't find OpenVPN, restart it..."
/etc/init.d/openvpn restart /etc/init.d/openvpn restart
sleep 10 sleep 5
fi fi
if [ "$(pgrep mlvpn)" = "" ] && [ "$(uci -q get mlvpn.general.enable)" != "0" ]; then if [ "$(pgrep mlvpn)" = "" ] && [ "$(uci -q get mlvpn.general.enable)" != "0" ]; then
_log "Can't find MLVPN, restart it..." _log "Can't find MLVPN, restart it..."
/etc/init.d/mlvpn restart /etc/init.d/mlvpn restart
sleep 10 sleep 5
fi fi
if [ "$(uci -q show openmptcprouter | grep get_config=\'1\')" != "" ] || [ "$(uci -q show openmptcprouter | grep admin_error=\'1\')" != "" ]; then if [ "$(uci -q show openmptcprouter | grep get_config=\'1\')" != "" ] || [ "$(uci -q show openmptcprouter | grep admin_error=\'1\')" != "" ]; then