1
0
Fork 0
mirror of https://github.com/notwa/rc synced 2024-11-13 20:39:04 -08:00

just use $REPLY instead of $reply in asn

This commit is contained in:
Connor Olding 2024-08-06 17:43:18 -07:00
parent 1f1297d6ee
commit c953c670f7

20
sh/asn
View file

@ -23,7 +23,7 @@ __asn_txt() {
declare -A __asn_replies __asn_descs declare -A __asn_replies __asn_descs
__asn_lookup() { __asn_lookup() {
local remote= ip= ish= reply= sep= asn= desc= local remote= ip= ish= REPLY= sep= asn= desc=
remote=asn.cymru.com remote=asn.cymru.com
ip="${1:?missing argument}" ip="${1:?missing argument}"
ish="${ip%.*}" ish="${ip%.*}"
@ -31,18 +31,17 @@ __asn_lookup() {
__asn_rev "$ip" __asn_rev "$ip"
if [ -n "${__asn_replies["$ish"]}" ]; then if [ -n "${__asn_replies["$ish"]}" ]; then
reply="${__asn_replies["$ish"]}" REPLY="${__asn_replies["$ish"]}"
else else
__asn_txt "$REPLY.origin.$remote" || return __asn_txt "$REPLY.origin.$remote" || return
reply="$REPLY" __asn_replies["$ish"]="$REPLY"
__asn_replies["$ish"]="$reply"
fi fi
asns="${reply%%"$sep"*}" reply="${reply#"$asns$sep"}" asns="${REPLY%%"$sep"*}" REPLY="${REPLY#"$asns$sep"}"
subnet="${reply%%"$sep"*}" reply="${reply#"$subnet$sep"}" subnet="${REPLY%%"$sep"*}" REPLY="${REPLY#"$subnet$sep"}"
country="${reply%%"$sep"*}" reply="${reply#"$country$sep"}" country="${REPLY%%"$sep"*}" REPLY="${REPLY#"$country$sep"}"
registry="${reply%%"$sep"*}" reply="${reply#"$registry$sep"}" registry="${REPLY%%"$sep"*}" REPLY="${REPLY#"$registry$sep"}"
date="${reply}" date="${REPLY}"
description= description=
while [ -n "$asns" ]; do while [ -n "$asns" ]; do
@ -51,8 +50,7 @@ __asn_lookup() {
desc="${__asn_descs["$asn"]}" desc="${__asn_descs["$asn"]}"
else else
__asn_txt "AS$asn.$remote" || return __asn_txt "AS$asn.$remote" || return
reply="$REPLY" desc="${REPLY##* | }"
desc="${reply##* | }"
__asn_descs["$asn"]="$desc" __asn_descs["$asn"]="$desc"
fi fi