Documentation
¶
Index ¶
- Variables
- func LoadFallback404(path string) []byte
- func LogCertLoaded(route, domain, file string, cert *tls.Certificate)
- type AccessRecord
- type Http3Server
- type HttpProxy
- func (s *HttpProxy) Close() error
- func (s *HttpProxy) FallbackCert(hello *tls.ClientHelloInfo) (*tls.Certificate, error)
- func (s *HttpProxy) ServeFallback(c net.Conn, state *tls.ConnectionState) bool
- func (s *HttpProxy) ServeHTTP3(qc *quic.Conn, wrap func(http.Handler) http.Handler) bool
- func (s *HttpProxy) Start() error
- type HttpServer
- func (s *HttpServer) Close() error
- func (s *HttpServer) DialContext(ctx context.Context, _, _ string) (net.Conn, error)
- func (s *HttpServer) DialTlsContext(ctx context.Context, network, addr string) (net.Conn, error)
- func (s *HttpServer) NewServer(port int, scheme string) *http.Server
- func (s *HttpServer) Start() error
- type HttpsListener
- type HttpsServer
- type NotFound
- type Plans
- type Store
Constants ¶
This section is empty.
Variables ¶
var ErrBind = errors.New("http proxy")
ErrBind wraps the error of a listener that could not be opened; that failure was logged already.
Functions ¶
func LoadFallback404 ¶
LoadFallback404 returns the body of fallback_404_file, the built-in one if path is empty or unreadable.
func LogCertLoaded ¶
func LogCertLoaded(route, domain, file string, cert *tls.Certificate)
LogCertLoaded reports that cert is in use for route; domain and file are left out when empty.
Types ¶
type AccessRecord ¶
type AccessRecord struct {
Time time.Time // when the request arrived
Route string // the domain of the host entry, or "http"/"https" when none matched
Host int // the host entry id, 0 when none matched
SrcIP string
Method string
Domain string // the Host header
Path string
Query string // the raw query, without "?"
Proto string // such as HTTP/1.1
Status int // 0 when the connection was dropped without a response
Bytes int64 // of the response body
Duration time.Duration
Target string // the backend host:port, empty when none was dialed
Referer string
UserAgent string
}
AccessRecord is one request to the domain proxy, given to HttpProxy.AccessLog when the request ends, refused ones included.
type Http3Server ¶
type Http3Server struct {
*HttpsServer
// contains filtered or unexported fields
}
func NewHttp3Server ¶
func NewHttp3Server(httpsSrv *HttpsServer, udpConn net.PacketConn) *Http3Server
func (*Http3Server) Close ¶
func (s *Http3Server) Close() error
Close stops the server. Closing the socket ends the QUIC transport and its connections, so the workers return.
func (*Http3Server) GetConfigForClient ¶
func (s *Http3Server) GetConfigForClient(info *tls.ClientHelloInfo) (*tls.Config, error)
func (*Http3Server) HandleQUIC ¶
func (s *Http3Server) HandleQUIC(qc *quic.Conn, alpn, sni string)
func (*Http3Server) Start ¶
func (s *Http3Server) Start() error
type HttpProxy ¶
type HttpProxy struct {
*proxy.BaseServer
HttpServer *HttpServer
HttpsServer *HttpsServer
Http3Server *Http3Server
HttpPort int
HttpsPort int
Http3Port int
HttpOnlyPass string
HttpPortStr string
HttpsPortStr string
Http3PortStr string
TimeLimitErrorContent []byte
FlowLimitErrorContent []byte
// Fallback404Content is the body of the 404 a bridge connection gets
// for a host of no route (fallback_404_file).
Fallback404Content []byte
Magic *certmagic.Config
Acme *certmagic.ACMEIssuer
ResponseHeaderTimeout time.Duration
AddOrigin bool
Http3Bridge bool
ErrorAlways bool
ForceAutoSsl bool
// AccessLog, if set, is called with every request that ends, whatever
// the log level; set it before Start.
AccessLog func(AccessRecord)
// contains filtered or unexported fields
}
func NewHttpProxy ¶
func (*HttpProxy) FallbackCert ¶
func (s *HttpProxy) FallbackCert(hello *tls.ClientHelloInfo) (*tls.Certificate, error)
FallbackCert returns the certificate for the TLS of a bridge connection that asks for hello.ServerName, chosen as the domain proxy chooses for a visitor of that name, or nil, nil when the name matches no route and the caller's default certificate applies.
func (*HttpProxy) ServeFallback ¶
ServeFallback serves c through the domain proxy, every byte of the HTTP request still unread. state is the TLS c arrived over, nil for none: only HTTP/1.1 is possible, as no ALPN was negotiated for it. It returns false, leaving c to the caller, when the proxy has no HTTP engine or is closed.
func (*HttpProxy) ServeHTTP3 ¶
ServeHTTP3 serves qc as HTTP/3 through the domain proxy until qc ends, wrap wrapping its handler. It returns false when the proxy has no HTTP engine.
type HttpServer ¶
type HttpServer struct {
*HttpProxy
// contains filtered or unexported fields
}
func NewHttpServer ¶
func NewHttpServer(httpProxy *HttpProxy, l net.Listener) *HttpServer
func (*HttpServer) Close ¶
func (s *HttpServer) Close() error
func (*HttpServer) DialContext ¶
DialContext opens the backend connection of a regular request, whose proxyRequest ctx carries.
func (*HttpServer) DialTlsContext ¶
func (*HttpServer) Start ¶
func (s *HttpServer) Start() error
type HttpsListener ¶
type HttpsListener struct {
// contains filtered or unexported fields
}
HttpsListener wraps a parent listener and hands out connections whose TLS handshake has already completed.
func NewHttpsListener ¶
func NewHttpsListener(l net.Listener) *HttpsListener
func (*HttpsListener) Addr ¶
func (l *HttpsListener) Addr() net.Addr
func (*HttpsListener) Close ¶
func (l *HttpsListener) Close() error
type HttpsServer ¶
type HttpsServer struct {
*HttpServer
// contains filtered or unexported fields
}
func NewHttpsServer ¶
func NewHttpsServer(httpServer *HttpServer, l net.Listener) *HttpsServer
func (*HttpsServer) Close ¶
func (s *HttpsServer) Close() error
func (*HttpsServer) Start ¶
func (s *HttpsServer) Start() error
type NotFound ¶
type NotFound struct {
// contains filtered or unexported fields
}
NotFound answers every request of the connections handed to it with the 404 of an unknown site: the fallback of a node that runs no domain proxy.
func NewNotFound ¶
NewNotFound returns a NotFound that answers with body.
func (*NotFound) ServeFallback ¶
ServeFallback serves c, every byte of its request unread; it returns false once closed.
type Plans ¶
type Plans struct {
// contains filtered or unexported fields
}
Plans holds the compiled plan of each host. The server drops the plan of a host whenever the host is edited or deleted.
type Store ¶
type Store interface {
// GetInfoByHost finds the host entry that serves request r for host.
GetInfoByHost(host string, r *http.Request) (*model.Host, error)
// FindCertByHost finds the host entry whose certificate serves name.
FindCertByHost(name string) (*model.Host, error)
// RangeClientCertHosts calls fn for the hosts of client clientID that
// carry a certificate, until fn returns false.
RangeClientCertHosts(clientID int, fn func(*model.Host) bool)
}
Store is what the host proxy reads of the stored hosts.