Extracting the onion address from about array
This commit is contained in:
parent
f2c9325b9b
commit
6d66aacf2e
|
@ -332,15 +332,39 @@ function show_domains {
|
|||
|
||||
# shellcheck disable=SC2068
|
||||
selected=$(dialog --backtitle $"Freedombone Control Panel" --title $"Domains" --menu $"Use Shift+cursors to select and copy onion addresses" $((height-4)) $((width-4)) $((height-4)) "${W[@]}" 3>&2 2>&1 1>&3)
|
||||
if [[ "$selected" != *'.onion'* ]]; then
|
||||
if [ ! "$selected" ]; then
|
||||
return
|
||||
fi
|
||||
intermediate=$(echo "$selected" | awk -F '.' '{print $2}')
|
||||
# obtain the addresses from the key by itterating through
|
||||
# the array. This is quite crude and maybe there's a better way
|
||||
key_found=
|
||||
selected_addresses=
|
||||
for key in "${W[@]}";
|
||||
do
|
||||
if [ $key_found ]; then
|
||||
selected_addresses="$key"
|
||||
break
|
||||
fi
|
||||
if [[ "$key" == "$selected" ]]; then
|
||||
key_found=1
|
||||
fi
|
||||
done
|
||||
# Was the key matched?
|
||||
if [ ! "$selected_addresses" ]; then
|
||||
return
|
||||
fi
|
||||
# addresses were found - is this an onion?
|
||||
if [[ "$selected_addresses" != *".onion"* ]]; then
|
||||
return
|
||||
fi
|
||||
# There are two forms of addresses: "x / y.onion" and "x.onion"
|
||||
intermediate=$(echo "$selected_addresses" | awk -F '.' '{print $2}')
|
||||
if [[ "$intermediate" == *'/'* ]]; then
|
||||
onion_addr=$(echo "$intermediate" | awk -F ' ' '{print $3}').onion
|
||||
else
|
||||
onion_addr="$selected".onion
|
||||
onion_addr="$selected_addresses".onion
|
||||
fi
|
||||
# show the onion address as a QR code
|
||||
clear
|
||||
echo "$onion_addr"
|
||||
echo -n "$onion_addr" | qrencode -t UTF8
|
||||
|
|
Loading…
Reference in New Issue