Created
July 22, 2025 11:24
-
-
Save cedws/c994638d5ba89c1d15bd979d84a6784b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
# Check if all required parameters are provided | |
if [ "$#" -ne 3 ]; then | |
echo "Usage: $0 <domain_list.txt> <profile_id> <cookie_value>" | |
exit 1 | |
fi | |
DOMAIN_LIST=$1 | |
PROFILE_ID=$2 | |
COOKIE_VALUE=$3 | |
API_URL="https://api.nextdns.io/profiles/${PROFILE_ID}/denylist" | |
# Check if file exists | |
if [ ! -f "$DOMAIN_LIST" ]; then | |
echo "Error: Domain list file not found!" | |
exit 1 | |
fi | |
# Read file line by line | |
while IFS= read -r domain || [[ -n "$domain" ]]; do | |
# Skip empty lines and lines starting with # | |
if [[ -z "$domain" ]] || [[ "$domain" =~ ^[[:space:]]*# ]]; then | |
continue | |
fi | |
# Remove any whitespace | |
domain=$(echo "$domain" | tr -d '[:space:]') | |
echo "Processing domain: $domain" | |
# Make API call | |
response=$(curl -s -X POST "$API_URL" \ | |
-H "Content-Type: application/json" \ | |
-H "Cookie: ${COOKIE_VALUE}" \ | |
-d "{\"id\":\"$domain\",\"active\":true}") | |
# Check if the request was successful | |
if [ -z "$response" ]; then | |
echo "Successfully added $domain" | |
else | |
echo "Error adding $domain: $response" | |
fi | |
# Add a small delay to prevent rate limiting | |
sleep 0.5 | |
done < "$DOMAIN_LIST" | |
echo "Processing complete!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment