Ejemplo n.º 1
0
 def normal(self):
     if not config.relay:
         get_db.send()
         register.send()
     while True:
         coin_count.send()
         get_nodes.count_send()
         time.sleep(60)
Ejemplo n.º 2
0
 def relay(self):
     get_nodes.send()
     register.send()
     sock = socket.socket()
     sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     sock.bind((config.host, config.port))
     sock.listen(5)
     while True:
         obj, conn = sock.accept()
         thread.start_new_thread(self.handle, (obj, conn[0]))
Ejemplo n.º 3
0
 def firstrun(self):
     print "Getting nodes..."
     get_nodes.send(True)
     check = config.nodes.find("nodes", "all")
     if not check:
         ip = config.host
         config.nodes.insert("nodes", {"ip":ip, "relay":config.relay, "port":config.port})
         config.nodes.save()
     print "Registering..."
     register.send()
Ejemplo n.º 4
0
 def relay(self):
     get_nodes.send()
     register.send()
     get_db.send()
     sock = socket.socket()
     sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
     sock.bind((config.host, config.port))
     sock.listen(5)
     while True:
         obj, conn = sock.accept()
         thread.start_new_thread(self.handle, (obj, conn[0]))
Ejemplo n.º 5
0
 def non_relay(self):
     register.send() #Re register with the network every time the node starts in case some of the config settings have changed.
     while True:
         if config.relay:
             for num,x in enumerate(config.relaying_to):
                 try:
                     x["object"].send(" ")
                 except:
                     config.relaying_to.pop(num)
         get_nodes_count.send()
         if not config.found_convo:
             thread.start_new_thread(find_convo.send, ())
         time.sleep(30)
Ejemplo n.º 6
0
 def first_run(self):
     print "Sperre seems to be running for the first time"
     print "Generating keys..."
     address = "SRE_"+uuid.uuid4().hex
     pubkey, privkey = rsa.newkeys(1024)
     config.my_data.insert("data", {"address":address, "publickey":str(pubkey), "privatekey":str(privkey)})
     config.my_data.save()
     print "Keys generated!"
     print "Getting node list..."
     get_nodes.send()
     print "Registering..."
     register.send()
     print "Registered!"
     print "Your address is: {0}".format(address)
Ejemplo n.º 7
0
 def non_relay(self):
     register.send(
     )  #Re register with the network every time the node starts in case some of the config settings have changed.
     while True:
         if config.relay:
             for num, x in enumerate(config.relaying_to):
                 try:
                     x["object"].send(" ")
                 except:
                     config.relaying_to.pop(num)
         get_nodes_count.send()
         if not config.found_convo:
             thread.start_new_thread(find_convo.send, ())
         time.sleep(30)
Ejemplo n.º 8
0
 def first_run(self):
     print "Sperre seems to be running for the first time"
     print "Generating keys..."
     address = "SRE_" + uuid.uuid4().hex
     pubkey, privkey = rsa.newkeys(1024)
     config.my_data.insert(
         "data", {
             "address": address,
             "publickey": str(pubkey),
             "privatekey": str(privkey)
         })
     config.my_data.save()
     print "Keys generated!"
     print "Getting node list..."
     get_nodes.send()
     print "Registering..."
     register.send()
     print "Registered!"
     print "Your address is: {0}".format(address)
Ejemplo n.º 9
0
 def firstrun(self):
     print "Generating address..."
     pub, priv = rsa.newkeys(1024)
     address = "SHA"+''.join([random.choice(string.uppercase+string.lowercase+string.digits) for x in range(50)])
     print "Your address is: "+address
     print "Getting nodes..."
     get_nodes.send(True)
     check = config.nodes.find("nodes", "all")
     if not check:
         print "It looks like you are the first node on this network."
         ip = raw_input("What is your IP address? ")
         config.nodes.insert("nodes", {"public":str(pub), "address":address, "ip":ip, "relay":config.relay, "port":config.port})
         config.nodes.save()
         config.db.insert("difficulty", {"difficulty":7})
         config.db.save()
     config.wallet.insert("data", {"public":str(pub), "address":address, "private":str(priv)})
     config.wallet.save()
     print "Registering..."
     register.send()
     print "Getting coins db..."
     get_db.send()
     print "Done!"
Ejemplo n.º 10
0
 def firstrun(self):
     print "Generating address and public/private keys"
     pub, priv = rsa.newkeys(1024)
     address = "Z"+''.join([random.choice(string.uppercase+string.lowercase+string.digits) for x in range(50)])
     print "My wallet address: "+address
     print "Getting nodes from network"
     get_nodes.send(True)
     check = config.nodes.find("nodes", "all")
     if not check:
         print "Seed node (aka no other nodes online)"
         ip = raw_input("What is your IP address?") ## replace by auto-check?
         config.nodes.insert("nodes", {"public":str(pub), "address":address, "ip":ip, "relay":config.relay, "port":config.port})
         config.nodes.save()
         config.db.insert("difficulty", {"difficulty":5})
         config.db.save()
     config.wallet.insert("data", {"public":str(pub), "address":address, "private":str(priv)})
     config.wallet.save()
     print "Registering..."
     register.send()
     print "Getting coins db..."
     get_db.send()
     print "Done!"