CLI: don't catch+wrap WrongPasswordError
Also remove .explain, now that we no longer wrap it in TransferError
This commit is contained in:
		
							parent
							
								
									b96b052c96
								
							
						
					
					
						commit
						e4a19748db
					
				| 
						 | 
					@ -3,7 +3,7 @@ import os, sys, json, binascii, six, tempfile, zipfile
 | 
				
			||||||
from tqdm import tqdm
 | 
					from tqdm import tqdm
 | 
				
			||||||
from twisted.internet import reactor, defer
 | 
					from twisted.internet import reactor, defer
 | 
				
			||||||
from twisted.internet.defer import inlineCallbacks, returnValue
 | 
					from twisted.internet.defer import inlineCallbacks, returnValue
 | 
				
			||||||
from ..twisted.transcribe import Wormhole, WrongPasswordError
 | 
					from ..twisted.transcribe import Wormhole
 | 
				
			||||||
from ..twisted.transit import TransitReceiver
 | 
					from ..twisted.transit import TransitReceiver
 | 
				
			||||||
from ..errors import TransferError
 | 
					from ..errors import TransferError
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -113,10 +113,8 @@ class TwistedReceiver:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @inlineCallbacks
 | 
					    @inlineCallbacks
 | 
				
			||||||
    def get_data(self, w):
 | 
					    def get_data(self, w):
 | 
				
			||||||
        try:
 | 
					        # this may raise WrongPasswordError
 | 
				
			||||||
        them_bytes = yield w.get_data()
 | 
					        them_bytes = yield w.get_data()
 | 
				
			||||||
        except WrongPasswordError as e:
 | 
					 | 
				
			||||||
            raise TransferError(u"ERROR: " + e.explain())
 | 
					 | 
				
			||||||
        them_d = json.loads(them_bytes.decode("utf-8"))
 | 
					        them_d = json.loads(them_bytes.decode("utf-8"))
 | 
				
			||||||
        if "error" in them_d:
 | 
					        if "error" in them_d:
 | 
				
			||||||
            raise TransferError(u"ERROR: " + them_d["error"])
 | 
					            raise TransferError(u"ERROR: " + them_d["error"])
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5,7 +5,7 @@ from twisted.protocols import basic
 | 
				
			||||||
from twisted.internet import reactor
 | 
					from twisted.internet import reactor
 | 
				
			||||||
from twisted.internet.defer import inlineCallbacks, returnValue
 | 
					from twisted.internet.defer import inlineCallbacks, returnValue
 | 
				
			||||||
from ..errors import TransferError
 | 
					from ..errors import TransferError
 | 
				
			||||||
from ..twisted.transcribe import Wormhole, WrongPasswordError
 | 
					from ..twisted.transcribe import Wormhole
 | 
				
			||||||
from ..twisted.transit import TransitSender
 | 
					from ..twisted.transit import TransitSender
 | 
				
			||||||
 | 
					
 | 
				
			||||||
APPID = u"lothar.com/wormhole/text-or-file-xfer"
 | 
					APPID = u"lothar.com/wormhole/text-or-file-xfer"
 | 
				
			||||||
| 
						 | 
					@ -87,10 +87,8 @@ def send(args, reactor=reactor):
 | 
				
			||||||
    my_phase1_bytes = json.dumps(phase1).encode("utf-8")
 | 
					    my_phase1_bytes = json.dumps(phase1).encode("utf-8")
 | 
				
			||||||
    yield w.send_data(my_phase1_bytes)
 | 
					    yield w.send_data(my_phase1_bytes)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    try:
 | 
					    # this may raise WrongPasswordError
 | 
				
			||||||
    them_phase1_bytes = yield w.get_data()
 | 
					    them_phase1_bytes = yield w.get_data()
 | 
				
			||||||
    except WrongPasswordError as e:
 | 
					 | 
				
			||||||
        raise TransferError(e.explain())
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    them_phase1 = json.loads(them_phase1_bytes.decode("utf-8"))
 | 
					    them_phase1 = json.loads(them_phase1_bytes.decode("utf-8"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
import functools, textwrap
 | 
					import functools
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ServerError(Exception):
 | 
					class ServerError(Exception):
 | 
				
			||||||
    def __init__(self, message, relay):
 | 
					    def __init__(self, message, relay):
 | 
				
			||||||
| 
						 | 
					@ -28,8 +28,6 @@ class WrongPasswordError(Exception):
 | 
				
			||||||
    chance.
 | 
					    chance.
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
    # or the data blob was corrupted, and that's why decrypt failed
 | 
					    # or the data blob was corrupted, and that's why decrypt failed
 | 
				
			||||||
    def explain(self):
 | 
					 | 
				
			||||||
        return textwrap.dedent(self.__doc__)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
class ReflectionAttack(Exception):
 | 
					class ReflectionAttack(Exception):
 | 
				
			||||||
    """An attacker (or bug) reflected our outgoing message back to us."""
 | 
					    """An attacker (or bug) reflected our outgoing message back to us."""
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user