mirror of
https://github.com/Ysurac/openmptcprouter-feeds.git
synced 2025-03-09 15:40:03 +00:00
Add support for httping in omr-tracker
This commit is contained in:
parent
10eef8eb74
commit
c2312ec7fe
3 changed files with 27 additions and 3 deletions
|
@ -26,8 +26,9 @@ o.default = "2"
|
|||
o.datatype = "range(1, 100)"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(ListValue, "type", translate("Type"), translate("Always ping gateway, then test connection by ping or dns. None mode only ping gateway."))
|
||||
o = s:option(ListValue, "type", translate("Type"), translate("Always ping gateway, then test connection by ping, httping or dns. None mode only ping gateway."))
|
||||
o:value("ping","ping")
|
||||
o:value("httping","httping")
|
||||
o:value("dns","dns")
|
||||
o:value("none","none")
|
||||
|
||||
|
@ -65,8 +66,9 @@ o.default = "2"
|
|||
o.datatype = "range(1, 100)"
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(ListValue, "type", translate("Type"), translate("Always ping gateway, then test connection by ping or dns. None mode only ping gateway."))
|
||||
o = s:option(ListValue, "type", translate("Type"), translate("Always ping gateway, then test connection by ping, httping or dns. None mode only ping gateway."))
|
||||
o:value("ping","ping")
|
||||
o:value("httping","httping")
|
||||
o:value("dns","dns")
|
||||
o:value("none","none")
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ define Package/$(PKG_NAME)
|
|||
CATEGORY:=Network
|
||||
TITLE:=OpenMPTCProuter tracker
|
||||
PKGARCH:=all
|
||||
DEPENDS:=+bind-dig
|
||||
DEPENDS:=+bind-dig +httping
|
||||
endef
|
||||
|
||||
define Package/$(PKG_NAME)/description
|
||||
|
|
|
@ -92,6 +92,25 @@ _ping() {
|
|||
false
|
||||
}
|
||||
|
||||
_httping() {
|
||||
local host=$1
|
||||
local deviceip=$2
|
||||
local localip=$3
|
||||
ret=$(httping "${host}" \
|
||||
-y "${deviceip}" \
|
||||
-t "$OMR_TRACKER_TIMEOUT" \
|
||||
-c 1 \
|
||||
-q
|
||||
) && echo "$ret" | grep -sq "1 ok" && {
|
||||
if [ "$localip" = "yes" ]; then
|
||||
OMR_TRACKER_LATENCY=$(echo "$ret" | cut -d "/" -s -f5 | cut -d "." -f1)
|
||||
_update_rto "$OMR_TRACKER_LATENCY"
|
||||
fi
|
||||
return
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
_dns() {
|
||||
local host=$1
|
||||
local deviceip=$2
|
||||
|
@ -152,6 +171,9 @@ while true; do
|
|||
if [ "$OMR_TRACKER_TYPE" = "ping" ]; then
|
||||
_ping "$OMR_TRACKER_HOST" "$OMR_TRACKER_DEVICE_IP" "yes"
|
||||
status=$?
|
||||
elif [ "$OMR_TRACKER_TYPE" = "httping" ]; then
|
||||
_httping "$OMR_TRACKER_HOST" "$OMR_TRACKER_DEVICE_IP" "yes"
|
||||
status=$?
|
||||
elif [ "$OMR_TRACKER_TYPE" = "dns" ]; then
|
||||
_dns "$OMR_TRACKER_HOST" "$OMR_TRACKER_DEVICE_IP" "yes"
|
||||
status=$?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue