#!/usr/bin/env python
# Serves the current directory over HTTP on port 80 of every IPv6 and (mapped) IPv4 address, for the ACME
# HTTP-01 challenge of acme_pre_hook. Works with Python 2 and 3.
import socket
import sys

if sys.version_info[0] == 2:
    from BaseHTTPServer import HTTPServer
    from SimpleHTTPServer import SimpleHTTPRequestHandler
else:
    from http.server import HTTPServer, SimpleHTTPRequestHandler


class DualStackServer(HTTPServer):
    address_family = socket.AF_INET6


if __name__ == '__main__':
    try:
        DualStackServer(('::', 80), SimpleHTTPRequestHandler).serve_forever()
    except KeyboardInterrupt:
        print("Exited by Ctrl+C")
