1
0
Fork 0
mirror of https://github.com/iiab/iiab.git synced 2025-03-09 15:40:17 +00:00

Merge pull request #1518 from georgejhunt/capfix-2

Captive Portal: works on Windows 7,8,10, with no network wire
This commit is contained in:
A Holt 2019-02-24 16:22:22 -05:00 committed by GitHub
commit d2b7bb78a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -177,27 +177,7 @@ def set_lasttimestamp(ip):
conn.commit() conn.commit()
# ################### Action routines based on OS ################3 # ################### Action routines based on OS ################3
def microsoft_splash(environ,start_response):
en_txt={ 'message':"Click on the button to go to the IIAB home page",\
"FQDN": fully_qualified_domain_name, \
'btn1':"GO TO IIAB HOME PAGE",'doc_root':get_iiab_env("WWWROOT")}
es_txt={ 'message':"Haga clic en el botón para ir a la página de inicio de IIAB",\
"FQDN": fully_qualified_domain_name, \
'btn1':"IIAB",'doc_root':get_iiab_env("WWWROOT")}
txt = en_txt
if lang == "en":
txt = en_txt
elif lang == "es":
txt = es_txt
response_body = str(j2_env.get_template("simple.template").render(**txt))
status = '200 OK'
response_headers = [('Content-type','text/html'),
('Content-Length',str(len(response_body)))]
start_response(status, response_headers)
return [response_body]
def microsoft(environ,start_response): def microsoft(environ,start_response):
global MICROSOFT_TRIGGERED
# firefox -- seems both mac and Windows use it # firefox -- seems both mac and Windows use it
agent = environ.get('HTTP_USER_AGENT','default_agent') agent = environ.get('HTTP_USER_AGENT','default_agent')
if agent.startswith('Mozilla'): if agent.startswith('Mozilla'):
@ -205,7 +185,7 @@ def microsoft(environ,start_response):
logger.debug("sending microsoft redirect") logger.debug("sending microsoft redirect")
response_body = "" response_body = ""
status = '302 Moved Temporarily' status = '302 Moved Temporarily'
response_headers = [('Location','/microsoft_splash'), response_headers = [('Location','http://box.lan/home'),
('Content-type','text/html'), ('Content-type','text/html'),
('Content-Length',str(len(response_body)))] ('Content-Length',str(len(response_body)))]
start_response(status, response_headers) start_response(status, response_headers)
@ -542,10 +522,6 @@ def application (environ, start_response):
return android(environ, start_response) return android(environ, start_response)
# microsoft # microsoft
if environ['PATH_INFO'] == "/microsoft_splash":
return microsoft_splash(environ, start_response)
if environ['PATH_INFO'] == "/connecttest.txt" and not is_inactive(ip):
return microsoft_connect(environ, start_response)
if environ['HTTP_HOST'] == "ipv6.msftncsi.com" or\ if environ['HTTP_HOST'] == "ipv6.msftncsi.com" or\
environ['HTTP_HOST'] == "detectportal.firefox.com" or\ environ['HTTP_HOST'] == "detectportal.firefox.com" or\
environ['HTTP_HOST'] == "ipv6.msftncsi.com.edgesuite.net" or\ environ['HTTP_HOST'] == "ipv6.msftncsi.com.edgesuite.net" or\
@ -557,7 +533,7 @@ def application (environ, start_response):
environ['HTTP_HOST'] == "teredo.ipv6.microsoft.com.nsatc.net": environ['HTTP_HOST'] == "teredo.ipv6.microsoft.com.nsatc.net":
return microsoft(environ, start_response) return microsoft(environ, start_response)
logger.debug("executing the default 204 response. [%s"%data) logger.debug("executing the default 302 response. [%s"%data)
return put_302(environ,start_response) return put_302(environ,start_response)
# Instantiate the server # Instantiate the server