Implement renew() and logout() functions - anticapum - Handle Università Politecnica delle Marche captive portal
(HTM) hg clone https://bitbucket.org/iamleot/anticapum
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
---
(DIR) changeset 17ad5c151fba32d5c8996dca63c7203dfd993ba1
(DIR) parent 19ae947887e54980abdde18e09140984bcbb18a6
(HTM) Author: Leonardo Taccari <iamleot@gmail.com>
Date: Thu, 11 Jan 2018 23:21:08
Implement renew() and logout() functions
- renew() renews the captive portal session using the dict returned by login()
- logout() logout the captive portal session using the dict returned by login()
Diffstat:
anticapum.py | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
---
diff -r 19ae947887e5 -r 17ad5c151fba anticapum.py
--- a/anticapum.py Thu Jan 11 23:19:00 2018 +0100
+++ b/anticapum.py Thu Jan 11 23:21:08 2018 +0100
@@ -102,6 +102,38 @@
}
+def renew(data):
+ """Renew the captive portal session.
+
+ Given a data dict containings username, ip, timestamp, sid and pulsante pairs
+ representing the current session renew the captive portal session.
+ """
+ auth = parse.urlencode(data)
+ auth = auth.encode('utf-8')
+
+ # TODO: Find a way to verify the cert!
+ sc = ssl.SSLContext()
+ sc.verify_mode = ssl.CERT_NONE
+ with request.urlopen(ANTICAPUM_URL_RENEW, data=auth, context=sc) as f:
+ pass
+
+
+def logout(data):
+ """Logout the captive portal session.
+
+ Given a data dict containings username, ip, timestamp, sid and pulsante pairs
+ representing the current session logout from the captive portal session.
+ """
+ auth = parse.urlencode(data)
+ auth = auth.encode('utf-8')
+
+ # TODO: Find a way to verify the cert!
+ sc = ssl.SSLContext()
+ sc.verify_mode = ssl.CERT_NONE
+ with request.urlopen(ANTICAPUM_URL_LOGOUT, data=auth, context=sc) as f:
+ pass
+
+
if __name__ == '__main__':
import time