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

Adding support for TCP port forwarding #16

Merged
merged 7 commits into from May 23, 2022
Merged

Conversation

dmitry-zaitsev
Copy link
Contributor

As requested in issue #1

Usage (Kotlin):

dadb.tcpForward(
    hostPort = 7001,
    targetPort = 7001
).use {
    // Do operations that depend on port forwarding
}

Copy link
Contributor

@mfilenko mfilenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for taking care of this, Dima! 👏

@Leland-Takamine
Copy link
Contributor

Let's add documentation for this api in the Readme as well

@Leland-Takamine
Copy link
Contributor

Should the forwarding be able to automatically recover from IO errors on either end?

@dmitry-zaitsev
Copy link
Contributor Author

@Leland-Takamine the part which can throw an exception is a forward method. In case of an exception, we shouldn't just retry as there is no guarantee that the receiver is idempotent and should instead surface the error to the user.

@Leland-Takamine
Copy link
Contributor

This implementation seems more straightforward: TCPForwardServer

Are we handling cases that the above implementation doesn't handle?

@dmitry-zaitsev
Copy link
Contributor Author

@Leland-Takamine TCPForwardServer is nice (and a source of inspiration), but it misses some points:

  • It blocks the thread once started. Meaning we have to handle the serverThread ourselves.
  • Assumes that the server will keep running forever (it won't). When the server is stopped, we need to wait for resources to be closed before it can be started up again (otherwise ports might be unavailable) which is not instantaneous.

@Leland-Takamine
Copy link
Contributor

Got it - looks good to me!

@dmitry-zaitsev dmitry-zaitsev merged commit ae8cae9 into master May 23, 2022
@dmitry-zaitsev dmitry-zaitsev deleted the port-forwarding branch May 23, 2022 08:47
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.

None yet

3 participants