Ejemplo n.º 1
0
def subnet_check(cidr, translate=False):
    if isinstance(cidr, unicode):
        cidr = cidr.encode('utf-8')

    if isinstance(cidr, str):
        cidr = create_cidr_ipaddr(cidr)
    elif not isinstance(cidr, cidr_ipaddr):
        return defer.succeed(None)
    
    if cidr is None:
        return defer.succeed(None)

    if translate:
        return ((cidr.mask << 32) | (cidr.addr.addr))
    return defer.succeed(unicode(str(cidr)))
Ejemplo n.º 2
0
 def handle_config_update(self, props):
     if "internal_subnets" not in props:
         lg.error("no 'internal_subnets' property found")
         return
     self.authenticator.clear_internal_subnets()
     arr = props["internal_subnets"][0].split(",")
     for prefix_str in arr:
         if prefix_str == "":
             continue
         if isinstance(prefix_str, unicode):
             prefix_str = prefix_str.encode('utf-8')
         prefix_str = prefix_str.strip()
         cidr = create_cidr_ipaddr(prefix_str)
         if cidr == None:
             lg.error("ignoring invalid prefix entry: '%s'" % prefix_str)
         else:
             self.authenticator.add_internal_subnet(cidr)
Ejemplo n.º 3
0
 def handle_config_update(self,props): 
     if "internal_subnets" not in props: 
         lg.error("no 'internal_subnets' property found")
         return
     self.authenticator.clear_internal_subnets()
     arr = props["internal_subnets"][0].split(",")
     for prefix_str in arr:
         if prefix_str == "": 
             continue 
         if isinstance(prefix_str, unicode):
             prefix_str = prefix_str.encode('utf-8')
         prefix_str = prefix_str.strip()
         cidr = create_cidr_ipaddr(prefix_str)
         if cidr == None:
             lg.error("ignoring invalid prefix entry: '%s'" % prefix_str)
         else:
             self.authenticator.add_internal_subnet(cidr)