#!/bin/sh

# Test script for DNS-over-QUIC (DoQ) functionality

echo "DNS-over-QUIC (DoQ) Test Script"
echo "================================"
echo ""
echo "This script will:"
echo "1. Start the DoH/DoQ proxy with DoQ enabled"
echo "2. You'll need a DoQ client to test (e.g., dnsproxy, q, or AdGuard)"
echo ""
echo "Starting server with DoQ support..."
echo ""

# Create a self-signed certificate for testing if needed
if [ ! -f "test-cert.pem" ] || [ ! -f "test-key.pem" ]; then
    echo "Generating self-signed certificate for testing..."
    openssl req -x509 -newkey rsa:2048 -keyout test-key.pem -out test-cert.pem -days 365 -nodes -subj "/CN=localhost" 2>/dev/null
    echo "Test certificates created: test-cert.pem and test-key.pem"
fi

echo "Starting DoH/DoQ server on:"
echo "  - DoH: https://localhost:3443/dns-query"
echo "  - DoQ: UDP port 853"
echo ""
echo "Press Ctrl+C to stop the server"
echo ""

# Run the server with both DoH and DoQ enabled
cargo run --release -- \
    -H 'localhost' \
    -u 8.8.8.8:53 \
    -l 127.0.0.1:3443 \
    -i test-cert.pem \
    -I test-key.pem \
    --enable-doq \
    --doq-port 853 \
    --doq-idle-timeout 30

echo ""
echo "Server stopped."