Skip to content

Commit

Permalink
ci: update ipset generation workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Aetherinox committed Nov 4, 2024
1 parent d8da1ae commit 3a7a978
Show file tree
Hide file tree
Showing 138 changed files with 2,384 additions and 199 deletions.
3 changes: 3 additions & 0 deletions .github/blocks/isp/aol.ipset
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
62.51.0.0/16
62.78.0.0/19
195.93.0.0/17
1 change: 1 addition & 0 deletions .github/blocks/privacy/01.ipset
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# a wide variety of bots come from this company (or customers of the company),
# including scrapers, brute-forcing, email spam, data collection, etc.
#
# https://raw.githubusercontent.com/cbuijs/ipasn/master/asn/as10439.list
# #

135.84.216.0/24
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions .github/categories/isp_aol_ipset.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Internet Service Provider (ISP)
1 change: 1 addition & 0 deletions .github/categories/isp_att_ipset.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Internet Service Provider (ISP)
1 change: 1 addition & 0 deletions .github/categories/isp_cablevision_ipset.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Internet Service Provider (ISP)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Internet Service Provider (ISP)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 12 additions & 0 deletions .github/descriptions/isp_aol_ipset.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Historic AOL LLC (Internet Service Provider)
# Oath Holdings Inc.
#
# Website https://aol.com
# Parent organization: Warner Bros. Discovery
# Founded 1985
# Registry RIPE
#
# This ISP has slowly been winding down over the years, with less and less servers. This is
# especially true since the messenger service ICQ was shut down on June 26, 2024.
#
# Be aware that this ASN may disappear in the future as less IP blocks are assigned.
10 changes: 10 additions & 0 deletions .github/descriptions/isp_att_ipset.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# AT&T Internet (Internet Service Provider)
#
# Website https://att.com/internet/
# Parent organization: AT&T Communications
# Founded September 19, 2016
#
# AT&T Internet is an AT&T brand of broadband internet service. Previously, AT&T Internet was
# branded as U-verse Internet and bundled with U-verse TV, which was spun off into the newly
# independent DirecTV in 2021. AT&T Internet plans powered by fiber-optic cable use the AT&T
# Fiber brand.
17 changes: 17 additions & 0 deletions .github/descriptions/isp_cablevision_ipset.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Cablevision (Internet Service Provider)
#
# Website https://cablevision.com
# Founded 1973
# Status Acquired by Altice (June 21, 2016)
#
# If you wish to block this internet service provider, it is recommended that you use both this blocklist,
# as well as the blocklist for Suddenlink / Optimum.
# - https://raw.githubusercontent.com/Aetherinox/blocklists/main/blocklists/isp/isp_suddenlink_optimum.ipset
#
# After Altice acquired Cablevision Systems Corporation on November 30, 2016, Suddenlink was combined with
# Cablevision. Together with Optimum, the name used by Cablevision for its products, Altice USA became the
# United States' fourth largest cable operator with 4.6 million subscribers, and the sixth largest Pay TV
# service provider with 3.5 million subscribers. On August 1, 2022, Suddenlink rebranded into Optimum.
#
# This blocklist contains mostly Cablevision IP addresses, however, it also includes some blocks which
# carried over from the acquisition of Suddenlink and Optimum which are registered as the same ASN.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Time Warner Cable, Charter Communications, Spectrum (Internet Service Provider)
#
# Website https://spectrum.com
# Founded Time Warner Cable (1973), Spectrum (2014)
# Status Merged into Charter Spectrum as of 2016.
#
# Time Warner Cable, Inc. was acquired by Charter Communications on May 18, 2016, which formed Charter Spectrum.
# - https://ir.charter.com/news-releases/news-release-details/charter-communications-merge-time-warner-cable-and-acquire
#
# This list merges all three companies together to block the overall network.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions .github/expires/isp_aol_ipset.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7 days
1 change: 1 addition & 0 deletions .github/expires/isp_att_ipset.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7 days
1 change: 1 addition & 0 deletions .github/expires/isp_cablevision_ipset.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7 days
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7 days
1 change: 1 addition & 0 deletions .github/expires/isp_suddenlink_optimum_ipset.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7 days
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
70 changes: 64 additions & 6 deletions .github/scripts/bl-block.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@
# copies local ipsets from .github/blocks/${ARG_BLOCKS_CAT}/*.ipset
#
# @terminal .github/scripts/bl-block.sh \
# blocklists/02_privacy_general.ipset \
# blocklists/privacy/privacy_general.ipset \
# privacy
#
# @terminal .github/scripts/bl-block.sh \
# blocklists/isp/isp_aol.ipset \
# isp/aol.ipset
#
# @workflow # Privacy › General
# chmod +x ".github/scripts/bl-block.sh"
# run_general=".github/scripts/bl-block.sh 02_privacy_general.ipset privacy"
Expand All @@ -31,7 +35,8 @@
# #

APP_THIS_FILE=$(basename "$0") # current script file
APP_THIS_DIR="${PWD}" # Current script directory
APP_THIS_DIR="${PWD}" # current script directory
APP_GITHUB_DIR="${APP_THIS_DIR}/.github" # .github folder

# #
# vars > colors
Expand Down Expand Up @@ -68,6 +73,40 @@ GREY1="\e[38;5;240m"
GREY2="\e[38;5;244m"
GREY3="\e[38;5;250m"

# #
# print an error and exit with failure
# $1: error message
# #

function error()
{
echo -e "${GREY2}${APP_THIS_FILE}${RESET}: \n ${BOLD}${RED}Error${NORMAL}: ${RESET}$1"
echo -e
exit 0
}

# #
# Sort Results
#
# @usage line=$(parse_spf_record "${ip}" | sort_results)
# #

sort_results()
{
declare -a ipv4 ipv6

while read -r line ; do
if [[ ${line} =~ : ]] ; then
ipv6+=("${line}")
else
ipv4+=("${line}")
fi
done

[[ -v ipv4[@] ]] && printf '%s\n' "${ipv4[@]}" | sort -g -t. -k1,1 -k 2,2 -k 3,3 -k 4,4 | uniq
[[ -v ipv6[@] ]] && printf '%s\n' "${ipv6[@]}" | sort -g -t: -k1,1 -k 2,2 -k 3,3 -k 4,4 -k 5,5 -k 6,6 -k 7,7 -k 8,8 | uniq
}

# #
# Arguments
#
Expand Down Expand Up @@ -189,8 +228,27 @@ fi
# #

if [ -d .github/blocks/ ]; then
for APP_FILE_TEMP in .github/blocks/${ARG_BLOCKS_CAT}/*.ipset; do
echo -e " 📒 Reading static block ${ORANGE2}${APP_FILE_TEMP}${RESET}"

# #
# Determines if the category provided is either a folder, or a file ending with `.ipset`.
#
# if a folder is provided, all files in the folder will be looped and loaded.
# if a file is provided, only that one file will be loaded.
# #

APP_BLOCK_TARGET=".github/blocks/${ARG_BLOCKS_CAT}/*.ipset"
if [[ "$ARG_BLOCKS_CAT" == *ipset ]]; then
APP_BLOCK_TARGET=".github/blocks/${ARG_BLOCKS_CAT}"
fi

# #
# Block folder specified. Each file in folder will be loaded. does not have .ipset at the end
#
# @usage .github/scripts/bl-block.sh blocklists/isp/isp_aol.ipset isp/aol
# #

for APP_FILE_TEMP in ${APP_BLOCK_TARGET}; do
echo -e " 📒 Reading static block ${ORANGE2}${APP_FILE_TEMP}${RESET}"

# #
# calculate how many IPs are in a subnet
Expand Down Expand Up @@ -261,7 +319,7 @@ if [ -d .github/blocks/ ]; then

echo -e " ➕ Added ${FUCHSIA2}${BLOCKS_COUNT_TOTAL_IP} IPs${RESET} and ${FUCHSIA2}${BLOCKS_COUNT_TOTAL_SUBNET} Subnets${RESET} to ${BLUE2}${APP_FILE_PERM}${RESET}"
echo -e
done
done
fi

# #
Expand All @@ -271,7 +329,7 @@ fi
# - remove .sort temp file
# #

APP_OUT=$(cat ${APP_FILE_PERM} | grep -v "^#" | sort -n | awk '{if (++dup[$0] == 1) print $0;}' > ${APP_FILE_PERM}.sort)
APP_OUT=$(cat ${APP_FILE_PERM} | grep -vi "^#|^;|^$" | sort -n | awk '{if (++dup[$0] == 1) print $0;}' > ${APP_FILE_PERM}.sort)
sed -i 's/[[:blank:]]*$//' ${APP_FILE_PERM}.sort
> ${APP_FILE_PERM}
cat ${APP_FILE_PERM}.sort >> ${APP_FILE_PERM}
Expand Down
41 changes: 38 additions & 3 deletions .github/scripts/bl-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
# #

APP_THIS_FILE=$(basename "$0") # current script file
APP_THIS_DIR="${PWD}" # Current script directory
APP_THIS_DIR="${PWD}" # current script directory
APP_GITHUB_DIR="${APP_THIS_DIR}/.github" # .github folder

# #
## #
# vars > colors
#
# Use the color table at:
Expand Down Expand Up @@ -64,6 +65,40 @@ GREY1="\e[38;5;240m"
GREY2="\e[38;5;244m"
GREY3="\e[38;5;250m"

# #
# print an error and exit with failure
# $1: error message
# #

function error()
{
echo -e "${GREY2}${APP_THIS_FILE}${RESET}: \n ${BOLD}${RED}Error${NORMAL}: ${RESET}$1"
echo -e
exit 0
}

# #
# Sort Results
#
# @usage line=$(parse_spf_record "${ip}" | sort_results)
# #

sort_results()
{
declare -a ipv4 ipv6

while read -r line ; do
if [[ ${line} =~ : ]] ; then
ipv6+=("${line}")
else
ipv4+=("${line}")
fi
done

[[ -v ipv4[@] ]] && printf '%s\n' "${ipv4[@]}" | sort -g -t. -k1,1 -k 2,2 -k 3,3 -k 4,4 | uniq
[[ -v ipv6[@] ]] && printf '%s\n' "${ipv6[@]}" | sort -g -t: -k1,1 -k 2,2 -k 3,3 -k 4,4 -k 5,5 -k 6,6 -k 7,7 -k 8,8 | uniq
}

# #
# Arguments
#
Expand Down Expand Up @@ -244,7 +279,7 @@ done
# Get IP list
# #

list_ips=$(echo "${APP_OUT}" | grep -v "^#" | sort -n | awk '{if (++dup[$0] == 1) print $0;}' > ${APP_FILE_TEMP})
list_ips=$(echo "${APP_OUT}" | grep -vi "^#|^;|^$" | sort -n | awk '{if (++dup[$0] == 1) print $0;}' > ${APP_FILE_TEMP})
sed -i '/[#;]/{s/#.*//;s/;.*//;/^$/d}' ${APP_FILE_TEMP} # remove # and ; comments
sed -i 's/\-.*//' ${APP_FILE_TEMP} # remove hyphens for ip ranges
sed -i 's/[[:blank:]]*$//' ${APP_FILE_TEMP} # remove space / tab from EOL
Expand Down
Loading

0 comments on commit 3a7a978

Please sign in to comment.