Skip to content

Commit 167db31

Browse files
bradfitztombergan
authored andcommitted
http2/h2i: add flag to dial one ip:port but SNI/:authority like it's another
Change-Id: I35049c37558ddedb9056278c9878f3e3fd6f7f76 Reviewed-on: https://go-review.googlesource.com/53640 Reviewed-by: Avelino <[email protected]> Reviewed-by: Tom Bergan <[email protected]>
1 parent 090ebbd commit 167db31

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

http2/h2i/h2i.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ var (
4545
flagNextProto = flag.String("nextproto", "h2,h2-14", "Comma-separated list of NPN/ALPN protocol names to negotiate.")
4646
flagInsecure = flag.Bool("insecure", false, "Whether to skip TLS cert validation")
4747
flagSettings = flag.String("settings", "empty", "comma-separated list of KEY=value settings for the initial SETTINGS frame. The magic value 'empty' sends an empty initial settings frame, and the magic value 'omit' causes no initial settings frame to be sent.")
48+
flagDial = flag.String("dial", "", "optional ip:port to dial, to connect to a host:port but use a different SNI name (including a SNI name without DNS)")
4849
)
4950

5051
type command struct {
@@ -147,11 +148,14 @@ func (app *h2i) Main() error {
147148
InsecureSkipVerify: *flagInsecure,
148149
}
149150

150-
hostAndPort := withPort(app.host)
151+
hostAndPort := *flagDial
152+
if hostAndPort == "" {
153+
hostAndPort = withPort(app.host)
154+
}
151155
log.Printf("Connecting to %s ...", hostAndPort)
152156
tc, err := tls.Dial("tcp", hostAndPort, cfg)
153157
if err != nil {
154-
return fmt.Errorf("Error dialing %s: %v", withPort(app.host), err)
158+
return fmt.Errorf("Error dialing %s: %v", hostAndPort, err)
155159
}
156160
log.Printf("Connected to %v", tc.RemoteAddr())
157161
defer tc.Close()

0 commit comments

Comments
 (0)