work on sockets

This commit is contained in:
Kevin Froman 2018-09-14 23:48:48 -05:00
parent e0fbe2033e
commit d80e72d18c
No known key found for this signature in database
GPG key ID: 0D414D0FE405B63B
3 changed files with 15 additions and 8 deletions

View file

@ -68,21 +68,21 @@ def on_processBlocks(api):
# userInfo blocks, such as for setting username
if blockType == 'userInfo':
if api.data['validSig']:
if api.data['validSig'] == True: # we use == True for type safety
_processUserInfo(api, myBlock)
# forwardKey blocks, add a new forward secrecy key for a peer
elif blockType == 'forwardKey':
if api.data['validSig']:
if api.data['validSig'] == True:
_processForwardKey(api, myBlock)
# socket blocks
elif blockType == 'openSocket':
if api.data['validSig']:
if api.data['validSig'] == True:
try:
address = api.data['address']
except KeyError:
raise onionrexceptions.MissingAddress("Missing address for new socket")
socketInfo = json.dumps({'peer': api.data['signer'], 'address': address, create = False})
api.get_core().daemonQueueAdd('createSocket', socketInfo)
api.get_core().daemonQueueAdd('startSocket', socketInfo)
def on_init(api, data = None):