Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync #441

Merged
merged 6 commits into from
Feb 24, 2024
Merged

sync #441

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.container {
/* container for entire page. fixes bootstrap theme's ridiculously small page width */
max-width: 1044px;
max-width: 1644px;
}
#interface_field {
padding: 12px 20px 20px 20px;
Expand Down Expand Up @@ -31,10 +31,6 @@
text-align: center;
}
/* Mwan3 ligthed CSS */
.container {
/* container for entire page. fixes bootstrap theme's ridiculously small page width */
max-width: 1044px;
}
#interface_field {
padding: 0px;
}
Expand Down
9 changes: 5 additions & 4 deletions mptcp/files/usr/share/omr/post-tracking.d/001-post-tracking
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,7 @@ dns_flush() {
# Get the current multipath status
multipath_status="off"
[ "$OMR_TRACKER_INTERFACE" = "omrvpn" ] && multipath $OMR_TRACKER_DEVICE off 2>&1 >/dev/null
[ "$OMR_TRACKER_INTERFACE" = "omr6in4" ] && multipath $OMR_TRACKER_DEVICE off 2>&1 >/dev/null
if [ -e "/sys/class/net/$OMR_TRACKER_DEVICE" ]; then
case "$(multipath "$OMR_TRACKER_DEVICE")" in
*default*) multipath_status="on" ;;
Expand Down Expand Up @@ -878,7 +879,7 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ] || [ "$interface_up" != "true" ]; then
ifup $OMR_TRACKER_INTERFACE 2>&1 >/dev/null
}

if [ "$OMR_TRACKER_INTERFACE" = "glorytun" ] || [ "$OMR_TRACKER_INTERFACE" = "omrvpn" ]; then
if [ "$OMR_TRACKER_INTERFACE" = "glorytun" ] || [ "$OMR_TRACKER_INTERFACE" = "omrvpn" ] || [ "$OMR_TRACKER_INTERFACE" = "omr6in4" ]; then
if [ "$OMR_TRACKER_STATUS_MSG" = "" ]; then
_log "$OMR_TRACKER_INTERFACE down"
else
Expand Down Expand Up @@ -917,7 +918,7 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ] || [ "$interface_up" != "true" ]; then
fi
if [ "$(uci -q get openvpn.omr.enabled)" = "1" ]; then
_log "OpenVPN down, restart it"
/etc/init.d/openvpn restart 2>&1 >/dev/null
/etc/init.d/openvpn restart omr 2>&1 >/dev/null
fi
config_load openmptcprouter
config_foreach disable_pihole server
Expand All @@ -944,7 +945,7 @@ if [ "$OMR_TRACKER_STATUS" = "ERROR" ] || [ "$interface_up" != "true" ]; then
exit 0
fi

if [ "$OMR_TRACKER_INTERFACE" = "glorytun" ] || [ "$OMR_TRACKER_INTERFACE" = "omrvpn" ]; then
if [ "$OMR_TRACKER_INTERFACE" = "glorytun" ] || [ "$OMR_TRACKER_INTERFACE" = "omrvpn" ] || [ "$OMR_TRACKER_INTERFACE" = "omr6in4" ]; then
if [ "$(uci -q get openmptcprouter.settings.shadowsocksudp)" = "1" ] && [ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] && [ -n "$(uci -q get shadowsocks-libev.sss0)" ] && [ "$(uci -q get shadowsocks-libev.ss_rules.redir_udp)" = "hi1" ]; then
_log "Tunnel up disable use of ShadowSocks for UDP"
uci -q delete shadowsocks-libev.ss_rules.redir_udp
Expand Down Expand Up @@ -1149,7 +1150,7 @@ if [ "$multipath_config" = "master" ]; then
config_load network
config_foreach set_route_balancing6 interface
[ -n "$routesbalancing6" ] && {
([ "$nbintf6" -gt "1" ] && [ "$(ip -6 r show default metric 1 | tr -d '\t' | tr -d '\n')" != "default via $routesbalancing6 " ] && [ "$(ip -6 r show default metric 1 | tr -d '\t' | tr -d '\n')" != "default $routesbalancing6 " ]) || ([ "$nbintf6" = "1" ] && [ "$(ip -6 r show default metric 1 | grep $OMR_TRACKER_DEVICE)" = "" ] && [ -n "$OMR_TRACKER_DEVICE_IP6" ]) && {
([ "$nbintf6" -gt "1" ] && [ "$(ip -6 r show default metric 1 | tr -d '\t' | tr -d '\n')" != "default via $routesbalancing6 " ] && [ "$(ip -6 r show default metric 1 | tr -d '\t' | tr -d '\n')" != "default $routesbalancing6 " ]) || ([ "$nbintf6" = "1" ] && [ "$(ip -6 r show default metric 1 | grep $OMR_TRACKER_DEVICE)" = "" ] && [ "$(ip -6 r show default metric 1 | grep omr6in4)" = "" ] && [ -n "$OMR_TRACKER_DEVICE_IP6" ]) && {
_log "Set ip -6 route replace default scope global metric 1 $routesbalancing6"
ip -6 route replace default scope global metric 1 $routesbalancing6 2>&1 >/dev/null
}
Expand Down
2 changes: 1 addition & 1 deletion omr-6in4/files/bin/omr-6in4
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ while true; do
[ -z "$peer" ] && peer=$(ip -4 r list dev $iface | grep via | grep -v default | grep -v metric | grep -v / | awk '{print $1; exit}' | tr -d "\n")
[ -z "$peer" ] && peer=$(ip -4 r list dev $iface | grep kernel | awk '/proto kernel/ {print $1}' | grep -v / | tr -d "\n")
[ -n "$addr" ] && [ -n "$peer" ] && {
if [ "$addr" != "$(uci -q get network.omr6in4.ipaddr)" ] || [ "$peer" != "$(uci -q get network.omr6in4.peeraddr)" ] || [ "$(ip -6 route show default | grep via)" = "" ]; then
if ([ "$addr" != "$(uci -q get network.omr6in4.ipaddr)" ] || [ "$peer" != "$(uci -q get network.omr6in4.peeraddr)" ]) && [ "$(ip -6 route show default dev 6in4-omr6in4 metric 1 | grep via)" = "" ]; then
logger -t "omr6in4" "Set network for OMR 6in4 to local $addr peer $peer"
uci -q batch <<-EOF
set network.omr6in4.ipaddr=$addr
Expand Down
101 changes: 68 additions & 33 deletions omr-tracker/files/bin/omr-tracker-server
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
name=$0
basename="$(basename $0)"

. /usr/lib/unbound/iptools.sh

_log() {
logger -p daemon.info -t "${basename}" "$@"
}
Expand All @@ -24,13 +26,23 @@ _check_server() {
local host=$1
local port=$2
local k=0
local valid_ip6=$(valid_subnet6 $host)
while [ "$server_ping" = false ] && [ "$k" -le "$retry" ]; do
ret=$(curl \
--max-time "$OMR_TRACKER_TIMEOUT" \
-s \
-k \
"https://${host}:${port}/"
)
if [ "$valid_ip6" != "ok" ]; then
ret=$(curl \
--max-time "$OMR_TRACKER_TIMEOUT" \
-s \
-k \
"https://${host}:${port}/"
)
else
ret=$(curl \
--max-time "$OMR_TRACKER_TIMEOUT" \
-s \
-k \
"https://[${host}]:${port}/"
)
fi
[ -n "$ret" ] && server_ping=true
k=$((k+1))
sleep "${intervaltries}"
Expand All @@ -40,16 +52,26 @@ _check_server() {
_check_server_intf() {
local host=$1
local port=$2
local valid_ip6=$(valid_subnet6 $host)
for intf in $(multipath | awk '/default/ {print $1}'); do
local k=0
while [ "$server_ping" = false ] && [ "$k" -le "$retry" ]; do
ret=$(curl \
--max-time "$OMR_TRACKER_TIMEOUT" \
-s \
-k \
--interface $intf \
"https://${host}:${port}/"
)
if [ "$valid_ip6" != "ok" ]; then
ret=$(curl \
--max-time "$OMR_TRACKER_TIMEOUT" \
-s \
-k \
--interface $intf \
"https://${host}:${port}/"
)
else
ret=$(curl \
--max-time "$OMR_TRACKER_TIMEOUT" \
-s \
-k \
"https://[${host}%${intf}]:${port}/"
)
fi
[ -n "$ret" ] && {
server_ping=true
}
Expand Down Expand Up @@ -89,21 +111,26 @@ _check_master() {
config_get ip $1 ip
config_get port $1 port "65500"
config_get disabled $1 disabled
serverip=""
[ "$master" = "1" ] && [ -n "$ip" ] && [ "$disabled" != "1" ] && {
set_ip() {
check_ip() {
local ipd=$1
local ip=""
ipresolve="$(resolveip -4 $ipd | head -n 1)"
if [ -n "$ipresolve" ]; then
ip="$ipresolve"
serverip="$ipresolve"
else
ip6resolve="$(resolveip -6 $ipd | head -n 1)"
[ -n "$ip6resolve" ] && ip="$ip6resolve"
[ -n "$ip6resolve" ] && serverip="$ip6resolve"
fi
[ -z "$ip" ] && return
#_ping_server $ip
#_check_server $ip $port
_check_server_intf $ip $port
[ -z "$serverip" ] && return
#_ping_server $serverip
#_check_server $serverip $port
_check_server_intf $serverip $port
[ "$server_ping" = true ] && return
countips=$((countips+1))
}
set_ip() {
ip="$serverip"
if [ "$server_ping" = true ]; then
if [ "$(uci -q get shadowsocks-libev.sss${count}.server | tr -d '\n')" != "$ip" ]; then
logger -t "OMR-Tracker-Server" "Master server ${name} up ($ip), set it back"
Expand Down Expand Up @@ -204,10 +231,10 @@ _check_master() {
script_alert_down="$(uci -q get omr-tracker.proxy.script_alert_down)"
[ -n "$script_alert_down" ] && eval $script_alert_down
fi
countips=$((countips+1))
}
config_load openmptcprouter
config_list_foreach $1 ip set_ip
config_list_foreach $1 ip check_ip
set_ip
#if [ "$server_ping" = true ] && [ "$countips" = "1" ]; then
# uci -q batch <<-EOF >/dev/null
# set shadowsocks-libev.sss${count}.server=$ip
Expand All @@ -233,19 +260,26 @@ _check_backup() {
config_get ip $1 ip
config_get port $1 port
config_get disabled $1 disabled
serverip=""
[ "$backup" = "1" ] && [ -n "$ip" ] && [ "$disabled" != "1" ] && {
set_ip() {
local ip=$1
ipresolve="$(resolveip -4 $ip | head -n 1)"
check_ip() {
local ipd=$1
ipresolve="$(resolveip -4 $ipd | head -n 1)"
if [ -n "$ipresolve" ]; then
ip="$ipresolve"
serverip="$ipresolve"
else
ip6resolve="$(resolveip -6 $ip | head -n 1)"
[ -n "$ip6resolve" ] && ip="$ip6resolve"
ip6resolve="$(resolveip -6 $ipd | head -n 1)"
[ -n "$ip6resolve" ] && serverip="$ip6resolve"
fi
#_ping_server $ip
#_check_server $ip $port
_check_server_intf $ip $port
[ -z "$serverip" ] && return
#_ping_server $serverip
#_check_server $serverip $port
_check_server_intf $serverip $port
[ "$server_ping" = true ] && return
countips=$((countips+1))
}
set_ip() {
ip="$serverip"
#[ "$server_ping" = true ] && [ "$(uci -q get shadowsocks-libev.sss${count}.server | tr -d '\n')" = "$ip" ] && break
if [ "$server_ping" = true ]; then
if [ "$(uci -q get shadowsocks-libev.sss${count}.server | tr -d '\n')" != "$ip" ]; then
Expand Down Expand Up @@ -349,7 +383,8 @@ _check_backup() {
countips=$((countips+1))
}
config_load openmptcprouter
config_list_foreach $1 ip set_ip
config_list_foreach $1 ip check_ip
set_ip
#if [ "$server_ping" = true ] && [ "$countips" = "1" ]; then
# uci -q batch <<-EOF >/dev/null
# set shadowsocks-libev.sss${count}.server=$ip
Expand Down
9 changes: 7 additions & 2 deletions omr-tracker/files/etc/init.d/omr-tracker
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ _launch_shadowsocks_tracker() {

[ "$enabled" = "0" ] || [ "$disabled" = "1" ] || [ -z "$hosts" ] && return
[ -z "$server" ] && return
[ "$server" = "192.168.1.3" ] || [ "$server" = "" ] && return
[ "$(uci -q get shadowsocks-libev.${server}.disabled)" = "1" ] && return

procd_open_instance
# shellcheck disable=SC2086
Expand Down Expand Up @@ -317,7 +317,7 @@ _launch_shadowsocks_rust_tracker() {

[ "$enabled" = "0" ] || [ "$disabled" = "1" ] || [ -z "$hosts" ] && return
[ -z "$server" ] && return
[ "$server" = "192.168.1.3" ] || [ "$server" = "" ] && return
[ "$(uci -q get shadowsocks-rust.${server}.disabled)" = "1" ] && return

procd_open_instance
# shellcheck disable=SC2086
Expand Down Expand Up @@ -385,12 +385,17 @@ _dns_server() {
local ip=$1
resolv=$(resolveip -4 ${ip} | head -n 1)
[ -n "${resolv}" ] && [ "${resolv}" != "${ip}" ] && multiserver=true
resolv=$(resolveip -6 ${ip} | head -n 1)
[ -n "${resolv}" ] && [ "${resolv}" != "${ip}" ] && multiserver=true
ipcount=$((ipcount+1))
}

_multi_server() {
local ipcount=0
config_get backup $1 backup
[ "$backup" = "1" ] && multiserver=true
config_list_foreach $1 ip _dns_server
[ "$ipcount" != "0" ] && [ "$ipcount" != "1" ] && multiserver=true
}

_gre_tunnel() {
Expand Down
14 changes: 9 additions & 5 deletions openmptcprouter-api/files/usr/libexec/rpcd/openmptcprouter
Original file line number Diff line number Diff line change
Expand Up @@ -1056,12 +1056,16 @@ function interfaces_status()
mArray.openmptcprouter["tun_state"] = "DOWN"
end
if mArray.openmptcprouter["ipv6"] == "enabled" or mArray.openmptcprouter["service_addr_ip6"] ~= "" then
local tunnel_ipv6_gw = uci:get("network","omr6in4","gateway")
local tunnel_ping6_test = ut.trim(sys.exec("ping6 -w 1 -c 1 " .. tunnel_ipv6_gw .. "%6in4-omr6in4 | grep '100% packet loss'"))
if tunnel_ping6_test == "" then
mArray.openmptcprouter["tun6_state"] = "UP"
local tunnel_ipv6_gw = uci:get("network","omr6in4","gateway") or ""
if tunnel_ipv6_gw ~= "" then
local tunnel_ping6_test = ut.trim(sys.exec("ping6 -w 1 -c 1 " .. tunnel_ipv6_gw .. "%6in4-omr6in4 | grep '100% packet loss'"))
if tunnel_ping6_test == "" then
mArray.openmptcprouter["tun6_state"] = "UP"
else
mArray.openmptcprouter["tun6_state"] = "DOWN"
end
else
mArray.openmptcprouter["tun6_state"] = "DOWN"
mArray.openmptcprouter["tun6_state"] = "UNKNOWN"
end
end
else
Expand Down