Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/fowl/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ def fowl(ip_privacy, mailbox, debug, local, remote, code_length, code, readme, i
Forward Over Wormhole, Locally

Bi-directional streaming data over secure and durable Dilated
magic-wormhole connections.
magic-wormhole connections. (That means a connection directly to
one peer, encrypted to them only, with multiple subchannels)

This frontend is meant for humans -- if you want machine-parsable
data and commands, use fowld (or 'python -m fowl')
Expand Down Expand Up @@ -481,7 +482,6 @@ def _replay_visuals(cfg, messages):
where_are_we = messages[0]["timestamp"]

def current_time():
print(f"current {where_are_we}")
return where_are_we
status_tracker = _StatusTracker(time_provider=current_time)

Expand Down Expand Up @@ -509,7 +509,6 @@ def render():
for kw in msg.subchannels.values()
},
)
print(msg)
# time is hard
# intuitively, we want to trigger a redraw 4 times a second
# ...but waiting 0.25s with time.sleep() isn't right,
Expand Down
35 changes: 30 additions & 5 deletions src/fowl/visual.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ def render_status(st: FowlStatus, time_now, show_logo=True) -> Table: # Panel?
top.add_row(logo)

from rich import box
t = Table(show_header=False, show_lines=True, box=box.HORIZONTALS) #title="Active Connections")
t = Table(show_header=False, show_lines=False, box=box.HORIZONTALS) #title="Active Connections")
t.add_column(justify="left", width=8)
t.add_column(justify="left", width=40)
t.add_column(justify="left", width=8)

top.add_row(t)
top.add_row(t, end_section=True)

status_local = Text(chicken.default[0])
status_remote = Text(chicken.peer[0])
Expand Down Expand Up @@ -120,9 +120,9 @@ def render_status(st: FowlStatus, time_now, show_logo=True) -> Table: # Panel?
# can/should we tell diff between "never connected" and
# "reconnecting"?
status_remote.stylize(color_connecting)
t.add_row(Text("hints"), Text("\n".join(st.hints)), None)
t.add_row(Text("hints"), Text("\n".join(st.hints)), None, end_section=True)
else:
t.add_row(Text("hint"), Text("🐥 {}".format(st.peer_connected)), None)
t.add_row(Text("hint"), Text("🐥 {}".format(st.peer_connected)), None, end_section=True)

# turn purple if we / they are closing
if st.peer_closing:
Expand All @@ -133,16 +133,41 @@ def render_status(st: FowlStatus, time_now, show_logo=True) -> Table: # Panel?
if random.choice("abcdefgh") == "a":
status_local.plain = random.choice(chicken.default)

for id_, data in st.listeners.items():
# row for each listener we have locally
if st.listeners:
t.add_row(
Text("local", justify="center"),
Text("service name", justify="center"),
Text("remote", justify="center"),
end_section=True,
)
listeners = list(st.listeners.items())
for id_, data in listeners[:-1]:
t.add_row(
Text("{} {}".format('🧙' if data.remote else ' ', data.local_port)),
Text("{} {}".format("-->" if data.remote else "<--", data.service_name)),
Text("{}".format(' ' if data.remote else '🧙'), justify="center"),
)
for id_, data in listeners[-1:]:
t.add_row(
Text("{} {}".format('🧙' if data.remote else ' ', data.local_port)),
Text("{} {}".format("-->" if data.remote else "<--", data.service_name)),
Text("{}".format(' ' if data.remote else '🧙'), justify="center"),
end_section=True, # nicer way to add line after last listener?
)
if not st.listeners:
t.add_row("", Text("(no listeners)", justify="center"), "", end_section=True)

# show a row for each of our subchannels with a bytes graph and
# counter. recently-finished streams show as greyed out for 10s

if st.subchannels:
t.add_row(
Text("local", justify="center"),
Text("subchannel traffic", justify="center"),
Text("remote", justify="center"),
end_section=True,
)
for id_, data in st.subchannels.items():
if data.done_at is not None:
if time_now - data.done_at > 10.0:
Expand Down
Loading