Apply suggestions from code review

Co-authored-by: Francis Lavoie <lavofr@gmail.com>
This commit is contained in:
Mohammed Al Sahaf 2024-08-27 10:48:59 +03:00 committed by GitHub
parent 38bb05c6c6
commit 908fa5e103
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 11 deletions

View file

@ -980,9 +980,9 @@ func (h *Handler) FinalizeUnmarshalCaddyfile(helper httpcaddyfile.Helper) error
// read_buffer <size> // read_buffer <size>
// write_buffer <size> // write_buffer <size>
// max_response_header <size> // max_response_header <size>
// network_proxy <module> { // network_proxy <module> {
// ... // ...
// } // }
// dial_timeout <duration> // dial_timeout <duration>
// dial_fallback_delay <duration> // dial_fallback_delay <duration>
// response_header_timeout <duration> // response_header_timeout <duration>
@ -993,9 +993,9 @@ func (h *Handler) FinalizeUnmarshalCaddyfile(helper httpcaddyfile.Helper) error
// tls_insecure_skip_verify // tls_insecure_skip_verify
// tls_timeout <duration> // tls_timeout <duration>
// tls_trusted_ca_certs <cert_files...> // tls_trusted_ca_certs <cert_files...>
// tls_trust_pool <module> { // tls_trust_pool <module> {
// ... // ...
// } // }
// tls_server_name <sni> // tls_server_name <sni>
// tls_renegotiation <level> // tls_renegotiation <level>
// tls_except_ports <ports...> // tls_except_ports <ports...>
@ -1074,12 +1074,13 @@ func (h *HTTPTransport) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
} }
case "forward_proxy_url": case "forward_proxy_url":
caddy.Log().Warn("The 'forward_proxy_url' field is deprecated. Use the 'network_proxy' field instead.") caddy.Log().Warn("The 'forward_proxy_url' field is deprecated. Use 'network_proxy url <url>' instead.")
if !d.NextArg() { if !d.NextArg() {
return d.ArgErr() return d.ArgErr()
} }
h.ForwardProxyURL = d.Val() h.ForwardProxyURL = d.Val()
case "network_proxy": case "network_proxy":
if !d.NextArg() { if !d.NextArg() {
return d.ArgErr() return d.ArgErr()
@ -1091,6 +1092,7 @@ func (h *HTTPTransport) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
return err return err
} }
h.NetworkProxyRaw = caddyconfig.JSONModuleObject(unm, "from", modStem, nil) h.NetworkProxyRaw = caddyconfig.JSONModuleObject(unm, "from", modStem, nil)
case "dial_timeout": case "dial_timeout":
if !d.NextArg() { if !d.NextArg() {
return d.ArgErr() return d.ArgErr()

View file

@ -145,15 +145,15 @@ type HTTPTransport struct {
// requests to the upstream. See [http.Transport.Proxy](https://pkg.go.dev/net/http#Transport.Proxy) // requests to the upstream. See [http.Transport.Proxy](https://pkg.go.dev/net/http#Transport.Proxy)
// for information regarding supported protocols. // for information regarding supported protocols.
// //
// Providing a value to this parameter results in // Providing a value to this parameter results in requests
// requests flowing through the reverse_proxy in the following // flowing through the reverse_proxy in the following way:
// way:
// //
// User Agent -> // User Agent ->
// reverse_proxy -> // reverse_proxy ->
// [proxy provided by the module] -> upstream // [proxy provided by the module] -> upstream
// //
// If nil/empty, default to reading the `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY`. // If nil, defaults to reading the `HTTP_PROXY`,
// `HTTPS_PROXY`, and `NO_PROXY` environment variables.
NetworkProxyRaw json.RawMessage `json:"network_proxy,omitempty" caddy:"namespace=caddy.network_proxy.source inline_key=from"` NetworkProxyRaw json.RawMessage `json:"network_proxy,omitempty" caddy:"namespace=caddy.network_proxy.source inline_key=from"`
h2cTransport *http2.Transport h2cTransport *http2.Transport