Skip to content

Commit

Permalink
fix valid_ip function
Browse files Browse the repository at this point in the history
  • Loading branch information
kx1t committed Oct 23, 2023
1 parent cf4818c commit 4c1be1f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions rootfs/etc/s6-overlay/scripts/radar1090
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,15 @@ s6wrap=(s6wrap --quiet --timestamps --prepend="$(basename "$0")")

function valid_ip()
{
local ip=$1
local stat=1
local ipx=$1
local stat=1
local ip

if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
OIFS=$IFS
IFS='.'
ip=("$ip")
IFS=$OIFS
if [[ $ipx =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
IFS='.' readarray -d '.' -t ip <<< "$ipx"
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
stat=$?
stat=$?
fi
return $stat
}
Expand Down

0 comments on commit 4c1be1f

Please sign in to comment.