How to use the fcp.node.uriIsPrivate function in fcp

To help you get started, we’ve selected a few fcp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github freenet / pyFreenet / freedisk.py View on Github external
return
    
        # deprecated
    
        if 0:    
            # mkdir to create the freedisk dir
            os.mkdir(self.diskPath)
            
            # wait for the pseudo-files to come into existence
            while not os.path.isfile(self.privKeyPath):
                time.sleep(0.1)
            
            # set the keys
            
            if fcp.node.uriIsPrivate(uri):
                path = privKeyPath
            else:
                path = pubKeyPath
            f = file(path, "w")
            f.write(uri)
            f.flush()
            f.close()
github freenet / pyFreenet / freesitemgr.py View on Github external
return
        sitedir = os.path.abspath(sitedir)
        if not os.path.isdir(sitedir):
            print "'%s' is not a directory, try again" % sitedir
            continue
        #elif not os.path.isfile(os.path.join(sitedir, "index.html")):
        #    print "'%s' has no index.html, try again" % sitedir
        #    continue
        break

    while 1:
        uriPriv = raw_input("Site private URI (if any - press ENTER for new\n: ").strip()
        if not uriPriv:
            uriPub, uriPriv = sitemgr.node.genkey()
        else:
            if not fcp.node.uriIsPrivate(uriPriv):
                print "Sorry, that's a public URI, we need a private URI"
                continue
            try:
                uriPub = sitemgr.node.invertprivate(uriPriv)
            except:
                traceback.print_exc()
                print "Invalid private URI:\n  %s" % uriPriv
                continue
        break
        uriPub = fixUri(uriPub, sitename)
        uriPriv = fixUri(uriPriv, sitename)
    
    # good to go - add the site
    sitemgr.addSite(name=sitename, dir=sitedir, uriPub=uriPub, uriPriv=uriPriv)

    print "Added new freesite: '%s' => %s" % (sitename, sitedir)