Example #1
0
 def cache(self, uuid):
     cachepath = os.path.join(self.lootdir, uuid, "cache")
     if not os.path.exists(cachepath):
         os.makedirs(cachepath)
     lloot = loot.loot(self.dynpath)
     for url in lloot.getindexurl(uuid):
         hmacannounced = lloot.gethmac(uuid)
         hmaccalculated = self.calchmac(cachepath + "/forban/index")
         # only fetch the index if the HMAC is different
         if not hmacannounced == hmaccalculated:
             fetch.urlget(url, cachepath + "/forban/index")
Example #2
0
 def cache (self, uuid):
     cachepath = os.path.join (self.lootdir, uuid, "cache")
     if not os.path.exists(cachepath):
         os.makedirs(cachepath)
     lloot = loot.loot(self.dynpath)
     for url in lloot.getindexurl(uuid):
         hmacannounced = lloot.gethmac(uuid)
         hmaccalculated = self.calchmac(cachepath+"/forban/index")
         # only fetch the index if the HMAC is different
         if not hmacannounced == hmaccalculated:
             fetch.urlget(url, cachepath+"/forban/index")
Example #3
0
            continue

        missingfiles = allindex.howfar(uuid)

        if (discoveredloot.whoami() == uuid):
            flogger.debug("we are not opportunistic on ourself %s (%s)" % (discoveredloot.getname(uuid),uuid))
        elif not missingfiles:
            flogger.info("missing no files with %s (%s)" % (discoveredloot.getname(uuid),uuid))
        else:
            for missedfile in missingfiles:
                if re.search(refilter, missedfile) and not (re.search(exfilter, missedfile) and efilter is not None):
                    sourcev4 = discoveredloot.getipv4(uuid)
                    url =  """http://%s:12555/s/?g=%s&f=b64e""" % (sourcev4, base64e.encode(missedfile))
                    localfile = forbanshareroot + "/" + missedfile
                    localsize = allindex.getfilesize(filename=missedfile)
                    remotesize = allindex.getfilesize(filename=missedfile,uuid=uuid)
                    if localsize < remotesize:
                        flogger.info("local file smaller - from %s fetching %s to be saved in %s" % (uuid,url,localfile))
                        fetch.urlget(url,localfile)
                    elif localsize is False:
                        flogger.info("local file not existing - from %s fetching %s to be saved in %s" % (uuid,url,localfile))
                        fetch.urlget(url,localfile)
                    elif remotesize is False:
                        flogger.info("remote file index issue for %s on loot %s" % (missedfile, uuid))
                    else:
                        flogger.info("local file larger or corrupt %s - don't fetch it" % (localfile))
                    allindex.build()

    time.sleep(announceinterval*(announceinterval/(announceinterval-2)))