working but inefficient script to remove invalid proxies from db
This commit is contained in:
33
remove_bad_proxies_from_proxylist.bash
Normal file
33
remove_bad_proxies_from_proxylist.bash
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
remove_invalid_proxy_using_a_slow_bash_script() {
|
||||
local args=$*
|
||||
args="${args// /\' OR proxy=\'}"
|
||||
echo "running sqlite query -- DELETE FROM proxylist WHERE proxy='${args}'"
|
||||
|
||||
sqlite3 proxylist.sqlite "DELETE FROM proxylist WHERE proxy='${args}'"
|
||||
}
|
||||
|
||||
args=()
|
||||
while IFS=: read -r ip port; do
|
||||
IFS=\. read -r a b c d <<<"$ip"
|
||||
|
||||
if [[ $a =~ ^0[0-9] || $a -lt 0 || $a -gt 255 || $b =~ ^0[0-9] || $b -lt 0 || $b -gt 255 || $c =~ ^0[0-9] || $c -lt 0 || $c -gt 255 || $d =~ ^0[0-9] || $d -lt 0 || $d -gt 255 ]]; then args+=("$ip:$port")
|
||||
elif [[ $port =~ ^0 || $port -lt 1 || $port -gt 65535 ]]; then args+=("$ip:$port")
|
||||
fi
|
||||
done < <(sqlite3 proxylist.sqlite "select proxy from proxylist")
|
||||
|
||||
aargs=()
|
||||
for arg in ${args[@]}; do
|
||||
aargs+=($arg)
|
||||
|
||||
if ((${#aargs[@]} >= 200)); then
|
||||
remove_invalid_proxy_using_a_slow_bash_script "${aargs[*]}"
|
||||
aargs=()
|
||||
fi
|
||||
done
|
||||
|
||||
if ((${#aargs[@]})); then
|
||||
remove_invalid_proxy_using_a_slow_bash_script "${args[*]}"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user