Files
myceliumcloud-examples/examples/nginx-mycelium/test-ipv6-website.sh

80 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
# Enhanced IPv6 Website Testing Script
echo "🌐 Mycelium IPv6 Website Testing"
echo "================================="
# Get IPv6 addresses from nodes
echo "🔍 Discovering IPv6 addresses..."
IPV6_ADDRS=$(kubectl get nodes -o jsonpath='{range .items[*]}{.metadata.annotations.k3s\.io/internal-ip}{"\n"}{end}' | tr ',' '\n' | grep ':' | sort | uniq)
if [ -z "$IPV6_ADDRS" ]; then
echo "❌ No IPv6 addresses found!"
exit 1
fi
echo "✅ Found IPv6 addresses:"
echo "$IPV6_ADDRS" | nl
# Get current pod info
POD_INFO=$(kubectl get pods -l app=mycelium-website -o wide --no-headers)
echo ""
echo "📊 Current Deployment Status:"
echo "$POD_INFO"
# Test each IPv6 address
echo ""
echo "🧪 Testing IPv6 connectivity..."
SUCCESS_COUNT=0
TOTAL_COUNT=$(echo "$IPV6_ADDRS" | wc -l)
for IPV6 in $IPV6_ADDRS; do
echo ""
echo "Testing: http://[$IPV6]:8080"
# Test connection with timeout and show result
if timeout 5 curl -6 -s --connect-timeout 3 --max-time 8 "http://[$IPV6]:8080" > /tmp/test_response.txt 2>/dev/null; then
if [ -s /tmp/test_response.txt ]; then
echo "✅ SUCCESS - Website accessible!"
SUCCESS_COUNT=$((SUCCESS_COUNT + 1))
# Show content preview
echo "📄 Content preview:"
head -5 /tmp/test_response.txt | sed 's/^/ /'
echo " ..."
else
echo "⚠️ Connection succeeded but no content received"
fi
else
echo "❌ FAILED - Cannot connect"
fi
done
echo ""
echo "📊 Results Summary:"
echo " Total IPv6 addresses: $TOTAL_COUNT"
echo " Accessible websites: $SUCCESS_COUNT"
echo " Success rate: $(( SUCCESS_COUNT * 100 / TOTAL_COUNT ))%"
if [ $SUCCESS_COUNT -gt 0 ]; then
echo ""
echo "🎯 Working URLs:"
for IPV6 in $IPV6_ADDRS; do
if timeout 3 curl -6 -s --connect-timeout 2 "http://[$IPV6]:8080" > /dev/null 2>/dev/null; then
echo " http://[$IPV6]:8080 ✅"
fi
done
echo ""
echo "🚀 Your website is globally accessible via Mycelium IPv6!"
echo " Users worldwide can now visit your site using these URLs."
else
echo ""
echo "🔧 Troubleshooting Tips:"
echo " - Check if Mycelium service is running on nodes"
echo " - Verify firewall rules allow IPv6 traffic on port 8080"
echo " - Ensure nginx is actually listening (check pod logs)"
fi
# Cleanup
rm -f /tmp/test_response.txt