Sindbad~EG File Manager

Current Path : /opt/nginxhttpd_/etc/openresty_config/utils/
Upload File :
Current File : //opt/nginxhttpd_/etc/openresty_config/utils/asn-prefixes.sh

#!/bin/bash

# $1 : string to display
function exitError() {
  echo -e "${RED}$1${RESTORE}"
  exit 1
}

jq --version > /dev/null 2>/dev/null || exitError "jq is required. yum install jq"

ASN="AS15169"
if test "$1" != "" ; then
  ASN=$1
fi

URL="https://stat.ripe.net/data/announced-prefixes/data.json?resource=$ASN"

echo "#$ASN Source:$URL"
echo "geo \$remote_addr \$map_$ASN {"
echo 'default              0;'
curl -sX GET -o - "$URL" 2> /dev/null | jq -r '.data.prefixes[].prefix' | while read ip ; do
  echo "$ip  1;"
done | grep -E '(^([0-9]+\.){3}[0-9]+\/[0-9]+  1;$)|(^\#)|(^[a-fA-F0-9:]+\/[0-9]+  1;$)' | column -t
echo '}';

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists