#!/bin/bash

if [ "$TLS_PASSTHROUGH_ON" = "true" ]; then
    echo "Reloading TLS passthrough..."

    # Create the Squid configuration file dynamically
    cat <<EOF > /etc/squid/squid.conf
    http_port ${TLS_PASSTHROUGH_PORT:-8001}

    acl localnet src all

    acl blocked dstdom_regex "/etc/squid/blocked_domains.lst"
    acl allowed dstdom_regex "/etc/squid/allowed_domains.lst"

    http_access deny blocked
    http_access allow allowed

    debug_options ALL,0


EOF
    
    # Reload Squid configuration
    if pgrep -x "squid" > /dev/null; then
        squid -k reconfigure
    fi
fi
