Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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):
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
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
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:
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()