From 8ea888f6fd49cb548a460acec2cd0027370399e0 Mon Sep 17 00:00:00 2001 From: kenzok8 Date: Mon, 9 Dec 2024 20:42:59 +0800 Subject: [PATCH] update 2024-12-09 20:42:59 --- floatip/Makefile | 2 +- floatip/files/floatip.sh | 39 +++++++++++++++++++++++---------------- v2ray-geoview/Makefile | 4 ++-- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/floatip/Makefile b/floatip/Makefile index 86f54d882..d59bb2692 100644 --- a/floatip/Makefile +++ b/floatip/Makefile @@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=floatip -PKG_VERSION:=1.0.6 +PKG_VERSION:=1.0.8 PKG_RELEASE:=1 PKG_MAINTAINER:=jjm2473 diff --git a/floatip/files/floatip.sh b/floatip/files/floatip.sh index eff5989e9..bf50583b3 100755 --- a/floatip/files/floatip.sh +++ b/floatip/files/floatip.sh @@ -64,19 +64,25 @@ set_lan_ping() { /etc/init.d/firewall reload 2>&1 } +safe_sleep() { + local sec="$1" + [[ "$sec" -lt 1 ]] && sec=1 + sleep $sec +} + . /lib/functions.sh fallback_loop() { local set_ip check_ip set_net set_prefix config_get set_ip "main" set_ip - config_get check_ip "main" check_ip - [[ "$set_ip" = "*/*" ]] || set_ip="$set_ip/32" + [[ -n "$set_ip" ]] || return 1 + [[ "$set_ip" = "*/*" ]] || set_ip="$set_ip/$DEFAULT_PREFIX" eval "$(ipcalc.sh "$set_ip" )";set_net=$NETWORK;set_prefix=$PREFIX;set_ip=$IP - [[ "$set_net" = 0.0.0.0 ]] && set_net=192.168.100.0 - [[ "$set_prefix" = 32 ]] && set_prefix=$DEFAULT_PREFIX - [[ "$set_ip" = 0.0.0.0 ]] && set_ip=192.168.100.3 local ipaddr="$set_ip/$set_prefix" + echo "ipaddr=$ipaddr" + local valid_check_ip cip + config_get check_ip "main" check_ip for cip in $check_ip; do eval "$(ipcalc.sh $cip/$set_prefix )" [[ "$NETWORK" = "$set_net" ]] && valid_check_ip="$valid_check_ip $cip" @@ -108,16 +114,16 @@ fallback_loop() { else dead_counter=0 fi - [[ $consume_time -lt 10 ]] && sleep $((10 - $consume_time)) + safe_sleep $((10 - $consume_time)) continue fi if [[ $floatip_up = 1 ]]; then - [[ $consume_time -lt 5 ]] && sleep $((5 - $consume_time)) + safe_sleep $((5 - $consume_time)) continue fi dead_counter=$(($dead_counter + 1)) if [[ $dead_counter -lt 3 ]]; then - [[ $consume_time -lt 10 ]] && sleep $((10 - $consume_time)) + safe_sleep $((10 - $consume_time)) continue fi echo "no host alive, set up floatip $ipaddr" >&2 @@ -128,14 +134,13 @@ fallback_loop() { } main_loop() { - local set_ip set_net set_prefix + local set_ip set_prefix config_get set_ip "main" set_ip - [[ "$set_ip" = "*/*" ]] || set_ip="$set_ip/32" - eval "$(ipcalc.sh "$set_ip" )";set_net=$NETWORK;set_prefix=$PREFIX;set_ip=$IP - [[ "$set_net" = 0.0.0.0 ]] && set_net=192.168.100.0 - [[ "$set_prefix" = 32 ]] && set_prefix=$DEFAULT_PREFIX - [[ "$set_ip" = 0.0.0.0 ]] && set_ip=192.168.100.3 + [[ -n "$set_ip" ]] || return 1 + [[ "$set_ip" = "*/*" ]] || set_ip="$set_ip/$DEFAULT_PREFIX" + eval "$(ipcalc.sh "$set_ip" )";set_prefix=$PREFIX;set_ip=$IP local ipaddr="$set_ip/$set_prefix" + echo "ipaddr=$ipaddr" local check_urls check_url_timeout config_get check_urls "main" check_url @@ -177,14 +182,16 @@ main_loop() { set_up "$ipaddr" floatip_up=1 fi + else + set_lan_ping 0 fi - [[ $consume_time -lt 5 ]] && sleep $((5 - $consume_time)) + safe_sleep $((5 - $consume_time)) continue else if [[ $url_pass = 0 ]]; then dead_counter=$(($dead_counter + 1)) if [[ $dead_counter -lt 3 ]]; then - [[ $consume_time -lt 5 ]] && sleep $((5 - $consume_time)) + safe_sleep $((5 - $consume_time)) continue fi echo "set down floatip, and disable ping" >&2 diff --git a/v2ray-geoview/Makefile b/v2ray-geoview/Makefile index c97025db1..8fe6c252f 100644 --- a/v2ray-geoview/Makefile +++ b/v2ray-geoview/Makefile @@ -1,12 +1,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=geoview -PKG_VERSION:=0.0.9 +PKG_VERSION:=0.1.0 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=https://codeload.github.com/snowie2000/geoview/tar.gz/$(PKG_VERSION)? -PKG_HASH:=ba0af14cd7a6ce457584ab4754331848ed78240ae39abdf65fef646df0130c2e +PKG_HASH:=f957ccda8177657ce386c2a823cdf0d2746a0c03ce2e1a767cf9da12dccc476b PKG_LICENSE:=Apache-2.0 PKG_LICENSE_FILES:=LICENSE