added intruction for nodes

This commit is contained in:
Kevin Froman 2018-04-18 20:17:47 -05:00
parent edce30ea20
commit 77f811c455
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
4 changed files with 36 additions and 2 deletions

View File

@ -148,6 +148,10 @@ class API:
action = request.args.get('action')
requestingPeer = request.args.get('myID')
data = request.args.get('data')
try:
data
except:
data = ''
if action == 'firstConnect':
pass
elif action == 'ping':
@ -160,6 +164,15 @@ class API:
resp = Response(self._utils.getBlockDBHash())
elif action == 'getBlockHashes':
resp = Response(self._core.getBlockList())
elif action == 'announce':
if data != '':
# TODO: require POW for this
if self._core.addAddress(data):
resp = Response('Success')
else:
resp = Response('')
else:
resp = Response('')
# setData should be something the communicator initiates, not this api
elif action == 'getData':
resp = self._core.getData(data)

View File

@ -91,6 +91,14 @@ class OnionrCommunicate:
if command[0] == 'shutdown':
logger.info('Daemon recieved exit command.')
break
elif command[0] == 'anounceNode':
announceAmount = 1
announceVal = False
for i in command[1]:
logger.info('Announcing our node to ' + command[1][i])
while not announceVal:
announceVal = self.performGet('announce', command[1][i], data=self._core.hsAdder, skipHighFailureAddress=True)
time.sleep(1)
return

View File

@ -41,6 +41,7 @@ class Core:
self.blockDB = 'data/blocks.db'
self.blockDataLocation = 'data/blocks/'
self.addressDB = 'data/address.db'
self.hsAdder = ''
if not os.path.exists('data/'):
os.mkdir('data/')
@ -48,6 +49,10 @@ class Core:
os.mkdir('data/blocks/')
if not os.path.exists(self.blockDB):
self.createBlockDB()
if os.path.exists('data/hs/hostname'):
with open('data/hs/hostname', 'r') as hs:
self.hsAdder = hs.read()
self._utils = onionrutils.OnionrUtils(self)
# Initialize the crypto object
@ -540,4 +545,12 @@ class Core:
self.addToBlockDB(addedHash, selfInsert=True)
self.setBlockType(addedHash, header)
retData = addedHash
return retData
return retData
def introduceNode(self):
'''
Introduces our node into the network by telling X many nodes our HS address
'''
nodeList = self.listAdders().split('\n')
self.daemonQueueAdd('announceNode', nodeList)
return

View File

@ -36,7 +36,7 @@ except ImportError:
logger.error('You need python3 tkinter and tk installed to use Onionr.')
sys.exit(1)
ONIONR_TAGLINE = 'Anonymous P2P Platform - GPLv3 - onionr.voidnet.tech'
ONIONR_TAGLINE = 'Anonymous P2P Platform - GPLv3 - https://Onionr.VoidNet.Tech'
ONIONR_VERSION = '0.0.0' # for debugging and stuff
API_VERSION = '1' # increments of 1; only change when something fundemental about how the API works changes. This way other nodes knows how to communicate without learning too much information about you.