diff --git a/utils/portail_captif.py b/utils/portail_captif.py index 6db92216..262c3488 100644 --- a/utils/portail_captif.py +++ b/utils/portail_captif.py @@ -134,6 +134,25 @@ def get_page(ip, by_mac=False, accueil=False): if accueil: return deco['inscrit'] return None + +def special(action, ip, environ, start_response): + mac = mac_from_ip(ip) + url = "https://intranet2.crans.org/machines/add/" + if 'wifi' in action: + url += 'wifi/' + else: + url += 'fil/' + if mac is not None: + url += mac + '/' + start_response("302 OK", [ + ("Content-Type", "text/html"), + ("Cache-Control", "no-cache, must-revalidate"), + ("Expires", "Thu, 01 Jan 1970 00:00:00 GMT"), + ("Location", url), + ("Content-Length", 0) + ]) + return "" + def app(environ, start_response): if 'HTTP_K_REAL_IP' in environ.keys(): @@ -142,6 +161,8 @@ def app(environ, start_response): ip=environ['HTTP_REAL_IP'] now=time.time() cleanup(now) + if environ.get('RAW_URI', '').startswith('/special'): + return special(environ.get('RAW_URI','')[9:], ip, environ, start_response) if AddrInNet(ip, '10.231.137.0/24'): if environ.get('RAW_URI', '').startswith('/enable'): enable_access(ip)