rename Wormhole (machine) to Boss, leave room for higher-level thing
This commit is contained in:
parent
92f2b89d3e
commit
20814a65f4
|
@ -8,7 +8,7 @@ digraph {
|
|||
compute the key, send VERSION. Starting from the Return, this saves
|
||||
two round trips. OTOH it adds consequences to hitting Tab. */
|
||||
|
||||
start [label="Wormhole\nMachine" style="dotted"]
|
||||
start [label="Boss\n(manager)" style="dotted"]
|
||||
|
||||
{rank=same; P0_code S0}
|
||||
P0_code [shape="box" style="dashed"
|
|
@ -8,7 +8,7 @@ digraph {
|
|||
start -> S0 [style="invis"]
|
||||
S0 [label="S0:\nunknown"]
|
||||
S0 -> P0_set_code [label="set"]
|
||||
P0_set_code [shape="box" label="W.set_code"]
|
||||
P0_set_code [shape="box" label="B.set_code"]
|
||||
P0_set_code -> S4
|
||||
S4 [label="S4: known" color="green"]
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
digraph {
|
||||
App [shape="box" color="blue" fontcolor="blue"]
|
||||
Wormhole [shape="box" label="Wormhole\n(manager)"
|
||||
Boss [shape="box" label="Boss\n(manager)"
|
||||
color="blue" fontcolor="blue"]
|
||||
Mailbox [shape="box" color="blue" fontcolor="blue"]
|
||||
Connection [label="Rendezvous\nConnector"
|
||||
|
@ -18,33 +18,33 @@ digraph {
|
|||
Connection -> websocket [color="blue"]
|
||||
#Connection -> Order [color="blue"]
|
||||
|
||||
App -> Wormhole [style="dashed" label="start\nset_code\nsend\nclose\n(once)"]
|
||||
#App -> Wormhole [color="blue"]
|
||||
Wormhole -> App [style="dashed" label="got_verifier\nreceived\nclosed\n(once)"]
|
||||
App -> Boss [style="dashed" label="start\nset_code\nsend\nclose\n(once)"]
|
||||
#App -> Boss [color="blue"]
|
||||
Boss -> App [style="dashed" label="got_verifier\nreceived\nclosed\n(once)"]
|
||||
|
||||
#Wormhole -> Connection [color="blue"]
|
||||
Wormhole -> Connection [style="dashed" label="start"]
|
||||
Connection -> Wormhole [style="dashed" label="rx_welcome"]
|
||||
#Boss -> Connection [color="blue"]
|
||||
Boss -> Connection [style="dashed" label="start"]
|
||||
Connection -> Boss [style="dashed" label="rx_welcome"]
|
||||
|
||||
Wormhole -> Send [style="dashed" label="send"]
|
||||
Boss -> Send [style="dashed" label="send"]
|
||||
|
||||
Wormhole -> Mailbox [style="dashed"
|
||||
Boss -> Mailbox [style="dashed"
|
||||
label="set_nameplate\nclose\n(once)"
|
||||
]
|
||||
#Wormhole -> Mailbox [color="blue"]
|
||||
Mailbox -> Wormhole [style="dashed" label="closed\n(once)"]
|
||||
#Boss -> Mailbox [color="blue"]
|
||||
Mailbox -> Boss [style="dashed" label="closed\n(once)"]
|
||||
Mailbox -> Order [style="dashed" label="got_message (once)"]
|
||||
Wormhole -> Key [style="dashed" label="set_code"]
|
||||
Key -> Wormhole [style="dashed" label="got_verifier\nscared"]
|
||||
Boss -> Key [style="dashed" label="set_code"]
|
||||
Key -> Boss [style="dashed" label="got_verifier\nscared"]
|
||||
Order -> Key [style="dashed" label="got_pake"]
|
||||
Order -> Receive [style="dashed" label="got_message"]
|
||||
#Wormhole -> Key [color="blue"]
|
||||
#Boss -> Key [color="blue"]
|
||||
Key -> Mailbox [style="dashed" label="add_message (pake)\nadd_message (version)"]
|
||||
Receive -> Send [style="dashed" label="got_verified_key"]
|
||||
Send -> Mailbox [style="dashed" label="add_message (phase)"]
|
||||
|
||||
Key -> Receive [style="dashed" label="got_key"]
|
||||
Receive -> Wormhole [style="dashed"
|
||||
Receive -> Boss [style="dashed"
|
||||
label="happy\nscared\ngot_message"]
|
||||
|
||||
Mailbox -> Connection [style="dashed"
|
||||
|
@ -60,7 +60,7 @@ digraph {
|
|||
label="tx_list"
|
||||
]
|
||||
|
||||
#Wormhole -> Code [color="blue"]
|
||||
#Boss -> Code [color="blue"]
|
||||
Code -> Connection [style="dashed"
|
||||
label="tx_allocate"
|
||||
]
|
||||
|
@ -73,7 +73,7 @@ digraph {
|
|||
Code -> Nameplates [style="dashed"
|
||||
label="refresh_nameplates"
|
||||
]
|
||||
Code -> Wormhole [style="dashed"
|
||||
Code -> Boss [style="dashed"
|
||||
label="set_code"]
|
||||
App -> Code [style="dashed"
|
||||
label="allocate\ninput\nset"]
|
||||
|
|
|
@ -36,8 +36,10 @@ digraph {
|
|||
P_stop [shape="box" label="C.stop"]
|
||||
P_stop -> SsB
|
||||
|
||||
SsB -> Ss [label="stopped"]
|
||||
SsB [label="SsB: closed\nstopping"]
|
||||
SsB -> Pss [label="stopped"]
|
||||
Pss [shape="box" label="B.closed"]
|
||||
Pss -> Ss
|
||||
|
||||
Ss [label="Ss: closed" color="green"]
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ digraph {
|
|||
S1 [label="S1:\nunverified key" color="orange"]
|
||||
S1 -> P_mood_scary [label="got_message\n(bad)"]
|
||||
S1 -> P1_accept_msg [label="got_message\n(good)" color="orange"]
|
||||
P1_accept_msg [shape="box" label="S.got_verified_key\nW.happy\nW.got_message"
|
||||
P1_accept_msg [shape="box" label="S.got_verified_key\nB.happy\nB.got_message"
|
||||
color="orange"]
|
||||
P1_accept_msg -> S2 [color="orange"]
|
||||
|
||||
|
@ -28,10 +28,10 @@ digraph {
|
|||
S2 -> P2_accept_msg [label="got_message\n(good)" color="orange"]
|
||||
S2 -> P_mood_scary [label="got_message(bad)"]
|
||||
|
||||
P2_accept_msg [label="W.got_message" shape="box" color="orange"]
|
||||
P2_accept_msg [label="B.got_message" shape="box" color="orange"]
|
||||
P2_accept_msg -> S2 [color="orange"]
|
||||
|
||||
P_mood_scary [shape="box" label="W.scared" color="red"]
|
||||
P_mood_scary [shape="box" label="B.scared" color="red"]
|
||||
P_mood_scary -> S3 [color="red"]
|
||||
|
||||
S3 [label="S3:\nscared" color="red"]
|
||||
|
|
|
@ -11,8 +11,8 @@ from ._nameplate import NameplateListing
|
|||
from ._code import Code
|
||||
from .util import bytes_to_dict
|
||||
|
||||
@implementer(_interfaces.IWormhole)
|
||||
class Wormhole:
|
||||
@implementer(_interfaces.IBoss)
|
||||
class Boss:
|
||||
m = MethodicalMachine()
|
||||
|
||||
def __init__(self, side, reactor, timing):
|
|
@ -1,6 +1,6 @@
|
|||
from zope.interface import Interface
|
||||
|
||||
class IWormhole(Interface):
|
||||
class IBoss(Interface):
|
||||
pass
|
||||
class IMailbox(Interface):
|
||||
pass
|
||||
|
|
|
@ -53,8 +53,8 @@ class Key(object):
|
|||
m = MethodicalMachine()
|
||||
def __init__(self, timing):
|
||||
self._timing = timing
|
||||
def wire(self, wormhole, mailbox, receive):
|
||||
self._W = _interfaces.IWormhole(wormhole)
|
||||
def wire(self, boss, mailbox, receive):
|
||||
self._B = _interfaces.IBoss(boss)
|
||||
self._M = _interfaces.IMailbox(mailbox)
|
||||
self._R = _interfaces.IReceive(receive)
|
||||
|
||||
|
@ -67,6 +67,11 @@ class Key(object):
|
|||
@m.state(terminal=True)
|
||||
def S3_scared(self): pass
|
||||
|
||||
# from Boss
|
||||
@m.input()
|
||||
def set_code(self, code): pass
|
||||
|
||||
# from Ordering
|
||||
def got_pake(self, body):
|
||||
assert isinstance(body, type(b"")), type(body)
|
||||
payload = bytes_to_dict(body)
|
||||
|
@ -74,9 +79,6 @@ class Key(object):
|
|||
self.got_pake_good(hexstr_to_bytes(payload["pake_v1"]))
|
||||
else:
|
||||
self.got_pake_bad()
|
||||
|
||||
@m.input()
|
||||
def set_code(self, code): pass
|
||||
@m.input()
|
||||
def got_pake_good(self, msg2): pass
|
||||
@m.input()
|
||||
|
@ -93,7 +95,7 @@ class Key(object):
|
|||
|
||||
@m.output()
|
||||
def scared(self):
|
||||
self._W.scared()
|
||||
self._B.scared()
|
||||
@m.output()
|
||||
def compute_key(self, msg2):
|
||||
assert isinstance(msg2, type(b""))
|
||||
|
@ -101,7 +103,7 @@ class Key(object):
|
|||
key = self._sp.finish(msg2)
|
||||
self._my_versions = {}
|
||||
self._M.add_message("version", self._my_versions)
|
||||
self._W.got_verifier(derive_key(key, b"wormhole:verifier"))
|
||||
self._B.got_verifier(derive_key(key, b"wormhole:verifier"))
|
||||
self._R.got_key(key)
|
||||
|
||||
S0_know_nothing.upon(set_code, enter=S1_know_code, outputs=[build_pake])
|
||||
|
|
|
@ -14,8 +14,8 @@ class Mailbox(object):
|
|||
self._pending_outbound = {}
|
||||
self._processed = set()
|
||||
|
||||
def wire(self, wormhole, rendezvous_connector, ordering):
|
||||
self._W = _interfaces.IWormhole(wormhole)
|
||||
def wire(self, boss, rendezvous_connector, ordering):
|
||||
self._B = _interfaces.IBoss(boss)
|
||||
self._RC = _interfaces.IRendezvousConnector(rendezvous_connector)
|
||||
self._O = _interfaces.IOrder(ordering)
|
||||
|
||||
|
@ -89,7 +89,7 @@ class Mailbox(object):
|
|||
@m.input()
|
||||
def start_connected(self): pass
|
||||
|
||||
# from Wormhole
|
||||
# from Boss
|
||||
@m.input()
|
||||
def set_nameplate(self, nameplate): pass
|
||||
@m.input()
|
||||
|
@ -210,7 +210,7 @@ class Mailbox(object):
|
|||
self._RC_stop()
|
||||
@m.output()
|
||||
def W_closed(self):
|
||||
self._W.closed()
|
||||
self._B.closed()
|
||||
|
||||
initial.upon(start_unconnected, enter=S0A, outputs=[])
|
||||
initial.upon(start_connected, enter=S0B, outputs=[])
|
||||
|
|
|
@ -10,8 +10,8 @@ class Receive(object):
|
|||
self._side = side
|
||||
self._timing = timing
|
||||
self._key = None
|
||||
def wire(self, wormhole, key, send):
|
||||
self._W = _interfaces.IWormhole(wormhole)
|
||||
def wire(self, boss, key, send):
|
||||
self._B = _interfaces.IBoss(boss)
|
||||
self._K = _interfaces.IKey(key)
|
||||
self._S = _interfaces.ISend(send)
|
||||
|
||||
|
@ -24,6 +24,7 @@ class Receive(object):
|
|||
@m.state(terminal=True)
|
||||
def S3_scared(self): pass
|
||||
|
||||
# from Ordering
|
||||
def got_message(self, phase, body):
|
||||
assert isinstance(phase, type("")), type(phase)
|
||||
assert isinstance(body, type(b"")), type(body)
|
||||
|
@ -35,14 +36,15 @@ class Receive(object):
|
|||
self.got_message_bad()
|
||||
return
|
||||
self.got_message_good(phase, plaintext)
|
||||
|
||||
@m.input()
|
||||
def got_key(self, key): pass
|
||||
@m.input()
|
||||
def got_message_good(self, phase, plaintext): pass
|
||||
@m.input()
|
||||
def got_message_bad(self): pass
|
||||
|
||||
# from Key
|
||||
@m.input()
|
||||
def got_key(self, key): pass
|
||||
|
||||
@m.output()
|
||||
def record_key(self, key):
|
||||
self._key = key
|
||||
|
@ -52,15 +54,15 @@ class Receive(object):
|
|||
self._S.got_verified_key(self._key)
|
||||
@m.output()
|
||||
def W_happy(self, phase, plaintext):
|
||||
self._W.happy()
|
||||
self._B.happy()
|
||||
@m.output()
|
||||
def W_got_message(self, phase, plaintext):
|
||||
assert isinstance(phase, type("")), type(phase)
|
||||
assert isinstance(plaintext, type(b"")), type(plaintext)
|
||||
self._W.got_message(phase, plaintext)
|
||||
self._B.got_message(phase, plaintext)
|
||||
@m.output()
|
||||
def W_scared(self):
|
||||
self._W.scared()
|
||||
self._B.scared()
|
||||
|
||||
S0_unknown_key.upon(got_key, enter=S1_unverified_key, outputs=[record_key])
|
||||
S1_unverified_key.upon(got_message_good, enter=S2_verified_key,
|
||||
|
|
|
@ -73,13 +73,13 @@ class RendezvousConnector(object):
|
|||
# TODO: Tor goes here
|
||||
return endpoints.HostnameEndpoint(self._reactor, hostname, port)
|
||||
|
||||
def wire(self, wormhole, mailbox, code, nameplate_lister):
|
||||
self._W = _interfaces.IWormhole(wormhole)
|
||||
def wire(self, boss, mailbox, code, nameplate_lister):
|
||||
self._B = _interfaces.IBoss(boss)
|
||||
self._M = _interfaces.IMailbox(mailbox)
|
||||
self._C = _interfaces.ICode(code)
|
||||
self._NL = _interfaces.INameplateLister(nameplate_lister)
|
||||
|
||||
# from Wormhole
|
||||
# from Boss
|
||||
def start(self):
|
||||
self._connector.startService()
|
||||
|
||||
|
@ -176,7 +176,7 @@ class RendezvousConnector(object):
|
|||
pass
|
||||
|
||||
def _response_handle_welcome(self, msg):
|
||||
self._W.rx_welcome(msg["welcome"])
|
||||
self._B.rx_welcome(msg["welcome"])
|
||||
|
||||
def _response_handle_claimed(self, msg):
|
||||
mailbox = msg["mailbox"]
|
||||
|
|
|
@ -17,8 +17,10 @@ class Send(object):
|
|||
@m.state(terminal=True)
|
||||
def S1_verified_key(self): pass
|
||||
|
||||
# from Receive
|
||||
@m.input()
|
||||
def got_verified_key(self, key): pass
|
||||
# from Boss
|
||||
@m.input()
|
||||
def send(self, phase, plaintext): pass
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user