Skip to content

chore(KtorTcpTransport): add way to get localSocketAddress#136

Merged
kruton merged 1 commit into
mainfrom
ktor-address
May 6, 2026
Merged

chore(KtorTcpTransport): add way to get localSocketAddress#136
kruton merged 1 commit into
mainfrom
ktor-address

Conversation

@kruton
Copy link
Copy Markdown
Member

@kruton kruton commented May 5, 2026

This is needed for connection tracking in ConnectBot. If the local address for the socket is indicated in a network event, ConnectBot will either wait for it to come back or disconnect immediately.

Copilot AI review requested due to automatic review settings May 5, 2026 17:54
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a way to expose the local TCP socket address from the default Ktor transport so higher layers can correlate SSH connections with network events. In the sshlib codebase, this extends the default transport/factory path rather than the generic Transport interface.

Changes:

  • Added getLocalAddress() to KtorTcpTransport and KtorTcpTransportFactory.
  • Introduced internal local-address plumbing from Ktor sockets to Java InetSocketAddress.
  • Added unit coverage for transport-level local-address exposure and updated the public API surface file.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
sshlib/src/test/kotlin/org/connectbot/sshlib/transport/KtorTcpTransportTest.kt Adds unit test coverage for transport-level local address behavior and updates the mock socket.
sshlib/src/main/kotlin/org/connectbot/sshlib/transport/TransportFactory.kt Stores the last created KtorTcpTransport and exposes its local address via the concrete factory.
sshlib/src/main/kotlin/org/connectbot/sshlib/transport/TransportDependencies.kt Adds internal local-address support to the Ktor socket wrapper and conversion to java.net.InetSocketAddress.
sshlib/src/main/kotlin/org/connectbot/sshlib/transport/KtorTcpTransport.kt Exposes the connected socket’s local address from the transport.
sshlib/api.txt Records the new public methods in the API baseline.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread sshlib/src/main/kotlin/org/connectbot/sshlib/transport/TransportFactory.kt Outdated
Comment thread sshlib/src/main/kotlin/org/connectbot/sshlib/transport/TransportFactory.kt Outdated
@kruton kruton enabled auto-merge (rebase) May 5, 2026 18:08
This is needed for connection tracking in ConnectBot. If the local address
for the socket is indicated in a network event, ConnectBot will either
wait for it to come back or disconnect immediately.
@kruton kruton merged commit 632ad23 into main May 6, 2026
10 checks passed
@kruton kruton deleted the ktor-address branch May 6, 2026 01:45
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