meejah / fowl

Forward over Wormhole: streams over magic-wormhole Dilation connections
MIT License
28 stars 2 forks source link

How do I have listen port be on the remote side #17

Closed lnee94 closed 8 months ago

lnee94 commented 9 months ago

I have a ssh server on the remote end that I want to forward to the local port in order I have to send {"kind": "local","endpoint": "tcp:22:interface=localhost","local-endpoint": "tcp:localhost:2222",} from the remote host. Is there a json string that does this on the local end.

meejah commented 9 months ago

"kind": "remote"

meejah commented 9 months ago

(I'm working on a branch that re-factors a bunch of CLI stuff, and improves the docs .. hopefully this will be more clear in there).

Basically both commands are the same, but "kind": "local" means the listener is "here" and "kind": "remote" means the listener is "there".

meejah commented 9 months ago

If the docs here: https://github.com/meejah/fowl/blob/15.split-cli/docs/messages.rst do make this clear from your perspective please let me know :)

lnee94 commented 9 months ago

got it I'm look to build a app that manages sshfs waypipe and other stuff I was in a rut until I found this thanks for makeing it also I'm looking in to packageing this for debian

lnee94 commented 9 months ago

Can you give an example for listen on local port 2222 and the remote host port 22 connect to a ssh server. I tried using the docs I it gives me error. I work better with examples thanks.

meejah commented 9 months ago

Cool, sounds like a nice app! My use-case is a pair-programming thing (started here https://git.sr.ht/~meejah/pear-on ).

Beware that I'm splitting this into fowld (for programs like yours or mine to use) and fowl for humans to use -- those efforts are in the branch above.

I'll make an SSH example and push it in the next hour or two to the branch https://github.com/meejah/fowl/tree/15.split-cli and ping you here.

An ssh-based workflow is actually one of my personal uses for this: set up a laptop <--> desktop SSH session over fowld and then when I go to the cafe or whatever, I'm still connected -- shows where the problems are :) like that Dilation / magic-wormhole itself could benefit from giving more feedback to Fowl so I can show the user something (like "re-connecting").

meejah commented 9 months ago

Also, Debian packaging would be great! Let me know if there are changes that help packagers :) (magic-wormhole etc already is packaged AFAIK).

meejah commented 9 months ago

Not sure how much this helps at the moment, mostly because I'm changing some of the names from what's in main, but does this clear it up a little?

https://github.com/meejah/fowl/blob/15.split-cli/docs/usage.rst#overview-of-a-session

lnee94 commented 9 months ago

I tried {"kind": "local", "listen": "tcp:1234:interface=localhost", "connect": "tcp:localhost:22"(note quote was missing)} in version 32.10.2 (pypi) I get

ERR: [Failure instance: Traceback: <class 'KeyError'>: 'listen-endpoint'
/home/lnee/.local/pipx/venvs/fowl/lib/python3.11/site-packages/fowl/_proto.py:1041:lineReceived
/home/lnee/.local/pipx/venvs/fowl/lib/python3.11/site-packages/twisted/internet/defer.py:1348:ensureDeferred
/home/lnee/.local/pipx/venvs/fowl/lib/python3.11/site-packages/twisted/internet/defer.py:1323:fromCoroutine
/home/lnee/.local/pipx/venvs/fowl/lib/python3.11/site-packages/twisted/internet/defer.py:2168:_cancellableInlineCallbacks
--- <exception caught here> ---
/home/lnee/.local/pipx/venvs/fowl/lib/python3.11/site-packages/twisted/internet/defer.py:2000:_inlineCallbacks
/home/lnee/.local/pipx/venvs/fowl/lib/python3.11/site-packages/fowl/_proto.py:945:_process_command
/home/lnee/.local/pipx/venvs/fowl/lib/python3.11/site-packages/fowl/_proto.py:905:_local_to_remote_forward
]

I also tested the split-cli branch (which compiled the deb first try) I could not get fowld to connect

lnee94 commented 9 months ago

ok I figured out for fowld you need to run {"kind":"allocate-code"} and {"kind":"set-code","code":"1-hacker-way"} You get a lot of python errors and this as the debug output

forward.RC.R.connected
forward.RC.R.tx(BIND )
forward.N[S0A].connected -> [S0B]
forward.M[S0A].connected -> [S0B]
forward.L[S0A_idle_disconnected].connected -> [S0B_idle_connected]
forward.RC.R.connected finished notifications
forward.RC.R.rx(welcome )
forward.C[S0_idle].allocate_code -> [S3_allocating]
 forward.C.do_start_allocate()
forward.RC.R.tx(ALLOCATE )
forward.RC.R.rx(allocated )
forward.C[S3_allocating].allocated -> [S4_known]
 forward.C.do_finish_allocate()
forward.N[S0B]._set_nameplate -> [S2B]
 forward.N.record_nameplate_and_RC_tx_claim()
forward.RC.R.tx(CLAIM )
forward.B[S0_empty].got_code -> [S1_lonely]
 forward.B.do_got_code()
forward.K[S00].got_code -> [S10]
 forward.K.deliver_code()
forward.SK[S0_know_nothing].got_code -> [S1_know_code]
 forward.SK.build_pake()
forward.M[S0B].add_message -> [S0B]
 forward.M.queue()
forward.RC.R.rx(claimed )
forward.N[S2B].rx_claimed -> [S3B]
 forward.N.I_got_wordlist()
 forward.N.M_got_mailbox()
forward.M[S0B].got_mailbox -> [S2B]
 forward.M.record_mailbox_and_RC_tx_open_and_drain()
forward.RC.R.tx(OPEN )
forward.RC.R.tx(ADD pake)
forward.RC.R.rx(message pake[mine])
forward.M[S2B].rx_message_ours -> [S2B]
 forward.M.dequeue()
forward.RC.R.rx(message pake)
forward.M[S2B].rx_message_theirs -> [S2B]
 forward.M.N_release_and_accept()
forward.N[S3B].release -> [S4B]
 forward.N.RC_tx_release()
forward.RC.R.tx(RELEASE )
forward.O[S0_no_pake].got_pake -> [S1_yes_pake]
 forward.O.notify_key()
forward.K[S10].got_pake -> [S11]
 forward.K.deliver_pake()
forward.SK[S1_know_code].got_pake_good -> [S2_know_key]
 forward.SK.compute_key()
forward.B[S1_lonely].got_key -> [S1_lonely]
 forward.B.W_got_key()
 forward.B.D_got_key()
forward.M[S2B].add_message -> [S2B]
 forward.M.queue()
 forward.M.RC_tx_add()
forward.RC.R.tx(ADD version)
forward.R[S0_unknown_key].got_key -> [S1_unverified_key]
 forward.R.record_key()
 forward.O.drain()
forward.RC.R.rx(message version)
forward.M[S2B].rx_message_theirs -> [S2B]
 forward.M.N_release_and_accept()
forward.N[S4B].release -> [S4B]
forward.O[S1_yes_pake].got_non_pake -> [S1_yes_pake]
 forward.O.deliver()
forward.R[S1_unverified_key].got_message_good -> [S2_verified_key]
 forward.R.S_got_verified_key()
forward.S[S0_no_key].got_verified_key -> [S1_verified_key]
 forward.S.record_key()
 forward.S.drain()
 forward.R.W_happy()
forward.B[S1_lonely].happy -> [S2_happy]
 forward.R.W_got_verifier()
forward.B[S2_happy].got_verifier -> [S2_happy]
 forward.B.W_got_verifier()
 forward.R.W_got_message()
forward.B[S2_happy]._got_version -> [S2_happy]
 forward.B.process_version()
forward.S[S1_verified_key].send -> [S1_verified_key]
 forward.S.deliver()
forward.M[S2B].add_message -> [S2B]
 forward.M.queue()
 forward.M.RC_tx_add()
forward.RC.R.tx(ADD dilate-0)
forward.RC.R.rx(released )
forward.N[S4B].rx_released -> [S5]
 forward.N.T_nameplate_done()
forward.T[Snmo].nameplate_done -> [Smo]
forward.RC.R.rx(message version[mine])
forward.M[S2B].rx_message_ours -> [S2B]
 forward.M.dequeue()
forward.RC.R.rx(message dilate-0)
forward.M[S2B].rx_message_theirs -> [S2B]
 forward.M.N_release_and_accept()
forward.N[S5].release -> [S5]
forward.O[S1_yes_pake].got_non_pake -> [S1_yes_pake]
 forward.O.deliver()
forward.R[S2_verified_key].got_message_good -> [S2_verified_key]
 forward.R.W_got_message()
forward.B[S2_happy]._got_dilate -> [S2_happy]
 forward.B.D_received_dilate()
forward.S[S1_verified_key].send -> [S1_verified_key]
 forward.S.deliver()
forward.M[S2B].add_message -> [S2B]
 forward.M.queue()
 forward.M.RC_tx_add()
forward.RC.R.tx(ADD dilate-1)
forward.S[S1_verified_key].send -> [S1_verified_key]
 forward.S.deliver()
forward.M[S2B].add_message -> [S2B]
 forward.M.queue()
 forward.M.RC_tx_add()
forward.RC.R.tx(ADD dilate-2)
forward.RC.R.rx(message dilate-0[mine])
forward.M[S2B].rx_message_ours -> [S2B]
 forward.M.dequeue()
forward.RC.R.rx(message dilate-1)
forward.M[S2B].rx_message_theirs -> [S2B]
 forward.M.N_release_and_accept()
forward.N[S5].release -> [S5]
forward.O[S1_yes_pake].got_non_pake -> [S1_yes_pake]
 forward.O.deliver()
forward.R[S2_verified_key].got_message_good -> [S2_verified_key]
 forward.R.W_got_message()
forward.B[S2_happy]._got_dilate -> [S2_happy]
 forward.B.D_received_dilate()
forward.RC.R.rx(message dilate-2)
forward.M[S2B].rx_message_theirs -> [S2B]
 forward.M.N_release_and_accept()
forward.N[S5].release -> [S5]
forward.O[S1_yes_pake].got_non_pake -> [S1_yes_pake]
 forward.O.deliver()
forward.R[S2_verified_key].got_message_good -> [S2_verified_key]
 forward.R.W_got_message()
forward.B[S2_happy]._got_dilate -> [S2_happy]
 forward.B.D_received_dilate()
forward.RC.R.rx(message dilate-1[mine])
forward.M[S2B].rx_message_ours -> [S2B]
 forward.M.dequeue()
forward.RC.R.rx(message dilate-2[mine])
forward.M[S2B].rx_message_ours -> [S2B]
 forward.M.dequeue()
forward.RC.R.lost
forward.N[S5].lost -> [S5]
forward.M[S2B].lost -> [S2A]
forward.L[S0B_idle_connected].lost -> [S0A_idle_disconnected]
meejah commented 8 months ago

If this isn't clear in the latest release (see e.g. https://fowl.readthedocs.io/en/latest/usage.html#common-fowl-options ) then please re-open this bug :)