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-08-01 22:07:29 +08:00 committed by GitHub
commit d36ddb24f4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 71 additions and 29 deletions

View file

@ -44,6 +44,13 @@ return view.extend({
o.value('offline', _('Offline'));
o.modalonly = true;
o = s.option(form.ListValue, 'type', _('Tracking method'),_('Check if VPS api answer or/and ping server IPs.'));
o.default = 'apiping';
o.value('apiping',_('API & Ping'));
o.value('api',_('API'));
o.value('ping',_('Ping'));
o.value('none',_('None'));
o = s.option(form.Flag, 'mail_alert', _('Mail alert'),
_('Send a mail when connection status change. You need to configure e-mail settings here.'));
o.rmempty = false;

View file

@ -602,6 +602,7 @@ service_triggers() {
[ -z "$iface" ] && network_get_physdev iface "$n"
[ -z "$iface" ] && iface=$(ifstatus "$n" | jsonfilter -q -e '@["l3_device"]')
[ -z "$iface" ] && config_get iface "$n" ifname
[ -z "$iface" ] && continue
procd_add_reload_interface_trigger "$n"
procd_add_interface_trigger "interface.*" "$n" /etc/init.d/mptcp reload "$iface"
done

View file

@ -177,10 +177,18 @@ _check_master() {
[ -z "$serverip" ] && return
#_ping_server $serverip
#_check_server $serverip $port
_check_server_intf $serverip $port
[ "$server_ping" = false ] && {
if [ "$OMR_TRACKER_TYPE" = "api" ]; then
_check_server_intf $serverip $port
elif [ "$OMR_TRACKER_TYPE" = "apiping" ]; then
_check_server_intf $serverip $port
[ "$server_ping" = false ] && {
_ping_server_intf $serverip
}
elif [ "$OMR_TRACKER_TYPE" = "ping" ]; then
_ping_server_intf $serverip
}
elif [ "$OMR_TRACKER_TYPE" = "none" ]; then
server_ping=true
fi
[ "$server_ping" = true ] && {
oneserverup="1"
}
@ -375,10 +383,18 @@ _check_backup() {
[ -z "$serverip" ] && return
#_ping_server $serverip
#_check_server $serverip $port
_check_server_intf $serverip $port
[ "$server_ping" = false ] && {
if [ "$OMR_TRACKER_TYPE" = "api" ]; then
_check_server_intf $serverip $port
elif [ "$OMR_TRACKER_TYPE" = "apiping" ]; then
_check_server_intf $serverip $port
[ "$server_ping" = false ] && {
_ping_server_intf $serverip
}
elif [ "$OMR_TRACKER_TYPE" = "ping" ]; then
_ping_server_intf $serverip
}
elif [ "$OMR_TRACKER_TYPE" = "none" ]; then
server_ping=true
fi
[ "$server_ping" = true ] && {
oneserverup="1"
}

View file

@ -67,4 +67,5 @@ config server 'server'
option wait_test '0'
option interval '5'
option mail_alert '0'
option initial_state 'online'
option initial_state 'online'
option type 'apiping'

View file

@ -168,6 +168,7 @@ _launch_server_tracker() {
procd_append_param env "OMR_TRACKER_INTERVAL=$interval"
procd_append_param env "OMR_TRACKER_INTERVAL_TRIES=$interval_tries"
procd_append_param env "OMR_TRACKER_WAIT_TEST=$wait_test"
procd_append_param env "OMR_TRACKER_TYPE=$type"
procd_set_param limits nofile="51200 51200"
procd_set_param respawn 0 10 0
procd_set_param stderr 1

View file

@ -136,5 +136,11 @@ if [ "$(uci -q get omr-tracker.defaults.family)" = "" ]; then
commit omr-tracker
EOF
fi
if [ "$(uci -q get omr-tracker.server.type)" = "" ]; then
uci -q batch <<-EOF >/dev/null
set omr-tracker.server.type='apiping'
commit omr-tracker
EOF
fi
exit 0

View file

@ -1058,8 +1058,8 @@ if [ "$(sysctl -qen net.mptcp.mptcp_enabled | tr -d '\n')" = "1" ] || [ "$(sysct
if [ "$multipath_status" = "$multipath_config" ] && ([ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.local_ipv4)" != "$OMR_TRACKER_DEVICE_IP" ] || [ "$(uci -q get openmptcprouter.$OMR_TRACKER_INTERFACE.local_ipv6)" != "$OMR_TRACKER_DEVICE_IP6" ]); then
_log "Local IP changed for $OMR_TRACKER_DEVICE ($OMR_TRACKER_INTERFACE) force Multipath"
multipath "$OMR_TRACKER_DEVICE" "$multipath_config"
[ -n "$OMR_TRACKER_DEVICE_IP" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.local_ipv4="$OMR_TRACKER_DEVICE_IP"
[ -n "$OMR_TRACKER_DEVICE_IP6" ] && uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.local_ipv6="$OMR_TRACKER_DEVICE_IP6"
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.local_ipv4="$OMR_TRACKER_DEVICE_IP"
uci -q set openmptcprouter.$OMR_TRACKER_INTERFACE.local_ipv6="$OMR_TRACKER_DEVICE_IP6"
elif [ "$multipath_status" != "$multipath_config" ]; then
if [ "$(uci -q get network.$OMR_TRACKER_INTERFACE.force_link)" != "0" ]; then
_log "Reload MPTCP config for $OMR_TRACKER_DEVICE"

View file

@ -98,6 +98,9 @@ _set_json() {
else
result=`curl --max-time 10 -s -k -H "Authorization: Bearer $token" -H "Content-Type: application/json" -X POST -d "$settings" https://[$server]:$serverport/$route`
fi
if [ "$(echo $result | grep 'Could not validate credentials')" ]; then
result=''
fi
echo $result
} || {
echo ''
@ -1659,7 +1662,7 @@ _set_config_from_vps() {
v2ray_key="$(echo "$vps_config" | jsonfilter -q -e '@.v2ray.config.key')"
#v2ray_port="$(echo "$vps_config" | jsonfilter -q -e '@.v2ray.config.port')"
v2ray_port="65228"
if ([ -n "$v2ray_key" ] && [ "$v2ray_key" != "$(uci -q get v2ray.omrout.s_vmess_user_id)" ]) || ([ -n "$v2ray_port" ] && [ "$v2ray_port" != "$(uci -q get v2ray.omrout.s_vmess.port)" ]); then
if [ -n "$(uci -q get v2ray.omr)" ] && (([ -n "$v2ray_key" ] && [ "$v2ray_key" != "$(uci -q get v2ray.omrout.s_vmess_user_id)" ]) || ([ -n "$v2ray_port" ] && [ "$v2ray_port" != "$(uci -q get v2ray.omrout.s_vmess.port)" ])); then
uci -q batch <<-EOF >/dev/null
set v2ray.omrout.s_socks_user_id="$v2ray_key"
set v2ray.omrout.s_socks_port="$((v2ray_port+3))"
@ -1677,8 +1680,10 @@ _set_config_from_vps() {
uci -q set v2ray.omrout.s_socks_address="$vpsip"
fi
uci -q commit v2ray
logger -t "OMR-VPS" "V2ray restart..."
/etc/init.d/v2ray restart >/dev/null 2>&1
if [ "$(uci -q get v2ray.main.enabled)" = "1" ]; then
logger -t "OMR-VPS" "V2ray restart..."
/etc/init.d/v2ray restart >/dev/null 2>&1
fi
fi
# XRay settings
@ -1687,7 +1692,7 @@ _set_config_from_vps() {
xray_vless_reality_key="$(echo "$vps_config" | jsonfilter -q -e '@.xray.config.vless_reality_key')"
#v2ray_port="$(echo "$vps_config" | jsonfilter -q -e '@.v2ray.config.port')"
xray_port="65248"
if ([ -n "$xray_key" ] && [ "$xray_key" != "$(uci -q get xray.omrout.s_vmess_user_id)" ]) || ([ -n "$xray_port" ] && [ "$xray_port" != "$(uci -q get xray.omrout.s_vmess.port)" ]); then
if [ -n "$(uci -q get xray.omr)" ] && (([ -n "$xray_key" ] && [ "$xray_key" != "$(uci -q get xray.omrout.s_vmess_user_id)" ]) || ([ -n "$xray_port" ] && [ "$xray_port" != "$(uci -q get xray.omrout.s_vmess.port)" ])); then
uci -q batch <<-EOF >/dev/null
set xray.omrout.s_shadowsocks_port="$((xray_port+4))"
set xray.omrout.s_shadowsocks_password="$xray_sskey"
@ -1712,14 +1717,16 @@ _set_config_from_vps() {
uci -q set xray.omrout.s_shadowsocks_address="$vpsip"
fi
uci -q commit xray
logger -t "OMR-VPS" "Xray restart..."
/etc/init.d/xray restart >/dev/null 2>&1
if [ "$(uci -q get xray.main.enabled)" = "1" ]; then
logger -t "OMR-VPS" "Xray restart..."
/etc/init.d/xray restart >/dev/null 2>&1
fi
fi
# Glorytun settings
glorytun_key="$(echo "$vps_config" | jsonfilter -q -e '@.glorytun.key')"
glorytun_port="$(echo "$vps_config" | jsonfilter -q -e '@.glorytun.port')"
if ([ -n "$glorytun_key" ] && [ "$glorytun_key" != "$(uci -q get glorytun.vpn.key)" ]) || ([ -n "$glorytun_port" ] || [ "$glorytun_port" != "$(uci -q get glorytun.vpn.port)" ]); then
if [ -n "$(uci -q get glorytun.vpn)" ] && (([ -n "$glorytun_key" ] && [ "$glorytun_key" != "$(uci -q get glorytun.vpn.key)" ]) || ([ -n "$glorytun_port" ] || [ "$glorytun_port" != "$(uci -q get glorytun.vpn.port)" ])); then
vpn="$(uci -q get openmptcprouter.settings.vpn)"
glorytun_state=0
if [ "$vpn" = "glorytun_tcp" ]; then
@ -1742,7 +1749,7 @@ _set_config_from_vps() {
logger -t "OMR-VPS" "Glorytun restart..."
/etc/init.d/glorytun restart >/dev/null 2>&1
fi
if ([ -n "$glorytun_key" ] && [ "$glorytun_key" != "$(uci -q get glorytun-udp.vpn.key)" ]) || ([ -n "$glorytun_port" ] || [ "$glorytun_port" != "$(uci -q get glorytun-udp.vpn.port)" ]); then
if [ -n "$(uci -q get glorytun.udp)" ] && (([ -n "$glorytun_key" ] && [ "$glorytun_key" != "$(uci -q get glorytun-udp.vpn.key)" ]) || ([ -n "$glorytun_port" ] || [ "$glorytun_port" != "$(uci -q get glorytun-udp.vpn.port)" ])); then
vpn="$(uci -q get openmptcprouter.settings.vpn)"
glorytun_state=0
if [ "$vpn" = "glorytun_udp" ]; then
@ -1833,7 +1840,7 @@ _set_config_from_vps() {
# MLVPN settings
mlvpn_key="$(echo "$vps_config" | jsonfilter -q -e '@.mlvpn.key')"
if [ -n "$mlvpn_key" ] && [ "$mlvpn_key" != "$(uci -q get mlvpn.general.password)" ] && [ -f /etc/init.d/mlvpn ]; then
if [ -n "$(uci -q get mlvpn.general)" ] && [ -n "$mlvpn_key" ] && [ "$mlvpn_key" != "$(uci -q get mlvpn.general.password)" ] && [ -f /etc/init.d/mlvpn ]; then
vpn="$(uci -q get openmptcprouter.settings.vpn)"
mlvpn_state=0
if [ "$vpn" = "mlvpn" ]; then
@ -1855,7 +1862,7 @@ _set_config_from_vps() {
# DSVPN settings
dsvpn_key="$(echo "$vps_config" | jsonfilter -q -e '@.dsvpn.key')"
dsvpn_port="$(echo "$vps_config" | jsonfilter -q -e '@.dsvpn.port')"
if ([ -n "$dsvpn_key" ] && [ "$dsvpn_key" != "$(uci -q get dsvpn.vpn.key)" ]) || ([ -n "$dsvpn_port" ] && [ "$dsvpn_port" != "$(uci -q get dsvpn.vpn.port)" ]); then
if [ -n "$(uci -q get dsvpn.vpn)" ] && (([ -n "$dsvpn_key" ] && [ "$dsvpn_key" != "$(uci -q get dsvpn.vpn.key)" ]) || ([ -n "$dsvpn_port" ] && [ "$dsvpn_port" != "$(uci -q get dsvpn.vpn.port)" ])); then
dsvpn_state=0
if [ "$vpn" = "dsvpn" ]; then
dsvpn_state=1
@ -2231,10 +2238,9 @@ _config_service() {
if [ "$(uci -q get openmptcprouter.settings.firstboot)" != "0" ]; then
[ -n "$(cat /proc/cpuinfo | grep aes)" ] && {
vps_aes="$(echo "$vps_config" | jsonfilter -q -e '@.vps.aes')"
if [ "$vps_aes" != "false" ] && [ "$user_permission" != "ro" ]; then
method="$(uci -q get openmptcprouter.settings.encryption)"
if [ "$vps_aes" != "false" ] && [ "$user_permission" != "ro" ] && [ "$method" != "aes-256-gcm" ]; then
logger -t "OMR-VPS" "CPU support AES, set it by default"
#method="$(uci -q get shadowsocks-libev.sss0.method)"
method="$(uci -q get openmptcprouter.settings.encryption)"
uci -q batch <<-EOF >/dev/null
set openmptcprouter.settings.encryption="aes-256-gcm"
commit openmptcprouter

View file

@ -2,14 +2,14 @@
# max open files
fs.file-max = 512000
# max read buffer
net.core.rmem_max = 16777216
net.core.rmem_max = 7500000
# max write buffer
net.core.wmem_max = 16777216
net.core.wmem_max = 7500000
#net.core.optmem_max = 33554432
# default read buffer
net.core.rmem_default = 16777216
#net.core.rmem_default = 16777216
# default write buffer
net.core.wmem_default = 16777216
#net.core.wmem_default = 16777216
# max processor input queue
net.core.netdev_max_backlog = 8192
# max backlog
@ -24,13 +24,13 @@ net.ipv4.tcp_tw_reuse = 1
# short FIN timeout
#net.ipv4.tcp_fin_timeout = 40
# increase max orphans
net.ipv4.tcp_max_orphans = 32768
net.ipv4.tcp_max_orphans = 16384
# short keepalive time
#net.ipv4.tcp_keepalive_time = 2400
# outbound port range
net.ipv4.ip_local_port_range = 9999 65000
# max SYN backlog
net.ipv4.tcp_max_syn_backlog = 10240
net.ipv4.tcp_max_syn_backlog = 4096
# max timewait sockets held by system simultaneously
net.ipv4.tcp_max_tw_buckets = 6000
# turn on TCP Fast Open on both client and server side
@ -40,11 +40,15 @@ net.ipv4.tcp_rmem = 4096 87380 16777216
# TCP write buffer
net.ipv4.tcp_wmem = 4096 87380 16777216
# TCP buffer
net.ipv4.tcp_mem = 1638400 1638400 1638400
net.ipv4.tcp_mem = 409600 819200 1638400
# UDP buffer
net.ipv4.udp_mem = 4096 131072 67108864
# turn off path MTU discovery
net.ipv4.tcp_mtu_probing = 0
# 1/8 * available memory in receive buffer
net.ipv4.tcp_adv_win_scale=-3
# limits the size of unsent bytes in the write queue
net.ipv4.tcp_notsent_lowat = 131072
# for low-latency network, use cubic instead
# net.ipv4.tcp_congestion_control = balia