Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

changed stat path and fixed a bug using the wrong attribute for http …

…error codes
  • Loading branch information...
commit e3d67ae276ba146e1611537ac0ef02ba032012b0 1 parent 8d16d27
@progrium progrium authored
Showing with 14 additions and 11 deletions.
  1. +13 −10 main.py
  2. +1 −1  pfsense/bridge.py
View
23 main.py
@@ -70,15 +70,6 @@ class MacAddressMapping(db.Model):
def get_by_mac(cls, address):
return cls.all().filter('address =', address).get()
-class StatHandler(webapp.RequestHandler):
- def get(self, name=None):
- if name in ['members', 'guests']:
- stat = get_stat(name)
- else:
- members = get_stat('members')
- guests = get_stat('guests')
- stat = members+guests
- self.response.out.write(str(stat))
class EntryHandler(webapp.RequestHandler):
""" Entry point for the wifi app
@@ -148,13 +139,25 @@ def get(self, mac):
self.error(404)
self.response.out.write("not found")
+class StatHandler(webapp.RequestHandler):
+ """ Simple endpoint for getting current members/guests using Internet """
+
+ def get(self, name=None):
+ if name in ['members', 'guests']:
+ stat = get_stat(name)
+ else:
+ members = get_stat('members')
+ guests = get_stat('guests')
+ stat = members+guests
+ self.response.out.write(str(stat))
+
def main():
application = webapp.WSGIApplication([
('/api/mac/(.+)', MacHandler),
+ ('/api/stat/(.+)', StatHandler),
('/guest', GuestHandler),
('/member', MemberHandler),
- ('/stat/(.+)', StatHandler),
('/(.+)', EntryHandler),] ,debug=True)
util.run_wsgi_app(application)
View
2  pfsense/bridge.py
@@ -33,7 +33,7 @@ def HandleAuthPacket(self, pkt):
reply.code=packet.AccessAccept
print "success: %s %s %s %s" % (mac_address, user, download, upload)
except (urllib2.URLError, urllib2.HTTPError), e:
- if hasattr(e, 'getcode') and e.getcode() == 404:
+ if hasattr(e, 'code') and e.code == 404:
reply.code=packet.AccessReject
print "fail: %s" % mac_address
else:
Please sign in to comment.
Something went wrong with that request. Please try again.