Revert "Boss/Receive: add 'side' to got_message"
This reverts commit 1fece5701c9de5e470526d2e7e9cfd7b461977e0.
This commit is contained in:
parent
d4c9210a4e
commit
a594a85427
|
@ -264,13 +264,12 @@ class Boss(object):
|
||||||
def scared(self):
|
def scared(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def got_message(self, side, phase, plaintext):
|
def got_message(self, phase, plaintext):
|
||||||
# this is only called for side != ours
|
|
||||||
assert isinstance(phase, type("")), type(phase)
|
assert isinstance(phase, type("")), type(phase)
|
||||||
assert isinstance(plaintext, type(b"")), type(plaintext)
|
assert isinstance(plaintext, type(b"")), type(plaintext)
|
||||||
d_mo = re.search(r'^dilate-(\d+)$', phase)
|
d_mo = re.search(r'^dilate-(\d+)$', phase)
|
||||||
if phase == "version":
|
if phase == "version":
|
||||||
self._got_version(side, plaintext)
|
self._got_version(plaintext)
|
||||||
elif d_mo:
|
elif d_mo:
|
||||||
self._got_dilate(int(d_mo.group(1)), plaintext)
|
self._got_dilate(int(d_mo.group(1)), plaintext)
|
||||||
elif re.search(r'^\d+$', phase):
|
elif re.search(r'^\d+$', phase):
|
||||||
|
@ -281,7 +280,7 @@ class Boss(object):
|
||||||
log.err(_UnknownPhaseError("received unknown phase '%s'" % phase))
|
log.err(_UnknownPhaseError("received unknown phase '%s'" % phase))
|
||||||
|
|
||||||
@m.input()
|
@m.input()
|
||||||
def _got_version(self, side, plaintext):
|
def _got_version(self, plaintext):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@m.input()
|
@m.input()
|
||||||
|
@ -310,10 +309,9 @@ class Boss(object):
|
||||||
self._W.got_code(code)
|
self._W.got_code(code)
|
||||||
|
|
||||||
@m.output()
|
@m.output()
|
||||||
def process_version(self, side, plaintext):
|
def process_version(self, plaintext):
|
||||||
# most of this is wormhole-to-wormhole, ignored for now
|
# most of this is wormhole-to-wormhole, ignored for now
|
||||||
# in the future, this is how Dilation is signalled
|
# in the future, this is how Dilation is signalled
|
||||||
self._their_side = side
|
|
||||||
self._their_versions = bytes_to_dict(plaintext)
|
self._their_versions = bytes_to_dict(plaintext)
|
||||||
self._D.got_wormhole_versions(self._side, self._their_side,
|
self._D.got_wormhole_versions(self._side, self._their_side,
|
||||||
self._their_versions)
|
self._their_versions)
|
||||||
|
|
|
@ -53,10 +53,10 @@ class Receive(object):
|
||||||
except CryptoError:
|
except CryptoError:
|
||||||
self.got_message_bad()
|
self.got_message_bad()
|
||||||
return
|
return
|
||||||
self.got_message_good(side, phase, plaintext)
|
self.got_message_good(phase, plaintext)
|
||||||
|
|
||||||
@m.input()
|
@m.input()
|
||||||
def got_message_good(self, side, phase, plaintext):
|
def got_message_good(self, phase, plaintext):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@m.input()
|
@m.input()
|
||||||
|
@ -73,23 +73,23 @@ class Receive(object):
|
||||||
self._key = key
|
self._key = key
|
||||||
|
|
||||||
@m.output()
|
@m.output()
|
||||||
def S_got_verified_key(self, side, phase, plaintext):
|
def S_got_verified_key(self, phase, plaintext):
|
||||||
assert self._key
|
assert self._key
|
||||||
self._S.got_verified_key(self._key)
|
self._S.got_verified_key(self._key)
|
||||||
|
|
||||||
@m.output()
|
@m.output()
|
||||||
def W_happy(self, side, phase, plaintext):
|
def W_happy(self, phase, plaintext):
|
||||||
self._B.happy()
|
self._B.happy()
|
||||||
|
|
||||||
@m.output()
|
@m.output()
|
||||||
def W_got_verifier(self, side, phase, plaintext):
|
def W_got_verifier(self, phase, plaintext):
|
||||||
self._B.got_verifier(derive_key(self._key, b"wormhole:verifier"))
|
self._B.got_verifier(derive_key(self._key, b"wormhole:verifier"))
|
||||||
|
|
||||||
@m.output()
|
@m.output()
|
||||||
def W_got_message(self, side, phase, plaintext):
|
def W_got_message(self, phase, plaintext):
|
||||||
assert isinstance(phase, type("")), type(phase)
|
assert isinstance(phase, type("")), type(phase)
|
||||||
assert isinstance(plaintext, type(b"")), type(plaintext)
|
assert isinstance(plaintext, type(b"")), type(plaintext)
|
||||||
self._B.got_message(side, phase, plaintext)
|
self._B.got_message(phase, plaintext)
|
||||||
|
|
||||||
@m.output()
|
@m.output()
|
||||||
def W_scared(self):
|
def W_scared(self):
|
||||||
|
|
|
@ -167,7 +167,7 @@ class Receive(unittest.TestCase):
|
||||||
("s.got_verified_key", key),
|
("s.got_verified_key", key),
|
||||||
("b.happy", ),
|
("b.happy", ),
|
||||||
("b.got_verifier", verifier),
|
("b.got_verifier", verifier),
|
||||||
("b.got_message", u"side", u"phase1", data1),
|
("b.got_message", u"phase1", data1),
|
||||||
])
|
])
|
||||||
|
|
||||||
phase2_key = derive_phase_key(key, u"side", u"phase2")
|
phase2_key = derive_phase_key(key, u"side", u"phase2")
|
||||||
|
@ -178,8 +178,8 @@ class Receive(unittest.TestCase):
|
||||||
("s.got_verified_key", key),
|
("s.got_verified_key", key),
|
||||||
("b.happy", ),
|
("b.happy", ),
|
||||||
("b.got_verifier", verifier),
|
("b.got_verifier", verifier),
|
||||||
("b.got_message", u"side", u"phase1", data1),
|
("b.got_message", u"phase1", data1),
|
||||||
("b.got_message", u"side", u"phase2", data2),
|
("b.got_message", u"phase2", data2),
|
||||||
])
|
])
|
||||||
|
|
||||||
def test_early_bad(self):
|
def test_early_bad(self):
|
||||||
|
@ -217,7 +217,7 @@ class Receive(unittest.TestCase):
|
||||||
("s.got_verified_key", key),
|
("s.got_verified_key", key),
|
||||||
("b.happy", ),
|
("b.happy", ),
|
||||||
("b.got_verifier", verifier),
|
("b.got_verifier", verifier),
|
||||||
("b.got_message", u"side", u"phase1", data1),
|
("b.got_message", u"phase1", data1),
|
||||||
])
|
])
|
||||||
|
|
||||||
phase2_key = derive_phase_key(key, u"side", u"bad")
|
phase2_key = derive_phase_key(key, u"side", u"bad")
|
||||||
|
@ -228,7 +228,7 @@ class Receive(unittest.TestCase):
|
||||||
("s.got_verified_key", key),
|
("s.got_verified_key", key),
|
||||||
("b.happy", ),
|
("b.happy", ),
|
||||||
("b.got_verifier", verifier),
|
("b.got_verifier", verifier),
|
||||||
("b.got_message", u"side", u"phase1", data1),
|
("b.got_message", u"phase1", data1),
|
||||||
("b.scared", ),
|
("b.scared", ),
|
||||||
])
|
])
|
||||||
r.got_message(u"side", u"phase1", good_body)
|
r.got_message(u"side", u"phase1", good_body)
|
||||||
|
@ -237,7 +237,7 @@ class Receive(unittest.TestCase):
|
||||||
("s.got_verified_key", key),
|
("s.got_verified_key", key),
|
||||||
("b.happy", ),
|
("b.happy", ),
|
||||||
("b.got_verifier", verifier),
|
("b.got_verifier", verifier),
|
||||||
("b.got_message", u"side", u"phase1", data1),
|
("b.got_message", u"phase1", data1),
|
||||||
("b.scared", ),
|
("b.scared", ),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
@ -1324,8 +1324,8 @@ class Boss(unittest.TestCase):
|
||||||
b.got_key(b"key")
|
b.got_key(b"key")
|
||||||
b.happy()
|
b.happy()
|
||||||
b.got_verifier(b"verifier")
|
b.got_verifier(b"verifier")
|
||||||
b.got_message("side", "version", b"{}")
|
b.got_message("version", b"{}")
|
||||||
b.got_message("side", "0", b"msg1")
|
b.got_message("0", b"msg1")
|
||||||
self.assertEqual(events, [
|
self.assertEqual(events, [
|
||||||
("w.got_key", b"key"),
|
("w.got_key", b"key"),
|
||||||
("d.got_key", b"key"),
|
("d.got_key", b"key"),
|
||||||
|
@ -1483,7 +1483,7 @@ class Boss(unittest.TestCase):
|
||||||
|
|
||||||
b.happy() # phase=version
|
b.happy() # phase=version
|
||||||
|
|
||||||
b.got_message("side", "unknown-phase", b"spooky")
|
b.got_message("unknown-phase", b"spooky")
|
||||||
self.assertEqual(events, [])
|
self.assertEqual(events, [])
|
||||||
|
|
||||||
self.flushLoggedErrors(errors._UnknownPhaseError)
|
self.flushLoggedErrors(errors._UnknownPhaseError)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user