fix bug in test_lan_learn and handle errors better in encryption plugin

master
Kevin 2020-06-23 16:48:04 -05:00
parent 8d33e1a188
commit 03608960c0
2 changed files with 12 additions and 2 deletions

View File

@ -22,12 +22,17 @@
import logger, config, threading, time, datetime, sys
import ujson as json
from nacl.exceptions import TypeError as NaclTypeError
from onionrutils import stringvalidators, bytesconverter
from onionrcrypto import encryption, keypair, signing, getourkeypair
import onionrexceptions, onionrusers
import locale
locale.setlocale(locale.LC_ALL, '')
import binascii
plugin_name = 'encrypt'
class PlainEncryption:
@ -110,7 +115,12 @@ class PlainEncryption:
return
def on_decrypt_cmd(api, data=None):
try:
PlainEncryption(api).decrypt()
except binascii.Error:
logger.error("Invalid ciphertext padding", terminal=True)
except NaclTypeError:
logger.error("Ciphertext too short.", terminal=True)
def on_encrypt_cmd(api, data=None):
PlainEncryption(api).encrypt()

View File

@ -40,7 +40,7 @@ class TestLanLearn(unittest.TestCase):
sock.close()
test_list = [test_ip]
Thread(target=learn_services, args=[test_list], daemon=True).start()
Thread(target=learn_services, daemon=True).start()
bettersleep.better_sleep(3)
multicast()
self.assertIn(test_ip, test_list)