added intruction for nodes
This commit is contained in:
parent
edce30ea20
commit
77f811c455
@ -148,6 +148,10 @@ class API:
|
|||||||
action = request.args.get('action')
|
action = request.args.get('action')
|
||||||
requestingPeer = request.args.get('myID')
|
requestingPeer = request.args.get('myID')
|
||||||
data = request.args.get('data')
|
data = request.args.get('data')
|
||||||
|
try:
|
||||||
|
data
|
||||||
|
except:
|
||||||
|
data = ''
|
||||||
if action == 'firstConnect':
|
if action == 'firstConnect':
|
||||||
pass
|
pass
|
||||||
elif action == 'ping':
|
elif action == 'ping':
|
||||||
@ -160,6 +164,15 @@ class API:
|
|||||||
resp = Response(self._utils.getBlockDBHash())
|
resp = Response(self._utils.getBlockDBHash())
|
||||||
elif action == 'getBlockHashes':
|
elif action == 'getBlockHashes':
|
||||||
resp = Response(self._core.getBlockList())
|
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
|
# setData should be something the communicator initiates, not this api
|
||||||
elif action == 'getData':
|
elif action == 'getData':
|
||||||
resp = self._core.getData(data)
|
resp = self._core.getData(data)
|
||||||
|
@ -91,6 +91,14 @@ class OnionrCommunicate:
|
|||||||
if command[0] == 'shutdown':
|
if command[0] == 'shutdown':
|
||||||
logger.info('Daemon recieved exit command.')
|
logger.info('Daemon recieved exit command.')
|
||||||
break
|
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)
|
time.sleep(1)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -41,6 +41,7 @@ class Core:
|
|||||||
self.blockDB = 'data/blocks.db'
|
self.blockDB = 'data/blocks.db'
|
||||||
self.blockDataLocation = 'data/blocks/'
|
self.blockDataLocation = 'data/blocks/'
|
||||||
self.addressDB = 'data/address.db'
|
self.addressDB = 'data/address.db'
|
||||||
|
self.hsAdder = ''
|
||||||
|
|
||||||
if not os.path.exists('data/'):
|
if not os.path.exists('data/'):
|
||||||
os.mkdir('data/')
|
os.mkdir('data/')
|
||||||
@ -48,6 +49,10 @@ class Core:
|
|||||||
os.mkdir('data/blocks/')
|
os.mkdir('data/blocks/')
|
||||||
if not os.path.exists(self.blockDB):
|
if not os.path.exists(self.blockDB):
|
||||||
self.createBlockDB()
|
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)
|
self._utils = onionrutils.OnionrUtils(self)
|
||||||
# Initialize the crypto object
|
# Initialize the crypto object
|
||||||
@ -540,4 +545,12 @@ class Core:
|
|||||||
self.addToBlockDB(addedHash, selfInsert=True)
|
self.addToBlockDB(addedHash, selfInsert=True)
|
||||||
self.setBlockType(addedHash, header)
|
self.setBlockType(addedHash, header)
|
||||||
retData = addedHash
|
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
|
@ -36,7 +36,7 @@ except ImportError:
|
|||||||
logger.error('You need python3 tkinter and tk installed to use Onionr.')
|
logger.error('You need python3 tkinter and tk installed to use Onionr.')
|
||||||
sys.exit(1)
|
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
|
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.
|
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.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user