Exemplo n.º 1
0
    def __init__(self, nKu, node, host, port, filename, offset, length, 
            meta=None):
        """
        Try to verify a file.
        If meta is present, it should be a (metakey, filelikeobj) pair.
        """
        host = getCanonicalIP(host)
        REQUEST.__init__(self, host, port, node)

        filekey = os.path.basename(filename) # XXX: filekey should be hash
        loggervrfy.info("sending VERIFY request to %s:%s" % (host, str(port)))
        Ku = self.node.config.Ku.exportPublicKey()
        url = 'http://'+host+':'+str(port)+'/hash/'+filekey+'?'
        url += 'nodeID='+str(self.node.config.nodeID)
        url += '&port='+str(self.node.config.port)
        url += "&Ku_e="+str(Ku['e'])
        url += "&Ku_n="+str(Ku['n'])
        url += "&offset="+str(offset)
        url += "&length="+str(length)
        if meta:
            url += "&metakey="+str(meta[0])
            url += "&meta="+fencode(meta[1].read())
        self.timeoutcount = 0

        if not isinstance(nKu, FludRSA):
            raise ValueError("must pass in a FludRSA as nKu to SENDVERIFY")

        self.deferred = defer.Deferred()
        ConnectionQueue.enqueue((self, self.headers, nKu, host, port, url))
Exemplo n.º 2
0
 def __init__(self, node, host, port):
     """
     Send a request to retrive the node's ID.  This is a reciprocal
     request -- must send my own ID in order to get one back.
     """
     host = getCanonicalIP(host)
     REQUEST.__init__(self, host, port, node)
     Ku = self.node.config.Ku.exportPublicKey()
     url = "http://"+host+":"+str(port)+"/ID?"
     url += 'nodeID='+str(self.node.config.nodeID)
     url += '&port='+str(self.node.config.port)
     url += "&Ku_e="+str(Ku['e'])
     url += "&Ku_n="+str(Ku['n'])
     #self.nKu = {}
     self.timeoutcount = 0
     self.deferred = defer.Deferred()
     ConnectionQueue.enqueue((self, node, host, port, url))
Exemplo n.º 3
0
 def __init__(self, node, host, port, key, commandName="nodes"):
     """
     """
     logger.info("sending %s (findnode) for %s... to %s:%d" 
             % (commandName, ("%x" % key)[:10], host, port)) 
     self.commandName = commandName
     host = getCanonicalIP(host)
     REQUEST.__init__(self, host, port, node)
     Ku = self.node.config.Ku.exportPublicKey()
     url = 'http://'+host+':'+str(port)+'/'+self.commandName+'/'
     url += fencode(key)
     url += '?nodeID='+str(self.node.config.nodeID)
     url += "&Ku_e="+str(Ku['e'])
     url += "&Ku_n="+str(Ku['n'])
     url += '&port='+str(self.node.config.port)
     self.timeoutcount = 0
     self.deferred = defer.Deferred()
     ConnectionQueue.enqueue((self, node, host, port, key, url))
Exemplo n.º 4
0
    def __init__(self, nKu, node, host, port, filekey, metakey):
        """
        Try to delete a file.
        """
        host = getCanonicalIP(host)
        REQUEST.__init__(self, host, port, node)

        loggerdele.info("sending DELETE request to %s:%s" % (host, str(port)))
        Ku = self.node.config.Ku.exportPublicKey()
        url = 'http://'+host+':'+str(port)+'/file/'+filekey+'?'
        url += 'nodeID='+str(self.node.config.nodeID)
        url += '&port='+str(self.node.config.port)
        url += "&Ku_e="+str(Ku['e'])
        url += "&Ku_n="+str(Ku['n'])
        url += "&metakey="+str(metakey)
        self.timeoutcount = 0
        self.authRetry = 0

        self.deferred = defer.Deferred()
        ConnectionQueue.enqueue((self, self.headers, nKu, host, port, url))
Exemplo n.º 5
0
 def __init__(self, node, host, port, key, val):
     logger.info("sending kSTORE to %s:%d" % (host, port))
     REQUEST.__init__(self, host, port, node)
     Ku = node.config.Ku.exportPublicKey()
     url = 'http://'+host+':'+str(port)+'/meta/'
     url += fencode(key)+"/"+fencode(val)
     url += '?nodeID='+str(node.config.nodeID)
     url += "&Ku_e="+str(Ku['e'])
     url += "&Ku_n="+str(Ku['n'])
     url += '&port='+str(node.config.port)
     # XXX: instead of a single key/val, protocol will take a series of
     # vals representing the blocks of the coded file and their
     # locations (by nodeID).  The entire thing will be stored under
     # the given key.  Also may need things like signature[s] from 
     # storing node[s], etc.
     #print "in SENDkSTORE.__init__, len(val)=%d" % len(str(val))
     #print "in SENDkSTORE.__init__, len(enc(val))=%d" % len(fencode(val))
     #print "in SENDkSTORE.__init__, len(url)=%d" % len(url)
     self.timeoutcount = 0
     self.deferred = defer.Deferred()
     ConnectionQueue.enqueue((self, host, port, url))
Exemplo n.º 6
0
    def __init__(self, nKu, node, host, port, datafile, metadata=None, fsize=0):
        """
        Try to upload a file.
        """
        host = getCanonicalIP(host)
        REQUEST.__init__(self, host, port, node)

        loggerstor.info("sending STORE request to %s" % self.dest)
        if not fsize:
            fsize = os.stat(datafile)[stat.ST_SIZE]
        Ku = self.node.config.Ku.exportPublicKey()
        filekey = os.path.basename(datafile) # check this before sending
        params = [('nodeID', self.node.config.nodeID),
                ('Ku_e', str(Ku['e'])),
                ('Ku_n', str(Ku['n'])),
                ('port', str(self.node.config.port)),
                ('size', str(fsize))]
        self.timeoutcount = 0

        self.deferred = defer.Deferred()
        ConnectionQueue.enqueue((self, self.headers, nKu, host, port, 
                filekey, datafile, metadata, params, True))