예제 #1
0
 def onAuthenticated(self, key, permissions):
     if not OPENDOOR:
         # check net filter
         if NETMASK != []:
             ipAllowed = False
             for netfilter in NETMASK:
                 ipHex=ipV4ToHex(self.peer.host)
                 ipAllowed = (ipHex & netfilter['mask']) == netfilter['ipAllowed'] & netfilter['mask']
                 if ipAllowed:
                     break
             if not ipAllowed:
                 raise Exception("host " + self.peer.host + " is not allowed!")
         # check authentication key
         if key is None:
             raise Exception("Authentication failed")
         # check permissions, array.index throws exception
         if (permissions['permissions'] != None):
             for req in permissions['permissions']:
                 WHITELIST.index(req);
         # check allowed service creation, array.index throws exception
         if (permissions['services'] != None):
             for req in permissions['services']:
                 SERVICELIST.index(req);
     # create cloudeebus service instance
     self.cloudeebusService = CloudeebusService(permissions)
     # register it for RPC
     self.registerForRpc(self.cloudeebusService)
     # register for Publish / Subscribe
     self.registerForPubSub("", True)
예제 #2
0
    
    OPENDOOR = args.opendoor
    
    if args.credentials:
        jfile = open(args.credentials)
        CREDENTIALS = json.load(jfile)
        jfile.close()
    
    if args.whitelist:
        jfile = open(args.whitelist)
        WHITELIST.extend(json.load(jfile))
        jfile.close()
        
    if args.servicelist:
        jfile = open(args.servicelist)
        SERVICELIST.extend(json.load(jfile))
        jfile.close()
        
    if args.netmask:
        iplist = args.netmask.split(",")
        for ip in iplist:
            if ip.rfind("/") != -1:
                ip=ip.split("/")
                ipAllowed = ip[0]
                mask = ip[1]
            else:
                ipAllowed = ip
                mask = "255.255.255.255" 
            NETMASK.append( {'ipAllowed': ipV4ToHex(ipAllowed), 'mask' : ipV4ToHex(mask)} )

    uri = "ws://localhost:" + args.port