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