work on forward secrecy
This commit is contained in:
parent
ce2423e6d9
commit
d151e0d302
5 changed files with 60 additions and 21 deletions
|
@ -22,28 +22,50 @@
|
|||
import logger, config
|
||||
import os, sys, json, time, random, shutil, base64, getpass, datetime, re
|
||||
from onionrblockapi import Block
|
||||
import onionrusers
|
||||
|
||||
plugin_name = 'metadataprocessor'
|
||||
|
||||
# event listeners
|
||||
|
||||
def _processUserInfo(api, newBlock):
|
||||
'''
|
||||
Set the username for a particular user, from a signed block by them
|
||||
'''
|
||||
myBlock = newBlock
|
||||
peerName = myBlock.getMetadata('name')
|
||||
try:
|
||||
if len(peerName) > 20:
|
||||
raise onionrexceptions.InvalidMetdata('Peer name specified is too large')
|
||||
except TypeError:
|
||||
pass
|
||||
except onionrexceptions.InvalidMetadata:
|
||||
pass
|
||||
else:
|
||||
api.get_core().setPeerInfo(signer, 'name', peerName)
|
||||
logger.info('%s is now using the name %s.' % (signer, api.get_utils().escapeAnsi(peerName)))
|
||||
|
||||
def _processForwardKey(api, myBlock):
|
||||
'''
|
||||
Get the forward secrecy key specified by the user for us to use
|
||||
'''
|
||||
peer = onionrusers.OnionrUser(self.api.get_core(), myBlock.signer)
|
||||
|
||||
def on_processBlocks(api):
|
||||
myBlock = api.data['block']
|
||||
blockType = api.data['type']
|
||||
print('blockType is ' + blockType)
|
||||
|
||||
# Process specific block types
|
||||
|
||||
# userInfo blocks, such as for setting username
|
||||
if blockType == 'userInfo':
|
||||
if myBlock.verifySig():
|
||||
peerName = myBlock.getMetadata('name')
|
||||
try:
|
||||
if len(peerName) > 20:
|
||||
raise onionrexceptions.InvalidMetdata('Peer name specified is too large')
|
||||
except TypeError:
|
||||
pass
|
||||
except onionrexceptions.InvalidMetadata:
|
||||
pass
|
||||
else:
|
||||
api.get_core().setPeerInfo(signer, 'name', peerName)
|
||||
logger.info('%s is now using the name %s.' % (signer, api.get_utils().escapeAnsi(peerName)))
|
||||
_processUserInfo(api, myBlock)
|
||||
# forwardKey blocks
|
||||
elif blockType == 'forwardKey':
|
||||
if myBlock.verifySig():
|
||||
_processForwardKey(api, myBlock)
|
||||
|
||||
def on_init(api, data = None):
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue