Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Duplicate for CI) Propagate half-closes correctly in forward #165

Closed
wants to merge 2 commits into from

Conversation

euank
Copy link
Contributor

@euank euank commented May 29, 2024

Duplicate of #163, but as a branch on this repo, to force the build-and-test job to run once.

This is the same code, so if it passes here, the intent is to close this PR and merge the original.
Due to using an authtoken secret, we need a local branch + pull request in order to actually run the CI step, and while I'm fairly confident this should pass CI, it's worth verifying properly before merging, even if juggling branches like this is a bit inconvenient.

abakum and others added 2 commits May 28, 2024 04:02
Before, the following would not work as you would expect:

```go
// # One terminal
// $ ncat --recv-only -l 9090

// ngrok-go code
fwd, err := sess.ListenAndForward(
  ctx,
  "127.0.0.1:9090",
  config.TCPEndpoint(),
)

// fwd.URL() is 0.tcp.jp.ngrok.io:14517 for this example

// another terminal
// $ ncat --send-only 0.tcp.jp.ngrok.io 14517 < hello-world.txt
```

What we would expect from the above would be for the send side to send
"hello world" and exit, and then the recv side to print "hello world"
and also exit.

This is what happens if you do `ncat --send-only localhost 9090`
instead of copying through the ngrok tcp tunnel.

Before this change, when copying through ngrok the recv side would not
exit because the 'Close' of the connection did not get propagated
through the 'join'.

I've also added a unit test showing this.

Thank you to @abakum for originally noticing this issue and offering a
fix over in #137.
In the hopes of landing this more quickly, I've written a new version, derived from
the internal ngrok agent's join code, which should thus be easier to
review etc.

To try and give credit correctly, I've maintained the original commits
from #137 as well.
@euank
Copy link
Contributor Author

euank commented May 29, 2024

Passed CI, cool, closing so I can go back and merge the original.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants