source_file
comment "// Copyright 2015 Matthew Holt and The Caddy Authors"
comment "//"
comment "// Licensed under the Apache License, Version 2.0 (the \"Lice"...
comment "// you may not use this file except in compliance with the L"...
comment "// You may obtain a copy of the License at"
comment "//"
comment "// http://www.apache.org/licenses/LICENSE-2.0"
comment "//"
comment "// Unless required by applicable law or agreed to in writing"...
comment "// distributed under the License is distributed on an \"AS IS"...
comment "// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expr"...
comment "// See the License for the specific language governing permi"...
comment "// limitations under the License."
package_clause
package "package"
package_identifier "reverseproxy"
import_declaration
import "import"
import_spec_list
( "("
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "context"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "crypto/tls"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "crypto/x509"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "encoding/base64"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "encoding/json"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "fmt"
" "\""
import_spec
package_identifier "weakrand"
interpreted_string_literal
" "\""
interpreted_string_literal_content "math/rand"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "net"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "net/http"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "net/url"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "os"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "reflect"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "strings"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "time"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "github.com/pires/go-proxyproto"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "github.com/quic-go/quic-go/http3"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "go.uber.org/zap"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "go.uber.org/zap/zapcore"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "golang.org/x/net/http2"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "github.com/caddyserver/caddy/v2"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "github.com/caddyserver/caddy/v2/modules/caddyhttp"
" "\""
import_spec
interpreted_string_literal
" "\""
interpreted_string_literal_content "github.com/caddyserver/caddy/v2/modules/caddytls"
" "\""
) ")"
function_declaration (+24 nodes collapsed)
comment "// HTTPTransport is essentially a configuration wrapper for "...
comment "// It defines a JSON structure useful when configuring the H"...
comment "// for Caddy's reverse proxy. It builds its http.Transport a"...
type_declaration (+245 nodes collapsed)
comment "// CaddyModule returns the Caddy module information."
method_declaration (+68 nodes collapsed)
comment "// Provision sets up h.Transport with a *http.Transport"
comment "// that is ready to use."
method_declaration (+113 nodes collapsed)
comment "// NewTransport builds a standard-lib-compatible http.Transp"...
method_declaration
func "func"
parameter_list
( "("
parameter_declaration
identifier "h"
pointer_type
* "*"
type_identifier "HTTPTransport"
) ")"
field_identifier "NewTransport"
parameter_list
( "("
parameter_declaration
identifier "caddyCtx"
qualified_type
package_identifier "caddy"
. "."
type_identifier "Context"
) ")"
parameter_list
( "("
parameter_declaration
pointer_type
* "*"
qualified_type
package_identifier "http"
. "."
type_identifier "Transport"
, ","
parameter_declaration
type_identifier "error"
) ")"
block
{ "{"
comment "// Set keep-alive defaults if it wasn't otherwise configured"
statement_list
if_statement (+78 nodes collapsed)
comment "// Set a relatively short default dial timeout."
comment "// This is helpful to make load-balancer retries more speedy"...
if_statement (+36 nodes collapsed)
short_var_declaration (+51 nodes collapsed)
if_statement (+290 nodes collapsed)
if_statement (+222 nodes collapsed)
short_var_declaration (+776 nodes collapsed)
comment "// negotiate any HTTP/SOCKS proxy for the HTTP transport"
var_declaration (+29 nodes collapsed)
if_statement (+129 nodes collapsed)
short_var_declaration (+105 nodes collapsed)
if_statement (+92 nodes collapsed)
if_statement (+124 nodes collapsed)
comment "// The proxy protocol header can only be sent once right aft"...
comment "// So single connection must not be used for multiple reques"...
comment "// come from different clients."
if_statement (+52 nodes collapsed)
if_statement (+29 nodes collapsed)
if_statement
if "if"
call_expression
identifier "sliceContains"
argument_list
( "("
selector_expression
identifier "h"
. "."
field_identifier "Versions"
, ","
interpreted_string_literal
" "\""
interpreted_string_literal_content "2"
" "\""
) ")"
block (+35 nodes collapsed)
comment "// configure HTTP/3 transport if enabled; however, this does"...
comment "// automatically fall back to lower versions like most web b"...
comment "// do (that'd add latency and complexity, besides, we expect"...
comment "// site owners control the backends), so it must be exclusi"...
if_statement
if "if"
binary_expression (+28 nodes collapsed)
block (+93 nodes collapsed)
else "else"
if_statement
if "if"
binary_expression
binary_expression
call_expression
identifier "len"
argument_list
( "("
selector_expression
identifier "h"
. "."
field_identifier "Versions"
) ")"
> ">"
int_literal "1"
&& "&&"
call_expression
identifier "sliceContains"
argument_list
( "("
selector_expression
identifier "h"
. "."
field_identifier "Versions"
, ","
interpreted_string_literal
" "\""
interpreted_string_literal_content "3"
" "\""
) ")"
block (+21 nodes collapsed)
comment "// if h2c is enabled, configure its transport (std lib http."...
comment "// does not \"HTTP/2 over cleartext TCP\")"
if_statement
if "if"
call_expression
identifier "sliceContains"
argument_list
( "("
selector_expression
identifier "h"
. "."
field_identifier "Versions"
, ","
interpreted_string_literal
" "\""
interpreted_string_literal_content "h2c"
" "\""
) ")"
block (+130 nodes collapsed)
return_statement
return "return"
expression_list
identifier "rt"
, ","
nil "nil"
} "}"
comment "// replaceTLSServername checks TLS servername to see if it n"...
comment "// if it does need replacing, it creates a new cloned HTTPTr"...
comment "// and does the replacing of the TLS servername on that and "...
comment "// if no replacement is necessary it returns the original"
method_declaration (+280 nodes collapsed)
comment "// RoundTrip implements http.RoundTripper."
method_declaration (+204 nodes collapsed)
comment "// SetScheme ensures that the outbound request req"
comment "// has the scheme set in its URL; the underlying"
comment "// http.Transport requires a scheme to be set."
comment "//"
comment "// This method may be used by other transport modules"
comment "// that wrap/use this one."
method_declaration (+96 nodes collapsed)
comment "// shouldUseTLS returns true if TLS should be used for req."
method_declaration (+106 nodes collapsed)
comment "// TLSEnabled returns true if TLS is enabled."
method_declaration (+27 nodes collapsed)
comment "// EnableTLS enables TLS on the transport."
method_declaration (+37 nodes collapsed)
comment "// Cleanup implements caddy.CleanerUpper and closes any idle"...
method_declaration (+50 nodes collapsed)
comment "// TLSConfig holds configuration related to the TLS configur"...
comment "// transport/client."
type_declaration (+146 nodes collapsed)
comment "// MakeTLSClientConfig returns a tls.Config usable by a clie"...
comment "// If there is no custom TLS configuration, a nil config may"...
method_declaration (+1198 nodes collapsed)
comment "// KeepAlive holds configuration pertaining to HTTP Keep-Ali"...
type_declaration (+57 nodes collapsed)
comment "// tcpRWTimeoutConn enforces read/write timeouts for a TCP c"...
comment "// If it fails to set deadlines, the error is logged but doe"...
comment "// the read/write attempt (ignoring the error is consistent "...
comment "// the standard library does: https://github.com/golang/go/b"...
type_declaration (+31 nodes collapsed)
method_declaration (+159 nodes collapsed)
method_declaration (+159 nodes collapsed)
comment "// decodeBase64DERCert base64-decodes, then DER-decodes, cer"...
function_declaration (+75 nodes collapsed)
comment "// sliceContains returns true if needle is in haystack."
function_declaration
func "func"
identifier "sliceContains"
parameter_list
( "("
parameter_declaration
identifier "haystack"
slice_type
[ "["
] "]"
type_identifier "string"
, ","
parameter_declaration
identifier "needle"
type_identifier "string"
) ")"
type_identifier "bool"
block
{ "{"
statement_list
for_statement
for "for"
range_clause
expression_list
identifier "_"
, ","
identifier "s"
:= ":="
range "range"
identifier "haystack"
block
{ "{"
statement_list
if_statement
if "if"
binary_expression
identifier "s"
== "=="
identifier "needle"
block
{ "{"
statement_list
return_statement
return "return"
expression_list
true "true"
} "}"
} "}"
return_statement
return "return"
expression_list
false "false"
} "}"
comment "// Interface guards"
var_declaration (+78 nodes collapsed)