#!/usr/bin/env python3
"""Minimal HTTP server for the Glic Actor ClickDispatcher UAF POC.

Serves the same files for any Host header on 127.0.0.1:8080.
Chrome is launched with --host-resolver-rules so that a.test and b.test
both resolve to 127.0.0.1; site isolation still treats them as distinct
sites, so the b.test iframe is an OOPIF and the inner a.test iframe is a
local-root subframe in the a.test renderer.
"""
import http.server
import os
import socketserver

PORT = 8080
ROOT = os.path.dirname(os.path.abspath(__file__))


class Handler(http.server.SimpleHTTPRequestHandler):
    def __init__(self, *a, **kw):
        super().__init__(*a, directory=ROOT, **kw)

    def log_message(self, fmt, *args):  # quiet
        pass


class Server(socketserver.TCPServer):
    allow_reuse_address = True


if __name__ == '__main__':
    with Server(('127.0.0.1', PORT), Handler) as httpd:
        print(f'serving on http://127.0.0.1:{PORT}/')
        httpd.serve_forever()
