-#!/usr/bin/python
#-*- coding: utf-8 -*-
#
# S.Çağlar Onur <caglar@cs.princeton.edu>
import os
import sys
+import socket
class BaseRateLimit(object):
api_method_caller = "unknown"
# excludes
- if api_method_source == None or api_method_source[0] == self.config.PLC_API_IP or api_method_source[0] in self.whitelist:
+ if api_method_source == None or api_method_source[0] == socket.gethostbyname(self.config.PLC_API_HOST) or api_method_source[0] in self.whitelist:
return
# sanity check
if (api_method == "session" and api_method_caller.__contains__("@")) or (api_method == "password" or api_method == "capability"):
self.mail(api_method_caller)
- raise PLCPermissionDenied, "Maximum allowed number of API calls exceeded"
+ raise PLCPermissionDenied("Maximum allowed number of API calls exceeded")
def after(self, wobj, data, *args, **kwargs):
return
-class RateLimitAspect_class(BaseRateLimit):
- __metaclass__ = MetaAspect
+class RateLimitAspect_class(BaseRateLimit, metaclass=MetaAspect):
name = "ratelimitaspect_class"
def __init__(self):