Skip to content

Commit

Permalink
sync (#391)
Browse files Browse the repository at this point in the history
  • Loading branch information
suyuan168 authored Dec 15, 2023
2 parents edbd94e + fd35a90 commit ad36ae9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
17 changes: 15 additions & 2 deletions openmptcprouter/files/bin/omr-test-speed-server
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,30 @@ if [ -n "$HOST" ] && [ -n "$PORT" ] && [ -n "$USERNAME" ] && [ -n "$PASSWORD" ];
# /etc/init.d/omr-tracker stop 2>&1 >/dev/null
# multipath ${INTERFACE} off
#fi
if [ -n "$UPLOAD" ]; then
if [ -f /usr/bin/v2ray ]; then
upload_file="/usr/bin/v2ray"
elif [ -f /usr/bin/xray ]; then
upload_file="/usr/bin/xray"
elif [ -f /boot/vmlinuz ]; then
upload_file="/boot/vmlinuz"
elif [ -f /bin/bash ]; then
upload_file="/bin/bash"
else
upload_file="/bin/busybox"
fi
fi
if [ -n "$FASTTEST" ]; then
if [ -n "$UPLOAD" ]; then
avg_speed=$(curl -k --max-time 30 -o /dev/null -qfsS -w '%{speed_upload}' -X POST -d @/boot/vmlinuz -d @/boot/vmlinuz --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest 2>/dev/null)
avg_speed=$(curl -k --max-time 30 -o /dev/null -qfsS -w '%{speed_upload}' -X POST -d @${upload_file} -d @${upload_file} --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest 2>/dev/null)
echo -n "$avg_speed"
else
avg_speed=$(curl -k --max-time 30 -o /dev/null -qfsS -w '%{speed_download}' --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest 2>/dev/null)
echo -n "$avg_speed"
fi
else
if [ -n "$UPLOAD" ]; then
curl -k -o /dev/null -X POST -d @/boot/vmlinuz -d @/boot/vmlinuz --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest || echo
curl -k -o /dev/null -X POST -d @${upload_file} -d @${upload_file} --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest || echo
else
curl -k -o /dev/null --interface $INTERFACE -H "Authorization: Bearer ${KEY}" https://${HOST}:${PORT}/speedtest || echo
fi
Expand Down
14 changes: 12 additions & 2 deletions openmptcprouter/files/etc/init.d/openmptcprouter-vps
Original file line number Diff line number Diff line change
Expand Up @@ -2124,7 +2124,7 @@ _get_token() {
[ "$(uci -q get openmptcprouter.${servername}.disabled)" = "1" ] && return
token=""
_login
[ -z "$token" ] && {
if [ -z "$token" ]; then
reason=""
test_ping() {
_ping_server $1
Expand Down Expand Up @@ -2163,7 +2163,12 @@ _get_token() {
uci -q batch <<-EOF >/dev/null
set openmptcprouter.${servername}.admin_error=1
EOF
}
else
uci -q batch <<-EOF >/dev/null
set openmptcprouter.${servername}.token_error=0
commit openmptcprouter
EOF
fi
echo "$server:$serverport:$token"
}

Expand Down Expand Up @@ -2306,13 +2311,18 @@ token() {
config_foreach _get_token server
}

_fix_server() {
uci -q rename openmptcprouter.$1=server
}

start_service() {
serversnb=0
wanips=""
serial=$(cat /proc/cpuinfo | grep Serial | awk '{print $3}')
[ -z "$serial" ] && [ -f "/usr/sbin/dmidecode" ] && serial=$(/usr/sbin/dmidecode -t 1 | egrep 'Serial' | awk '{print $3}')
uci -q set openmptcprouter.settings.serial=${serial}
config_load openmptcprouter
config_foreach _fix_server openmptcprouter
config_foreach _count_server server
config_foreach _get_local_wan_ip interface
config_foreach _config_service server
Expand Down

0 comments on commit ad36ae9

Please sign in to comment.