From b249b45d109cdfef51b94cdeeb1ef7593e3b26ab Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Mon, 30 Sep 2019 09:07:43 -0600 Subject: tls: Change struct fields to pointers, add nil checks; rate.Burst update Making them pointers makes for cleaner JSON when adapting configs, if the struct is empty now it will be omitted entirely. The x/time/rate package was updated to support changing the burst, so we've incorporated that here and removed a TODO. --- modules/caddytls/connpolicy.go | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'modules/caddytls/connpolicy.go') diff --git a/modules/caddytls/connpolicy.go b/modules/caddytls/connpolicy.go index 7d86308..c82337d 100644 --- a/modules/caddytls/connpolicy.go +++ b/modules/caddytls/connpolicy.go @@ -155,17 +155,19 @@ func (p *ConnectionPolicy) buildStandardTLSConfig(ctx caddy.Context) error { } // session tickets support - cfg.SessionTicketsDisabled = tlsApp.SessionTickets.Disabled - - // session ticket key rotation - tlsApp.SessionTickets.register(cfg) - ctx.OnCancel(func() { - // do cleanup when the context is cancelled because, - // though unlikely, it is possible that a context - // needing a TLS server config could exist for less - // than the lifetime of the whole app - tlsApp.SessionTickets.unregister(cfg) - }) + if tlsApp.SessionTickets != nil { + cfg.SessionTicketsDisabled = tlsApp.SessionTickets.Disabled + + // session ticket key rotation + tlsApp.SessionTickets.register(cfg) + ctx.OnCancel(func() { + // do cleanup when the context is cancelled because, + // though unlikely, it is possible that a context + // needing a TLS server config could exist for less + // than the lifetime of the whole app + tlsApp.SessionTickets.unregister(cfg) + }) + } // TODO: Clean up session ticket active locks in storage if app (or process) is being closed! -- cgit v1.2.3