„update_blocklist.sh“ ändern
This commit is contained in:
parent
5751553cd1
commit
0d8c417056
1 changed files with 7 additions and 5 deletions
|
@ -245,7 +245,6 @@ sec_to_time() {
|
||||||
echo "INSERT OR IGNORE INTO AutoBlockIP ('IP', 'RecordTime', 'ExpireTime', 'Deny', 'IPStd', 'Type', 'Meta') VALUES " > "$sql_statement"
|
echo "INSERT OR IGNORE INTO AutoBlockIP ('IP', 'RecordTime', 'ExpireTime', 'Deny', 'IPStd', 'Type', 'Meta') VALUES " > "$sql_statement"
|
||||||
|
|
||||||
while read BLOCKED_IP ; do
|
while read BLOCKED_IP ; do
|
||||||
let progress_start=progress_start+1
|
|
||||||
|
|
||||||
# Check if IP valid
|
# Check if IP valid
|
||||||
VALID_IPv4=$(echo "$BLOCKED_IP" | grep -Eo "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" | wc -l)
|
VALID_IPv4=$(echo "$BLOCKED_IP" | grep -Eo "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$" | wc -l)
|
||||||
|
@ -253,7 +252,6 @@ while read BLOCKED_IP ; do
|
||||||
# check GeoIP
|
# check GeoIP
|
||||||
if [ "$useGeoIP" = blockonly ] || [ "$useGeoIP" = blockother ]; then
|
if [ "$useGeoIP" = blockonly ] || [ "$useGeoIP" = blockother ]; then
|
||||||
request_GeoIP_result="$(request_GeoIP "$BLOCKED_IP")"
|
request_GeoIP_result="$(request_GeoIP "$BLOCKED_IP")"
|
||||||
|
|
||||||
if grep -qi "is not in the database" <<<"$request_GeoIP_result" ; then
|
if grep -qi "is not in the database" <<<"$request_GeoIP_result" ; then
|
||||||
# is not in the database
|
# is not in the database
|
||||||
request_GeoIP_result="empty"
|
request_GeoIP_result="empty"
|
||||||
|
@ -261,10 +259,12 @@ while read BLOCKED_IP ; do
|
||||||
|
|
||||||
if [ "$useGeoIP" = blockonly ] && echo "${countries[@]}" | grep -qiv "$request_GeoIP_result" ; then
|
if [ "$useGeoIP" = blockonly ] && echo "${countries[@]}" | grep -qiv "$request_GeoIP_result" ; then
|
||||||
let skipByGeoIP=$skipByGeoIP+1
|
let skipByGeoIP=$skipByGeoIP+1
|
||||||
|
let progress_start=progress_start+1
|
||||||
[ "$LOGLEVEL" -eq 2 ] && echo "continue - $BLOCKED_IP - country: $request_GeoIP_result"
|
[ "$LOGLEVEL" -eq 2 ] && echo "continue - $BLOCKED_IP - country: $request_GeoIP_result"
|
||||||
continue
|
continue
|
||||||
elif [ "$useGeoIP" = blockother ] && echo "${countries[@]}" | grep -qi "$request_GeoIP_result" ; then
|
elif [ "$useGeoIP" = blockother ] && echo "${countries[@]}" | grep -qi "$request_GeoIP_result" ; then
|
||||||
let skipByGeoIP=$skipByGeoIP+1
|
let skipByGeoIP=$skipByGeoIP+1
|
||||||
|
let progress_start=progress_start+1
|
||||||
[ "$LOGLEVEL" -eq 2 ] && echo "continue - $BLOCKED_IP - country: $request_GeoIP_result"
|
[ "$LOGLEVEL" -eq 2 ] && echo "continue - $BLOCKED_IP - country: $request_GeoIP_result"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
@ -277,15 +277,17 @@ while read BLOCKED_IP ; do
|
||||||
IPv6=$(printf "0000:0000:0000:0000:0000:FFFF:%02X%02X:%02X%02X" $IPv4)
|
IPv6=$(printf "0000:0000:0000:0000:0000:FFFF:%02X%02X:%02X%02X" $IPv4)
|
||||||
|
|
||||||
echo "('$BLOCKED_IP','$UNIXTIME','$UNIXTIME_DELETE_IP','$Deny','$IPv6','$TYPE','$META')," >> "$sql_statement"
|
echo "('$BLOCKED_IP','$UNIXTIME','$UNIXTIME_DELETE_IP','$Deny','$IPv6','$TYPE','$META')," >> "$sql_statement"
|
||||||
|
|
||||||
countadded=$(( $countadded + 1 ))
|
countadded=$(( $countadded + 1 ))
|
||||||
|
|
||||||
if [ "$LOGLEVEL" -eq 2 ]; then
|
if [ "$LOGLEVEL" -eq 2 ]; then
|
||||||
echo "IP added to Database! --> $BLOCKED_IP"
|
echo "IP added to Database! --> $BLOCKED_IP"
|
||||||
elif [ "$LOGLEVEL" -eq 1 ] && [ "$PROGRESSBAR" -eq 1 ]; then
|
elif [ "$LOGLEVEL" -eq 1 ] && [ "$PROGRESSBAR" -eq 1 ]; then
|
||||||
# progressbar:
|
# progressbar:
|
||||||
|
let progress_start=progress_start+1
|
||||||
progressbar ${progress_start} ${progress_end}
|
progressbar ${progress_start} ${progress_end}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done < "$blocklist_list"
|
done < "$blocklist_list"
|
||||||
|
|
||||||
if [ "$countofdiffs" -ge 1 ] ; then
|
if [ "$countofdiffs" -ge 1 ] ; then
|
||||||
|
|
Loading…
Reference in a new issue