Skip to content

Commit 9698471

Browse files
authored
Merge pull request #76 from nathan0/master
Add optional HOST header
2 parents a451541 + cefd86a commit 9698471

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

client/client.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ type Config struct {
2828
Server string
2929
HTTPProxy string
3030
Remotes []string
31+
HostHeader string
3132
}
3233

3334
//Client represents a client instance
@@ -198,7 +199,13 @@ func (c *Client) connectionLoop() {
198199
return c.httpProxyURL, nil
199200
}
200201
}
201-
wsConn, _, err := d.Dial(c.server, nil)
202+
hostHeader := http.Header{}
203+
if c.config.HostHeader == "" {
204+
hostHeader = nil
205+
} else {
206+
hostHeader = http.Header{"Host": {c.config.HostHeader}}
207+
}
208+
wsConn, _, err := d.Dial(c.server, hostHeader)
202209
if err != nil {
203210
connerr = err
204211
continue

main.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ var clientHelp = `
263263
--proxy, An optional HTTP CONNECT proxy which will be used reach
264264
the chisel server. Authentication can be specified inside the URL.
265265
For example, http://admin:[email protected]:8081
266+
267+
--hostname, An optional HOST header to send, can be left blank.
266268
` + commonHelp
267269

268270
func client(args []string) {
@@ -276,6 +278,7 @@ func client(args []string) {
276278
maxRetryInterval := flags.Duration("max-retry-interval", 0, "")
277279
proxy := flags.String("proxy", "", "")
278280
pid := flags.Bool("pid", false, "")
281+
hostname := flags.String("hostname", "", "")
279282
verbose := flags.Bool("v", false, "")
280283
flags.Usage = func() {
281284
fmt.Print(clientHelp)
@@ -299,6 +302,7 @@ func client(args []string) {
299302
HTTPProxy: *proxy,
300303
Server: args[0],
301304
Remotes: args[1:],
305+
HostHeader: *hostname,
302306
})
303307
if err != nil {
304308
log.Fatal(err)

0 commit comments

Comments
 (0)