ssh: allow to bind to a hostname in remote forwarding
To avoid breaking backwards compatibility, we fix Listen, which receives the address as a string, while ListenTCP can still only be used with IP addresses. Fixes golang/go#33227 Fixes golang/go#37239 Change-Id: I4d45b40fdcb0d6012ed8da59a02149fa37e7db50 Reviewed-on: https://go-review.googlesource.com/c/crypto/+/599995 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Bishakh Ghosh <ghoshbishakh@gmail.com> Reviewed-by: Filippo Valsorda <filippo@golang.org> Auto-Submit: Nicola Murino <nicola.murino@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
committed by
Gopher Robot
parent
122a78f140
commit
79ec3a51fc
@@ -51,6 +51,8 @@ func testPortForward(t *testing.T, n, listenAddr string) {
|
||||
}
|
||||
}()
|
||||
|
||||
// The forwarded address match the listen address because we run the tests
|
||||
// on the same host.
|
||||
forwardedAddr := sshListener.Addr().String()
|
||||
netConn, err := net.Dial(n, forwardedAddr)
|
||||
if err != nil {
|
||||
@@ -111,6 +113,8 @@ func testPortForward(t *testing.T, n, listenAddr string) {
|
||||
}
|
||||
|
||||
func TestPortForwardTCP(t *testing.T) {
|
||||
testPortForward(t, "tcp", ":0")
|
||||
testPortForward(t, "tcp", "[::]:0")
|
||||
testPortForward(t, "tcp", "localhost:0")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user