@@ -98,12 +98,13 @@ var exitFunc = os.Exit
98
98
99
99
// Context groups listening context data together
100
100
type Context struct {
101
- watcher chan bool
102
- status * statusHandler
103
- statusHTTP * http.Server
104
- dial func () (net.Conn , error )
105
- metrics * sqmetrics.SquareMetrics
106
- cert * certificate
101
+ watcher chan bool
102
+ status * statusHandler
103
+ statusHTTP * http.Server
104
+ shutdownTimeout time.Duration
105
+ dial func () (net.Conn , error )
106
+ metrics * sqmetrics.SquareMetrics
107
+ cert * certificate
107
108
}
108
109
109
110
// Dialer is an interface for dialers (either net.Dialer, or http_dialer.HttpTunnel)
@@ -280,7 +281,7 @@ func run(args []string) error {
280
281
logger .Printf ("using target address %s" , * serverForwardAddress )
281
282
282
283
status := newStatusHandler (dial )
283
- context := & Context {watcher , status , nil , dial , metrics , cert }
284
+ context := & Context {watcher , status , nil , * shutdownTimeout , dial , metrics , cert }
284
285
285
286
// Start listening
286
287
err = serverListen (context )
@@ -309,7 +310,7 @@ func run(args []string) error {
309
310
}
310
311
311
312
status := newStatusHandler (dial )
312
- context := & Context {watcher , status , nil , dial , metrics , cert }
313
+ context := & Context {watcher , status , nil , * shutdownTimeout , dial , metrics , cert }
313
314
314
315
// Start listening
315
316
err = clientListen (context )
@@ -328,7 +329,7 @@ func run(args []string) error {
328
329
// connections. This is useful for the purpose of replacing certificates
329
330
// in-place without having to take downtime, e.g. if a certificate is expiring.
330
331
func serverListen (context * Context ) error {
331
- config , err := buildConfig (* caBundlePath )
332
+ config , err := buildConfig (* enabledCipherSuites , * caBundlePath )
332
333
if err != nil {
333
334
logger .Printf ("error trying to read CA bundle: %s" , err )
334
335
return err
@@ -353,10 +354,11 @@ func serverListen(context *Context) error {
353
354
}
354
355
355
356
proxy := & proxy {
356
- quit : 0 ,
357
- listener : tls .NewListener (listener , config ),
358
- handlers : & sync.WaitGroup {},
359
- dial : context .dial ,
357
+ quit : 0 ,
358
+ listener : tls .NewListener (listener , config ),
359
+ handlers : & sync.WaitGroup {},
360
+ connectTimeout : * timeoutDuration ,
361
+ dial : context .dial ,
360
362
}
361
363
362
364
if * statusAddress != "" {
@@ -399,10 +401,11 @@ func clientListen(context *Context) error {
399
401
}
400
402
401
403
proxy := & proxy {
402
- quit : 0 ,
403
- listener : listener ,
404
- handlers : & sync.WaitGroup {},
405
- dial : context .dial ,
404
+ quit : 0 ,
405
+ listener : listener ,
406
+ handlers : & sync.WaitGroup {},
407
+ connectTimeout : * timeoutDuration ,
408
+ dial : context .dial ,
406
409
}
407
410
408
411
if * statusAddress != "" {
@@ -437,7 +440,7 @@ func (context *Context) serveStatus() error {
437
440
mux .Handle ("/debug/pprof/trace" , http .HandlerFunc (pprof .Trace ))
438
441
}
439
442
440
- config , err := buildConfig (* caBundlePath )
443
+ config , err := buildConfig (* enabledCipherSuites , * caBundlePath )
441
444
if err != nil {
442
445
return err
443
446
}
@@ -495,7 +498,7 @@ func serverBackendDialer() (func() (net.Conn, error), error) {
495
498
496
499
// Get backend dialer function in client mode (connecting to a TLS port)
497
500
func clientBackendDialer (cert * certificate , network , address , host string ) (func () (net.Conn , error ), error ) {
498
- config , err := buildConfig (* caBundlePath )
501
+ config , err := buildConfig (* enabledCipherSuites , * caBundlePath )
499
502
if err != nil {
500
503
return nil , err
501
504
}
@@ -522,7 +525,7 @@ func clientBackendDialer(cert *certificate, network, address, host string) (func
522
525
logger .Printf ("using HTTP(S) CONNECT proxy %s" , (* clientConnectProxy ).String ())
523
526
524
527
// Use HTTP CONNECT proxy to connect to target.
525
- proxyConfig , err := buildConfig (* caBundlePath )
528
+ proxyConfig , err := buildConfig (* enabledCipherSuites , * caBundlePath )
526
529
if err != nil {
527
530
return nil , err
528
531
}
0 commit comments