1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-15 03:51:51 +00:00
This commit is contained in:
suyuan 2024-01-19 01:43:23 +08:00 committed by GitHub
commit 3fb2013eaa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 42 additions and 34 deletions

View file

@ -240,6 +240,9 @@ interface_multipath_settings() {
if [ -z "$gateway" ] || [ "$( valid_subnet4 $gateway )" != "ok" ]; then
gateway=$(ubus call network.interface.${config}_4 status 2>/dev/null | jsonfilter -q -l 1 -e '@.route[@.target="0.0.0.0"].nexthop' | tr -d "\n")
fi
if [ -z "$gateway" ] || [ "$( valid_subnet4 $gateway )" != "ok" ]; then
gateway=$(ip -4 r list dev "$iface" | awk '/via/ {print $3;exit}' | tr -d "\n")
fi
if [ -z "$gateway" ] || [ "$( valid_subnet4 $gateway )" != "ok" ]; then
gateway=$(traceroute -m1 -i $iface 8.8.8.8 2>/dev/null | awk 'FNR==2{ print $2 }')
[ "$gateway" = "*" ] && gateway=""
@ -297,7 +300,7 @@ interface_multipath_settings() {
ip route replace $network/$netmask dev $iface scope link table $id $initcwrwnd 2>&1 >/dev/null
ip route replace default via $gateway dev $iface table $id $initcwrwnd 2>&1 >/dev/null
[ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ] && ip route replace default via $gateway dev $iface metric $id $initcwrwnd 2>&1 >/dev/null
ip route flush cache $id 2>&1 >/dev/null
#ip route flush cache $id 2>&1 >/dev/null
fi
#config_get mode "$config" multipath ""
@ -387,7 +390,7 @@ interface_multipath_settings() {
ip -6 route replace $network6/$netmask6 dev $iface scope link table 6$id $initcwrwnd 2>&1 >/dev/null
ip -6 route replace default via $gateway6 dev $iface table 6$id $initcwrwnd 2>&1 >/dev/null
[ "$(uci -q get openmptcprouter.settings.defaultgw)" != "0" ] && ip -6 route replace default via $gateway6 dev $iface metric 6$id $initcwrwnd 2>&1 >/dev/null
ip -6 route flush cache 6$id 2>&1 >/dev/null
#ip -6 route flush cache 6$id 2>&1 >/dev/null
fi
#config_get mode "$config" multipath "off"
@ -528,14 +531,14 @@ start_service() {
#config_foreach remove route6
#config_foreach remove rule
#config_foreach remove rule6
[ -z "$intf" ] && [ -n "$(uci -q get network.@route[-1])" ] && {
# logger -t "MPTCP" "Flush main table"
# ip route flush table main
# ip -6 route flush table main
logger -t "MPTCP" "Flush route cache"
ip route flush cache
ip -6 route flush cache
}
#[ -z "$intf" ] && [ -n "$(uci -q get network.@route[-1])" ] && {
## logger -t "MPTCP" "Flush main table"
## ip route flush table main
## ip -6 route flush table main
# logger -t "MPTCP" "Flush route cache"
# ip route flush cache
# ip -6 route flush cache
#}
if [ "$(uci -q get network.globals.mptcp_disable_initial_config)" != "1" ]; then
config_foreach interface_multipath_settings interface $intf
config_foreach add_route route

View file

@ -132,20 +132,23 @@ if [ -f /proc/sys/net/mptcp/mptcp_enabled ]; then
printf "0x%02x" $(($(($IFF^$(($IFF&$IFF_MASK))))|$FLAG)) > $FLAG_PATH
else
# Remove not needed if* interfaces in MPTCP
oldintfs=$(ip mptcp endpoint show | grep "dev if" | awk '{ print $3 }')
endpoint="$(ip mptcp endpoint show)"
[ -z "$endpoint" ] && exit 0
oldintfs=$(echo "${endpoint}" | grep "dev if" | awk '{ print $3 }')
[ -n "$oldintfs" ] && {
for oldintf in $oldintfs; do
ip mptcp endpoint delete id $oldintf 2>&1 >/dev/null
done
}
ID=$(ip mptcp endpoint show | sort | grep "dev $DEVICE " | awk '{print $3}')
IFF=$(ip mptcp endpoint show | sort | grep -m 1 -E "dev $DEVICE " | awk '{print $4}')
endpoint="$(ip mptcp endpoint show)"
[ -z "$endpoint" ] && exit 0
ID=$(echo "${endpoint}" | sort | grep "dev $DEVICE " | awk '{print $3}')
IFF=$(echo "${endpoint}" | sort | grep -m 1 -E "dev $DEVICE " | awk '{print $4}')
#IP=$(ip a show $DEVICE | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p')
[ -f /usr/bin/jsonfilter ] && IP=$(ip -j a show $DEVICE | jsonfilter -e '@[0].addr_info[*].local')
[ -f /usr/bin/jq ] && IP=$(ip -j a show $DEVICE | jq -r '.[0].addr_info[].local')
[ -z "$ID" ] && [ -n "$IP" ] && ID=$(ip mptcp endpoint show | grep "$IP " | awk '{print $3}')
RMID=$(ip mptcp endpoint show | grep '::ffff' | awk '{ print $3 }')
[ -z "$ID" ] && [ -n "$IP" ] && ID=$(echo "${endpoint}" show | grep "$IP " | awk '{print $3}')
RMID=$(echo "${endpoint}" | grep '::ffff' | awk '{ print $3 }')
[ -n "$RMID" ] && ip mptcp endpoint delete id $RMID 2>&1 >/dev/null
case $TYPE in
"off")

View file

@ -807,6 +807,15 @@ start_service() {
#nft insert rule inet fw4 ss_rules_dst_tcp ip daddr @omr_dst_bypass_all accept
#nft insert rule inet fw4 ss_rules_local_out ip daddr @omr_dst_bypass_all accept
EOF
#config_load shadowsocks-libev
#config_foreach _ss_rules_config ss_rules
([ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] || [ "$(uci -q get shadowsocks-rust.sss0.disabled)" != "1" ]) && _ss_rules_config
#config_load shadowsocks-rust
#config_foreach _ss_rules_config ss_rules
[ "$(uci -q get v2ray.main.enabled)" = "1" ] && _v2ray_rules_config
[ "$(uci -q get xray.main.enabled)" = "1" ] && _xray_rules_config
uci batch <<-EOF
set firewall.omr_bypass=include
set firewall.omr_bypass.enabled='1'
@ -846,14 +855,6 @@ start_service() {
# ip rule add prio 1 fwmark 0x4539 lookup 991337 > /dev/null 2>&1
# ip -6 rule add prio 1 fwmark 0x6539 lookup 6991337 > /dev/null 2>&1
#config_load shadowsocks-libev
#config_foreach _ss_rules_config ss_rules
([ "$(uci -q get shadowsocks-libev.sss0.disabled)" != "1" ] || [ "$(uci -q get shadowsocks-rust.sss0.disabled)" != "1" ]) && _ss_rules_config
#config_load shadowsocks-rust
#config_foreach _ss_rules_config ss_rules
[ "$(uci -q get v2ray.main.enabled)" = "1" ] && _v2ray_rules_config
[ "$(uci -q get xray.main.enabled)" = "1" ] && _xray_rules_config
# NDPI Netfilter is not available for nftables
$IPTABLESSAVE --counters 2>/dev/null | grep -v omr-bypass-dpi | $IPTABLESRESTORE -w --counters 2>/dev/null
$IPTABLESRESTORE -w --wait=60 --noflush <<-EOF

View file

@ -21,7 +21,7 @@ config_get lan_device lan ifname
_add_dscp_domain() {
domain=""; config_get domain "$1" name ""
class=""; config_get class "$1" class ""
[ -n "$domain" ] && [ -n "$class" ] && [ -z "$(uci -q get dhcp.omr_dscp-$class.domain | grep $domain)" ] && {
[ -n "$domain" ] && [ -n "$class" ] && [ -z "$(uci -q get dhcp.omr_dscp_$class.domain | grep $domain)" ] && {
uci -q batch <<-EOF
add_list dhcp.omr_dscp_$class.domain="$domain"
commit dhcp
@ -146,6 +146,7 @@ _setup_tunnel() {
}
_cleanup() {
uci -q del dhcp.@dnsmasq[0].ipset
config_load dhcp
config_foreach _remove_ipset_dnsmasq
config_load firewall

View file

@ -317,7 +317,7 @@ while true; do
OMR_TRACKER_DEVICE_GATEWAY=$(ip -4 r list dev "$OMR_TRACKER_DEVICE" | grep -m 1 default | awk '/via/ {print $3}' | tr -d "\n")
fi
if [ -z "$OMR_TRACKER_DEVICE_GATEWAY" ]; then
OMR_TRACKER_DEVICE_GATEWAY=$(ip -4 r list dev "$OMR_TRACKER_DEVICE" | awk '/via/ {print $3}' | tr -d "\n")
OMR_TRACKER_DEVICE_GATEWAY=$(ip -4 r list dev "$OMR_TRACKER_DEVICE" | awk '/via/ {print $3;exit}' | tr -d "\n")
fi
fi
if ([ "$OMR_TRACKER_IPV6" = "1" ] || [ "$OMR_TRACKER_IPV6" = "auto" ] || [ -z "$OMR_TRACKER_IPV6" ]) && ([ "$OMR_TRACKER_FAMILY" = "ipv6" ] || [ "$OMR_TRACKER_FAMILY" = "ipv4ipv6" ]); then

View file

@ -174,8 +174,8 @@ _check_master() {
echo -e "Subject: $OMR_SYSNAME: Server ${name} (${ip}) is UP\n. The reason is \"$OMR_TRACKER_STATUS_MSG\"." | sendmail $(uci -q get mail.default.to)
fi
}
script_alert_down="$(uci -q get omr-tracker.proxy.script_alert_up)"
[ -n "$script_alert_down" ] && eval $script_alert_up
script_alert_up="$(uci -q get omr-tracker.proxy.script_alert_up)"
[ -n "$script_alert_up" ] && eval $script_alert_up
count=$((count+1))
else
logger -t "OMR-Tracker-Server" "Master server ${name} down ($ip)"
@ -317,8 +317,8 @@ _check_backup() {
echo -e "Subject: $OMR_SYSNAME: Server ${name} (${ip}) is UP\n. The reason is \"$OMR_TRACKER_STATUS_MSG\"." | sendmail $(uci -q get mail.default.to)
fi
}
script_alert_down="$(uci -q get omr-tracker.proxy.script_alert_up)"
[ -n "$script_alert_down" ] && eval $script_alert_up
script_alert_up="$(uci -q get omr-tracker.proxy.script_alert_up)"
[ -n "$script_alert_up" ] && eval $script_alert_up
count=$((count+1))
else
uci -q batch <<-EOF >/dev/null
@ -374,7 +374,6 @@ interval=${OMR_TRACKER_INTERVAL:-10}
intervaltries=${OMR_TRACKER_INTERVAL_TRIES:-2}
retry=${OMR_TRACKER_TRIES:-4}
waittest=${OMR_TRACKER_WAIT_TEST:-0}
while true; do
server_ping=false
config_load openmptcprouter

View file

@ -3,6 +3,7 @@
cd /etc/uci-defaults || exit 0
# Keep dnsmasq ipset with old method
rm -f /etc/uci-defaults/50-dnsmasq-migrate-ipset.sh
uci -q del dhcp.@dnsmasq[0].ipset
source /etc/os-release

View file

@ -41,7 +41,7 @@ define Package/$(PKG_NAME)-config-nft
TITLE+= (init script with nft)
endef
define Package/$(PKG_NAME)/description
define Package/$(PKG_NAME)-core/description
Xray-core bare bones binary (compiled without cgo)
endef
@ -53,7 +53,7 @@ define Package/$(PKG_NAME)-config-nft/description
Xray-core init script with nft support
endef
define Package/$(PKG_NAME)/config
define Package/$(PKG_NAME)-core/config
menu "Xray Configuration"
depends on PACKAGE_$(PKG_NAME)-core

View file

@ -2114,7 +2114,7 @@ start_instance() {
fi
if [ -z "$xray_file" ] || [ ! -s "$xray_file" ] ; then
_err "Invalid V2Ray file."
_err "Invalid XRay file."
return 1
fi