|
@ -376,108 +376,110 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { |
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
//
|
|
|
func (h *HTTPTransport) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { |
|
|
func (h *HTTPTransport) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { |
|
|
for d.NextBlock(0) { |
|
|
for d.Next() { |
|
|
switch d.Val() { |
|
|
for d.NextBlock(0) { |
|
|
case "read_buffer": |
|
|
switch d.Val() { |
|
|
if !d.NextArg() { |
|
|
case "read_buffer": |
|
|
return d.ArgErr() |
|
|
if !d.NextArg() { |
|
|
} |
|
|
return d.ArgErr() |
|
|
size, err := humanize.ParseBytes(d.Val()) |
|
|
} |
|
|
if err != nil { |
|
|
size, err := humanize.ParseBytes(d.Val()) |
|
|
return d.Errf("invalid read buffer size '%s': %v", d.Val(), err) |
|
|
if err != nil { |
|
|
} |
|
|
return d.Errf("invalid read buffer size '%s': %v", d.Val(), err) |
|
|
h.ReadBufferSize = int(size) |
|
|
} |
|
|
|
|
|
h.ReadBufferSize = int(size) |
|
|
|
|
|
|
|
|
case "write_buffer": |
|
|
case "write_buffer": |
|
|
if !d.NextArg() { |
|
|
if !d.NextArg() { |
|
|
return d.ArgErr() |
|
|
return d.ArgErr() |
|
|
} |
|
|
} |
|
|
size, err := humanize.ParseBytes(d.Val()) |
|
|
size, err := humanize.ParseBytes(d.Val()) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return d.Errf("invalid write buffer size '%s': %v", d.Val(), err) |
|
|
return d.Errf("invalid write buffer size '%s': %v", d.Val(), err) |
|
|
} |
|
|
} |
|
|
h.WriteBufferSize = int(size) |
|
|
h.WriteBufferSize = int(size) |
|
|
|
|
|
|
|
|
case "dial_timeout": |
|
|
case "dial_timeout": |
|
|
if !d.NextArg() { |
|
|
if !d.NextArg() { |
|
|
return d.ArgErr() |
|
|
return d.ArgErr() |
|
|
} |
|
|
} |
|
|
dur, err := time.ParseDuration(d.Val()) |
|
|
dur, err := time.ParseDuration(d.Val()) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return d.Errf("bad timeout value '%s': %v", d.Val(), err) |
|
|
return d.Errf("bad timeout value '%s': %v", d.Val(), err) |
|
|
} |
|
|
} |
|
|
h.DialTimeout = caddy.Duration(dur) |
|
|
h.DialTimeout = caddy.Duration(dur) |
|
|
|
|
|
|
|
|
case "tls_client_auth": |
|
|
case "tls_client_auth": |
|
|
args := d.RemainingArgs() |
|
|
args := d.RemainingArgs() |
|
|
if len(args) != 2 { |
|
|
if len(args) != 2 { |
|
|
return d.ArgErr() |
|
|
return d.ArgErr() |
|
|
} |
|
|
} |
|
|
if h.TLS == nil { |
|
|
if h.TLS == nil { |
|
|
h.TLS = new(TLSConfig) |
|
|
h.TLS = new(TLSConfig) |
|
|
} |
|
|
} |
|
|
h.TLS.ClientCertificateFile = args[0] |
|
|
h.TLS.ClientCertificateFile = args[0] |
|
|
h.TLS.ClientCertificateKeyFile = args[1] |
|
|
h.TLS.ClientCertificateKeyFile = args[1] |
|
|
|
|
|
|
|
|
case "tls": |
|
|
case "tls": |
|
|
if h.TLS == nil { |
|
|
if h.TLS == nil { |
|
|
h.TLS = new(TLSConfig) |
|
|
h.TLS = new(TLSConfig) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
case "tls_insecure_skip_verify": |
|
|
case "tls_insecure_skip_verify": |
|
|
if d.NextArg() { |
|
|
if d.NextArg() { |
|
|
return d.ArgErr() |
|
|
return d.ArgErr() |
|
|
} |
|
|
} |
|
|
if h.TLS == nil { |
|
|
if h.TLS == nil { |
|
|
h.TLS = new(TLSConfig) |
|
|
h.TLS = new(TLSConfig) |
|
|
} |
|
|
} |
|
|
h.TLS.InsecureSkipVerify = true |
|
|
h.TLS.InsecureSkipVerify = true |
|
|
|
|
|
|
|
|
case "tls_timeout": |
|
|
case "tls_timeout": |
|
|
if !d.NextArg() { |
|
|
if !d.NextArg() { |
|
|
return d.ArgErr() |
|
|
return d.ArgErr() |
|
|
} |
|
|
} |
|
|
dur, err := time.ParseDuration(d.Val()) |
|
|
dur, err := time.ParseDuration(d.Val()) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return d.Errf("bad timeout value '%s': %v", d.Val(), err) |
|
|
return d.Errf("bad timeout value '%s': %v", d.Val(), err) |
|
|
} |
|
|
} |
|
|
if h.TLS == nil { |
|
|
if h.TLS == nil { |
|
|
h.TLS = new(TLSConfig) |
|
|
h.TLS = new(TLSConfig) |
|
|
} |
|
|
} |
|
|
h.TLS.HandshakeTimeout = caddy.Duration(dur) |
|
|
h.TLS.HandshakeTimeout = caddy.Duration(dur) |
|
|
|
|
|
|
|
|
case "keepalive": |
|
|
case "keepalive": |
|
|
if !d.NextArg() { |
|
|
if !d.NextArg() { |
|
|
return d.ArgErr() |
|
|
return d.ArgErr() |
|
|
} |
|
|
} |
|
|
if h.KeepAlive == nil { |
|
|
if h.KeepAlive == nil { |
|
|
h.KeepAlive = new(KeepAlive) |
|
|
h.KeepAlive = new(KeepAlive) |
|
|
} |
|
|
} |
|
|
if d.Val() == "off" { |
|
|
if d.Val() == "off" { |
|
|
var disable bool |
|
|
var disable bool |
|
|
h.KeepAlive.Enabled = &disable |
|
|
h.KeepAlive.Enabled = &disable |
|
|
} |
|
|
} |
|
|
dur, err := time.ParseDuration(d.Val()) |
|
|
dur, err := time.ParseDuration(d.Val()) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return d.Errf("bad duration value '%s': %v", d.Val(), err) |
|
|
return d.Errf("bad duration value '%s': %v", d.Val(), err) |
|
|
} |
|
|
} |
|
|
h.KeepAlive.IdleConnTimeout = caddy.Duration(dur) |
|
|
h.KeepAlive.IdleConnTimeout = caddy.Duration(dur) |
|
|
|
|
|
|
|
|
case "keepalive_idle_conns": |
|
|
case "keepalive_idle_conns": |
|
|
if !d.NextArg() { |
|
|
if !d.NextArg() { |
|
|
return d.ArgErr() |
|
|
return d.ArgErr() |
|
|
} |
|
|
} |
|
|
num, err := strconv.Atoi(d.Val()) |
|
|
num, err := strconv.Atoi(d.Val()) |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return d.Errf("bad integer value '%s': %v", d.Val(), err) |
|
|
return d.Errf("bad integer value '%s': %v", d.Val(), err) |
|
|
} |
|
|
} |
|
|
if h.KeepAlive == nil { |
|
|
if h.KeepAlive == nil { |
|
|
h.KeepAlive = new(KeepAlive) |
|
|
h.KeepAlive = new(KeepAlive) |
|
|
} |
|
|
} |
|
|
h.KeepAlive.MaxIdleConns = num |
|
|
h.KeepAlive.MaxIdleConns = num |
|
|
|
|
|
|
|
|
default: |
|
|
default: |
|
|
return d.Errf("unrecognized subdirective %s", d.Val()) |
|
|
return d.Errf("unrecognized subdirective %s", d.Val()) |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return nil |
|
|
return nil |
|
|