portail_captif: /enable => autorise surcis
This commit is contained in:
parent
d947a60253
commit
ee76d0dc6e
1 changed files with 9 additions and 2 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import time
|
import time
|
||||||
|
@ -32,6 +34,7 @@ deco={
|
||||||
|
|
||||||
'ex_crous': 'ERR_CUSTOM_EX_CROUS.html',
|
'ex_crous': 'ERR_CUSTOM_EX_CROUS.html',
|
||||||
'ex_crous_enable': 'ERR_CUSTOM_EX_CROUS_ENABLE.html',
|
'ex_crous_enable': 'ERR_CUSTOM_EX_CROUS_ENABLE.html',
|
||||||
|
'confirmation': 'ERR_RECONNECT_CONFIRM.html',
|
||||||
|
|
||||||
'age': 'ERR_CUSTOM_AGE.html',
|
'age': 'ERR_CUSTOM_AGE.html',
|
||||||
'ago': 'ERR_CUSTOM_AGO.html',
|
'ago': 'ERR_CUSTOM_AGO.html',
|
||||||
|
@ -48,7 +51,7 @@ deco={
|
||||||
'bloq':'ERR_CUSTOM_BLOQ.html',
|
'bloq':'ERR_CUSTOM_BLOQ.html',
|
||||||
|
|
||||||
'nouvelle_annee':'ERR_CUSTOM_NOUVELLE_ANNEE.html',
|
'nouvelle_annee':'ERR_CUSTOM_NOUVELLE_ANNEE.html',
|
||||||
'paiement': 'ERR_CUSTOM_NOUVELLE_ANNEE.html',
|
'paiement': 'ERR_CUSTOM_READHESION.html',
|
||||||
'proxy_local':'ERR_CUSTOM_PROXY_LOCAL.html',
|
'proxy_local':'ERR_CUSTOM_PROXY_LOCAL.html',
|
||||||
|
|
||||||
'virus':'ERR_CUSTOM_BL_VIRUS.html',
|
'virus':'ERR_CUSTOM_BL_VIRUS.html',
|
||||||
|
@ -83,7 +86,8 @@ def mac_from_ip(ip):
|
||||||
|
|
||||||
def enable_access(ip):
|
def enable_access(ip):
|
||||||
"""Lance la commande idoine pour autoriser l'adresse IP"""
|
"""Lance la commande idoine pour autoriser l'adresse IP"""
|
||||||
p = subprocess.Popen(['sudo', '-n', '/usr/scripts/utils/install-party/ipset_allow', ip],
|
cmd = ['/usr/sbin/ipset', 'add', 'CONFIRMATION', ip]
|
||||||
|
p = subprocess.Popen(['sudo', '-n'] + cmd,
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.PIPE)
|
stderr=subprocess.PIPE)
|
||||||
out, err = p.communicate()
|
out, err = p.communicate()
|
||||||
|
@ -169,6 +173,9 @@ def app(environ, start_response):
|
||||||
data = deco['ex_crous_enable']
|
data = deco['ex_crous_enable']
|
||||||
else:
|
else:
|
||||||
data = deco['ex_crous']
|
data = deco['ex_crous']
|
||||||
|
elif environ.get('RAW_URI', '').startswith('/enable'):
|
||||||
|
enable_access(ip)
|
||||||
|
data = deco['confirmation']
|
||||||
elif ip in cache.keys() and cache[ip]['time']>(now - cache_time):
|
elif ip in cache.keys() and cache[ip]['time']>(now - cache_time):
|
||||||
data=cache[ip]['page']
|
data=cache[ip]['page']
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue