Commit 2893473d authored by Daniel STAN's avatar Daniel STAN

portail_captif: lien spécial pour register une mac

parent 112f4304
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment