Fix Proof of Caching to skip system domains and test direct to server
Changes: - Filter out system/template domains (cloudvpstemplate, cprapid, IP-based) - Skip domains under /nobody/ user - Test directly to server IP using --resolve (bypasses CDN/Cloudflare) - Show server IP being tested for transparency - Now correctly finds and tests actual user domains
This commit is contained in:
@@ -170,11 +170,19 @@ get_cpanel_domains() {
|
||||
continue
|
||||
fi
|
||||
|
||||
# Skip system/template domains
|
||||
if [[ "$domain" =~ cloudvpstemplate\. ]] || \
|
||||
[[ "$domain" =~ cprapid\. ]] || \
|
||||
[[ "$domain" =~ ^[0-9\-]+\. ]] || \
|
||||
[[ "$domain_file" =~ /nobody/ ]]; then
|
||||
continue
|
||||
fi
|
||||
|
||||
# Only add if it looks like a domain (has a dot, not . or ..)
|
||||
if [[ "$domain" != "." && "$domain" != ".." && "$domain" =~ \. ]]; then
|
||||
domains+=("$domain")
|
||||
fi
|
||||
done < <(find /var/cpanel/userdata -type f 2>/dev/null | head -20)
|
||||
done < <(find /var/cpanel/userdata -type f 2>/dev/null | head -50)
|
||||
fi
|
||||
|
||||
printf '%s\n' "${domains[@]}"
|
||||
@@ -723,16 +731,22 @@ proof_of_caching() {
|
||||
|
||||
if [ -z "$domain" ]; then
|
||||
print_error "No domains found to test"
|
||||
echo ""
|
||||
echo "Tip: Make sure you have at least one active domain/website configured"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Get server IP for direct testing (bypasses CDN)
|
||||
local server_ip=$(hostname -I | awk '{print $1}')
|
||||
|
||||
echo "Testing domain: $domain"
|
||||
echo "Server IP: $server_ip (testing direct to bypass CDN)"
|
||||
echo ""
|
||||
|
||||
# Test common static files
|
||||
local test_files=(
|
||||
"/favicon.ico"
|
||||
"/robots.txt"
|
||||
"/favicon.ico"
|
||||
"/"
|
||||
)
|
||||
|
||||
@@ -744,12 +758,13 @@ proof_of_caching() {
|
||||
echo "Testing: $test_path"
|
||||
|
||||
# First request - should be MISS
|
||||
local first_request=$(curl -s -I --max-time 5 "$url" 2>/dev/null)
|
||||
# Use --resolve to bypass CDN and test directly to server
|
||||
local first_request=$(curl -s -I --max-time 5 --resolve "${domain}:80:${server_ip}" "$url" 2>/dev/null)
|
||||
local first_cache=$(echo "$first_request" | grep -i "X-Cache:" | awk '{print $2}' | tr -d '\r')
|
||||
|
||||
# Second request - should be HIT
|
||||
sleep 0.5
|
||||
local second_request=$(curl -s -I --max-time 5 "$url" 2>/dev/null)
|
||||
local second_request=$(curl -s -I --max-time 5 --resolve "${domain}:80:${server_ip}" "$url" 2>/dev/null)
|
||||
local second_cache=$(echo "$second_request" | grep -i "X-Cache:" | awk '{print $2}' | tr -d '\r')
|
||||
|
||||
# Check if we got valid responses
|
||||
|
||||
Reference in New Issue
Block a user