How to use the fcp.node.FCPNode 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 initc3 / HoneyBadgerBFT-Python / test / honest_party_test_Freenet.py View on Github external
def generateFreenetKeys(N):
    global publicKeys, nodeList
    mylog("Initiating ...")
    privateList = []
    USKPrivateList = []
    jobList = []
    for i in range(N * CONCURRENT_NUM):
        mylog("Registering node %d" % i)
        n = fcp.node.FCPNode()
        public, private = n.genkey()
        USKPublic, USKPrivate = n.genkey(name='badger', usk=True)
        mylog("Got public key %s, private key %s, USKPublic key %s, USKPrivate key %s" % (
            public, private, USKPublic, USKPrivate))
        mylog("Initializing msg_count for node %d" % i)
        # Set the initial counter
        j = n.put(uri=USKPrivate, data="0",
            mimetype="application/octet-stream", realtime=True, priority=0, async=True)
        jobList.append(j)
        # Update the lists
        publicKeys.append(public)
        USKPublicKeys.append(USKPublic)
        privateList.append(private)
        USKPrivateList.append(USKPrivate)
        nodeList.append(n)
    for index, job in enumerate(jobList):
github freenet / pyFreenet / freesitemgr.py View on Github external
def getChkCalcNode(addr):
    """
    yuck - using a separate node for chk calculation
    """
    parts = addr.split(":")
    nparts = len(parts)
    if nparts == 1:
        chkHost = addr
        chkPort = fcp.node.defaultFCPPort
    elif nparts == 2:
        chkHost = parts[0] or fcp.node.defaultFCPHost
        chkPort = parts[1] or fcp.node.defaultFCPPort
    
    try:
        chkNode = fcp.node.FCPNode(host=chkHost, port=chkPort)
        return chkNode
    except:
        return None
github freenet / pyFreenet / fcp / genkey.py View on Github external
def main():
    """
    Front end for fcpget utility
    """

    parser = create_parser()
    args = parser.parse_args()

    # default job options
    verbosity = node.ERROR
    verbose = False

    # try to create the node
    try:
        fcp_node = node.FCPNode(host=args.fcphost, port=args.fcpport, verbosity=verbosity,
                         logfile=sys.stderr)
    except:
        if verbose:
            traceback.print_exc(file=sys.stderr)
        sys.stderr.write("Failed to connect to FCP service at %s:%d\n" % (args.fcphost, args.fcpport))
        sys.exit(1)

    # grab the keypair
    pub, priv = fcp_node.genkey()

    fcp_node.shutdown()

    # successful, return the uri
    print pub
    print priv
github freenet / pyFreenet / fcp / get.py View on Github external
args = parser.parse_args(argv)

    uri = args.key_uri
    if not uri.startswith("freenet:"):
        uri = "freenet:" + uri

    opts['priority'] = args.priority
    if args.global_queue:
        opts['Global'] = 'true'
    opts['persistence'] = args.persistence
    opts['timeout'] = args.timeout


    # try to create the node
    try:
        fcp_node = node.FCPNode(host=args.fcphost,
                         port=args.fcpport,
                         Global=args.global_queue,
                         verbosity=verbosity,
                         logfile=sys.stderr)
    except:
        if verbose:
            traceback.print_exc(file=sys.stderr)
        sys.stderr.write("Failed to connect to FCP service at %s:%s\n" % (args.fcphost, args.fcpport))
        sys.exit(1)

    # try to retrieve the key
    try:
        # print "opts=%s" % opts
        mimetype, data, msg = fcp_node.get(uri, **opts)
        fcp_node.shutdown()
    except:
github freenet / pyFreenet / fcp / invertkey.py View on Github external
def main():
    """
    Front end for fcpget utility
    """
    # default job options
    verbosity = node.ERROR
    verbose = False

    parser = create_parser()
    args = parser.parse_args()

    # try to create the node
    try:
        n = node.FCPNode(host=args.fcphost, port=args.fcpport, verbosity=verbosity,
                         logfile=sys.stderr)
    except:
        if verbose:
            traceback.print_exc(file=sys.stderr)
        sys.stderr.write("Failed to connect to FCP service at %s:%s\n" % (args.fcphost, args.fcpport))

    # determine the uri
    if not args.uri:
        args.uri = raw_input('Enter a URI: ')

    uri = args.uri.strip()

    # do the invert
    uriPub = n.invertprivate(args.uri)

    n.shutdown()