Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:hackerdojo/hd-captiveportal

  • Loading branch information...
commit 738d09176929a8e0adb74b0c00fcbe9bc2c3cec2 2 parents 26ab1b6 + a7f6a71
@dustball dustball authored
Showing with 31 additions and 27 deletions.
  1. +30 −26 pfsense/bridge.py
  2. +1 −1  pfsense/portal.php
View
56 pfsense/bridge.py
@@ -2,6 +2,7 @@
import logging
import sys
import urllib2
+import threading
logger = logging.getLogger("pyrad")
logger.setLevel(logging.DEBUG)
@@ -19,33 +20,36 @@ class RadiusServer(server.Server):
"""
def HandleAuthPacket(self, pkt):
- mac_address = pkt[1][0]
- reply=self.CreateReplyPacket(pkt)
- try:
- resp = urllib2.urlopen('http://hd-wifi.appspot.com/api/mac/%s' % mac_address)
- user, download, upload = resp.read().split(',')
- if download:
- reply.AddAttribute((14122,8), download) # WISPr-Bandwidth-Max-Down
- if upload:
- reply.AddAttribute((14122,7), upload) # WISPr-Bandwidth-Max-Up
- if not '*' in user:
- member_cache[mac_address] = user
- reply.code=packet.AccessAccept
- print "accept: %s %s %s %s" % (mac_address, user, download, upload)
- except (urllib2.URLError, urllib2.HTTPError), e:
- if hasattr(e, 'code') and e.code == 404:
- reply.code=packet.AccessReject
- print "reject: %s" % mac_address
- else:
- if mac_address in member_cache:
- reply.AddAttribute((14122,8), '0')
- reply.AddAttribute((14122,7), '0')
- print "accept [failover]: %s %s" % (mac_address, member_cache[mac_address])
- else:
- print "accept [failover]: %s" % mac_address
+ def _handle():
+ mac_address = pkt[1][0]
+ reply=self.CreateReplyPacket(pkt)
+ try:
+ resp = urllib2.urlopen('http://hd-captiveportal.appspot.com/api/mac/%s' % mac_address)
+ user, download, upload = resp.read().split(',')
+ if download:
+ reply.AddAttribute((14122,8), download) # WISPr-Bandwidth-Max-Down
+ if upload:
+ reply.AddAttribute((14122,7), upload) # WISPr-Bandwidth-Max-Up
+ if not '*' in user:
+ member_cache[mac_address] = user
reply.code=packet.AccessAccept
-
- self.SendReplyPacket(pkt.fd, reply)
+ print "accept: %s %s %s %s" % (mac_address, user, download, upload)
+ except (urllib2.URLError, urllib2.HTTPError), e:
+ if hasattr(e, 'code') and e.code == 404:
+ reply.code=packet.AccessReject
+ print "reject: %s" % mac_address
+ else:
+ if mac_address in member_cache:
+ reply.AddAttribute((14122,8), '0')
+ reply.AddAttribute((14122,7), '0')
+ print "accept [failover]: %s %s" % (mac_address, member_cache[mac_address])
+ else:
+ print "accept [failover]: %s" % mac_address
+ reply.code=packet.AccessAccept
+
+ self.SendReplyPacket(pkt.fd, reply)
+ thread = threading.Thread(target=_handle)
+ thread.start()
srv=RadiusServer(addresses=[''], dict=dictionary.Dictionary("dictionary"))
View
2  pfsense/portal.php
@@ -30,7 +30,7 @@
<html>
<body>
<script type="text/javascript">
- window.location.href = "https://hd-wifi.appspot.com/<?= base64_encode(str_replace(":", "", $clientmac) .','. $redirurl); ?>";
+ window.location.href = "https://hd-captiveportal.appspot.com/<?= base64_encode(str_replace(":", "", $clientmac) .','. $redirurl); ?>";
</script>
</body>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.