From 21523b8b5cefefe2bbd0fb68b3b61eabb6a8f88d Mon Sep 17 00:00:00 2001 From: Nathan Date: Sat, 19 Jan 2019 18:50:00 +0000 Subject: [PATCH 1/2] Add --hostname argument --- main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.go b/main.go index 72e92cca..984f20ab 100644 --- a/main.go +++ b/main.go @@ -263,6 +263,8 @@ var clientHelp = ` --proxy, An optional HTTP CONNECT proxy which will be used reach the chisel server. Authentication can be specified inside the URL. For example, http://admin:password@my-server.com:8081 + + --hostname, An optional HOST header to send, can be left blank. ` + commonHelp func client(args []string) { @@ -276,6 +278,7 @@ func client(args []string) { maxRetryInterval := flags.Duration("max-retry-interval", 0, "") proxy := flags.String("proxy", "", "") pid := flags.Bool("pid", false, "") + hostname := flags.String("hostname", "", "") verbose := flags.Bool("v", false, "") flags.Usage = func() { fmt.Print(clientHelp) @@ -299,6 +302,7 @@ func client(args []string) { HTTPProxy: *proxy, Server: args[0], Remotes: args[1:], + HostHeader: *hostname, }) if err != nil { log.Fatal(err) From cefd86aab849abf40dbb476d7a38550fa90b2477 Mon Sep 17 00:00:00 2001 From: Nathan Date: Sat, 19 Jan 2019 18:50:35 +0000 Subject: [PATCH 2/2] Add HOST header --- client/client.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/client/client.go b/client/client.go index 0728bea6..0e718815 100644 --- a/client/client.go +++ b/client/client.go @@ -28,6 +28,7 @@ type Config struct { Server string HTTPProxy string Remotes []string + HostHeader string } //Client represents a client instance @@ -198,7 +199,13 @@ func (c *Client) connectionLoop() { return c.httpProxyURL, nil } } - wsConn, _, err := d.Dial(c.server, nil) + hostHeader := http.Header{} + if c.config.HostHeader == "" { + hostHeader = nil + } else { + hostHeader = http.Header{"Host": {c.config.HostHeader}} + } + wsConn, _, err := d.Dial(c.server, hostHeader) if err != nil { connerr = err continue