atsign-foundation / noports

Connect to any device with no external listening ports open
https://noports.com
BSD 3-Clause "New" or "Revised" License
265 stars 15 forks source link

feat(WIP): Try noports wish application #1014

Closed XavierChanth closed 1 month ago

XavierChanth commented 4 months ago

- What I did

Update (June 13th, 2024): This was blocked by the C daemon, so we could statically link it into the go program. This is now ready to move forward, but I (@XavierChanth) don't currently have the bandwidth to continue working on it.

- How I did it

- How to verify it

- Description for the changelog feat: Try noports wish application

XavierChanth commented 4 months ago

Forgot to finish the welcome message, I will also explain all this code in the files changed tab before EOD

XavierChanth commented 4 months ago

@XavierChanth how do I run this? I've already tried the obvious go get && go run main.go but that just gets me:

# command-line-arguments
./main.go:59:4: undefined: AppMiddleware

What's your thinking on tests? And how we're going to host this?

I've written the main package across multiple files, so you have to run via go run .

I'm not sure what to do about tests yet, most of the functions should be pure enough to unit test, and I think I could emulate some end2end tests. For the time being, I was thinking I setup a trial container to test against, and give the team access for testing and feedback. Ideally we release this with the APKAM installer, so I'm about on track.

Also, when I write the tests I can refactor the other files so that they are different, isolated packages and that way running go run main.go will work as expected.

XavierChanth commented 4 months ago

Started dockerizing, this file explains how the usage is intended: https://github.com/atsign-foundation/noports/blob/try-noports-wish/packages/go/trynoports/docker.md

I designed the go application to spawn a go routine which runs sshnpd as a child process. This works fine, but SRV seems to crash... I think it has trouble binding sockets (see logs below)

FYI. The only dart:io classes used in srv are Process, Socket, InternetAddress.

At the moment the application crashes with:

2024/05/03 23:16:01 INFO Sshnpd |
  Msg=
  │ r.result is a bool
  │ INFO|2024-05-03 23:16:01.373459| sshnpd |svr.result is true
  │  bool, Result: true, SigningMetadata: {HashingAlgo: sha256, SigningAlgo: rsa2048, SignatureTimestamp: 2024-05-03 23:16:01.370563Z}
  │ INFO|2024-05-03 23:16:01.373442| sshnpd |sv
2024/05/03 23:16:01 INFO Sshnpd |
  Msg=
  │ r.result is a bool
  │ INFO|2024-05-03 23:16:01.373459| sshnpd |svr.result is true

2024/05/03 23:16:01 INFO Sshnpd |
  Msg=
  │ INFO|2024-05-03 23:16:01.373799| sshnpd |Setting up ports for tunnel session using dart (dart) from: @xavierchanth session: d5ae6098-6937-4f74-a0c6-787b61fc8264

2024/05/03 23:16:01 INFO Sshnpd |
  Msg=
  │ INFO|2024-05-03 23:16:01.392005|SrvImplExec|SrvImplExec.run(): executing /usr/local/at/srv -h uplink.xavierchanth.xyz -p 43219 --local-port 23234 --local-host localhost --multi --rv-auth --rv-e2ee

2024/05/03 23:16:01 INFO Sshnpd |
  Msg=
  │ 1780|SrvImplExec|rv stderr | #0      _Directory.createSync (dart:io/directory_impl.dart:124)
  │ INFO|2024-05-03 23:16:01.621786|SrvImplExec|rv stderr | #1      _File.createSync (dart:io/file_impl.dart:303)
  │ INFO|2024-05-03 23:16:01.621791|SrvImplExec|rv stde
2024/05/03 23:16:01 INFO Sshnpd |
  Msg=
  │ 1780|SrvImplExec|rv stderr | #0      _Directory.createSync (dart:io/directory_impl.dart:124)
  │ INFO|2024-05-03 23:16:01.621786|SrvImplExec|rv stderr | #1      _File.createSync (dart:io/file_impl.dart:303)
  │ INFO|2024-05-03 23:16:01.621791|SrvImplExec|rv stde
2024/05/03 23:16:01 INFO Sshnpd |
  Msg=
  │ mplExec|rv stderr | #4      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295)
  │ INFO|2024-05-03 23:16:01.621807|SrvImplExec|rv stderr | #5      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:18
2024/05/03 23:16:01 INFO Sshnpd |
  Msg=
  │ mplExec|rv stderr | #4      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295)
  │ INFO|2024-05-03 23:16:01.621807|SrvImplExec|rv stderr | #5      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:18
2024/05/03 23:16:01 INFO Sshnpd |
  Msg=
  │ 4)

2024/05/03 23:16:04 INFO Sshnpd |
  Msg=
  │ SEVERE|2024-05-03 23:16:04.573590| sshnpd |startNpt failed with unexpected error : TimeoutException after 0:00:03.000000: Future not completed

^C2024/05/03 23:31:57 INFO Stopping SSH server

The stuff indented under Msg= are the logs from sshnpd, which are relogged through the go program's logger.

XavierChanth commented 1 month ago

This should be progressable at this point, but we don't have as much demand for it compared to the amount of effort it would be to embed the C version of sshnpd into this program. Closing for now