-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
https://github.com/qzeleza/kvas/issues/53
- Loading branch information
Showing
21 changed files
with
267 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
VERSION=1.1.5 | ||
STAGE=final | ||
RELEASE=26 | ||
RELEASE=28 |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/sh | ||
|
||
HOST_LIST=/opt/etc/hosts.list | ||
TABLE_NAME=$(cat < /opt/apps/kvas/bin/libs/ndm | grep 'table_name=' | cut -d'=' -f2) | ||
IP_FILTER='[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Добавляем переданные в функцию IP адреса в ipset таблицу unblock | ||
# ------------------------------------------------------------------------------ | ||
add_host_by_iplist_to_ipset(){ | ||
host=${1//\*/} | ||
# получаем список из адресов от текущего dns сервера | ||
# и исключаем из списка адреса типа 0.0.0.0 | ||
ip_list=$(kdig +short "${host}" @localhost \ | ||
| grep -Eo "${IP_FILTER}" \ | ||
| grep -v '0.0.0.0' ) | ||
|
||
# если список не пуст | ||
if [ -n "${ip_list}" ]; then | ||
for ip in ${ip_list}; do | ||
ipset list "${TABLE_NAME}" | grep -q "${ip}" || { | ||
ipset -exist add "${TABLE_NAME}" "${ip}" | ||
mess="Обнаружен новый IP=${ip} для домена ${host} и успешно добавлен в таблицу ipset." | ||
# echo "${mess}" | ||
logger -t "КВАС" "${mess}" | ||
} | ||
done | ||
|
||
fi | ||
} | ||
|
||
# ------------------------------------------------------------------------------ | ||
# Добавляем список AS IP диапазонов, в который может входить переданный host | ||
# ------------------------------------------------------------------------------ | ||
add_host_by_ASlist_to_ipset(){ | ||
host=${1//\*/}; | ||
if [ "${host}" ]; then | ||
for ip in $(kdig +short "${host}" @localhost); do | ||
as_number=$(whois -h whois.radb.net "${ip}" | grep 'origin:' | tr -d ' ' | cut -d ':' -f2) | ||
for net in $(whois -h whois.radb.net "!g${as_number}" | tr '\n' ' '); do | ||
if echo "${net}" | grep -Eo "${IP_FILTER}" | grep -qv '0.0.0.0' ; then | ||
ipset -exist add "${TABLE_NAME}" "${net}" &>/dev/null | ||
fi | ||
done | ||
done | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.