Peer Validation - In Progress
Mostly done.. must find a way to allow master registration and reception of peer list BEFORE validating incoming messages to the peer list -- chicken and egg problem. Easily solved, but needs an EFFICIENT solution since EVERY PACKET will be passed through this test.
This commit is contained in:
parent
9e049977fd
commit
2e0f29fc97
12
ipsc.py
12
ipsc.py
@ -59,12 +59,20 @@ def strip_hash(_data):
|
|||||||
# Determine if the provided peer ID is valid for the provided network
|
# Determine if the provided peer ID is valid for the provided network
|
||||||
#
|
#
|
||||||
def valid_peer(_network, _peerid):
|
def valid_peer(_network, _peerid):
|
||||||
|
print(' %s' % binascii.b2a_hex(_peerid))
|
||||||
|
for peer in NETWORK[_network]['PEERS']:
|
||||||
|
print(binascii.b2a_hex(peer['RADIO_ID']))
|
||||||
|
if peer['RADIO_ID'] == _peerid:
|
||||||
return True
|
return True
|
||||||
|
return True #MUST BE FIXED!!!!!! should return false, but there are other issues right now...
|
||||||
|
|
||||||
# Determine if the provided master ID is valid for the provided network
|
# Determine if the provided master ID is valid for the provided network
|
||||||
#
|
#
|
||||||
def valid_master(_network, _peerid):
|
def valid_master(_network, _peerid):
|
||||||
|
if NETWORK[_network]['MASTER']['RADIO_ID'] == _peerid:
|
||||||
return True
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
# Take a packet to be SENT, calcualte auth hash and return the whole thing
|
# Take a packet to be SENT, calcualte auth hash and return the whole thing
|
||||||
#
|
#
|
||||||
@ -341,7 +349,8 @@ class IPSC(DatagramProtocol):
|
|||||||
logger.warning('(%s) AuthError: IPSC packet failed authentication. Type %s: Peer ID: %s', self._network, binascii.b2a_hex(_packettype), _dec_peerid)
|
logger.warning('(%s) AuthError: IPSC packet failed authentication. Type %s: Peer ID: %s', self._network, binascii.b2a_hex(_packettype), _dec_peerid)
|
||||||
return
|
return
|
||||||
|
|
||||||
if valid_peer(self._network, _peerid) == False or valid_master(self._network, _dec_peerid) == True:
|
if self._master_stat['CONNECTED'] == True:
|
||||||
|
if valid_peer(self._network, _peerid) == False or valid_master(self._network, _peerid) == False:
|
||||||
logger.warning('(%s) PeerError: Peer not in peer-list: %s', self._network, _dec_peerid)
|
logger.warning('(%s) PeerError: Peer not in peer-list: %s', self._network, _dec_peerid)
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -363,6 +372,7 @@ class IPSC(DatagramProtocol):
|
|||||||
logger.debug('<<- (%s) Master Registration Packet Recieved', self._network)
|
logger.debug('<<- (%s) Master Registration Packet Recieved', self._network)
|
||||||
|
|
||||||
elif (_packettype == MASTER_REG_REPLY):
|
elif (_packettype == MASTER_REG_REPLY):
|
||||||
|
self._master['RADIO_ID'] = _peerid
|
||||||
self._master_stat['CONNECTED'] = True
|
self._master_stat['CONNECTED'] = True
|
||||||
self._master_stat['KEEP_ALIVES_OUTSTANDING'] = 0
|
self._master_stat['KEEP_ALIVES_OUTSTANDING'] = 0
|
||||||
logger.debug('<<- (%s) Master Registration Reply From:%s:%s ', self._network, host, port)
|
logger.debug('<<- (%s) Master Registration Reply From:%s:%s ', self._network, host, port)
|
||||||
|
@ -47,7 +47,7 @@ dictConfig({
|
|||||||
'ipsc': {
|
'ipsc': {
|
||||||
# 'handlers': ['file-timed', 'console-timed'],
|
# 'handlers': ['file-timed', 'console-timed'],
|
||||||
'handlers': ['file', 'console'],
|
'handlers': ['file', 'console'],
|
||||||
'level': 'DEBUG',
|
'level': 'INFO',
|
||||||
'propagate': True,
|
'propagate': True,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user