Documentation ¶
Index ¶
- Constants
- Variables
- func GetHttpRequestInfo(c frpNet.Conn) (_ frpNet.Conn, _ map[string]string, err error)
- func GetHttpsHostname(c frpNet.Conn) (_ frpNet.Conn, _ map[string]string, err error)
- func HttpAuthFunc(c frpNet.Conn, userName, passWord, authorization string) (bAccess bool, err error)
- func IsWebsocketRequest(req *http.Request) bool
- func ModifyHttpRequest(c frpNet.Conn, rewriteHost string) (_ frpNet.Conn, err error)
- type BufferPool
- type ByLocation
- type CreateConnFunc
- type HttpMuxer
- type HttpReverseProxy
- func (rp *HttpReverseProxy) CheckAuth(domain, location, user, passwd string) bool
- func (rp *HttpReverseProxy) CreateConnection(domain string, location string) (net.Conn, error)
- func (rp *HttpReverseProxy) GetHeaders(domain string, location string) (headers map[string]string)
- func (rp *HttpReverseProxy) GetRealHost(domain string, location string) (host string)
- func (rp *HttpReverseProxy) Register(routeCfg VhostRouteConfig) error
- func (rp *HttpReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)
- func (rp *HttpReverseProxy) UnRegister(domain string, location string)
- type HttpReverseProxyOptions
- type HttpsMuxer
- type Listener
- type ReverseProxy
- type VhostMuxer
- type VhostRouteConfig
- type VhostRouter
- type VhostRouters
Constants ¶
const (
NotFound = `` /* 481-byte string literal not displayed */
)
Variables ¶
var ( ErrRouterConfigConflict = errors.New("router config conflict") ErrNoDomain = errors.New("no such domain") )
Functions ¶
func GetHttpRequestInfo ¶
func GetHttpsHostname ¶
func HttpAuthFunc ¶
func IsWebsocketRequest ¶ added in v0.15.1
Types ¶
type BufferPool ¶ added in v0.14.1
A BufferPool is an interface for getting and returning temporary byte slices for use by io.CopyBuffer.
type ByLocation ¶
type ByLocation []*VhostRouter
sort by location
func (ByLocation) Len ¶
func (a ByLocation) Len() int
func (ByLocation) Less ¶
func (a ByLocation) Less(i, j int) bool
func (ByLocation) Swap ¶
func (a ByLocation) Swap(i, j int)
type CreateConnFunc ¶ added in v0.14.1
type HttpMuxer ¶
type HttpMuxer struct {
*VhostMuxer
}
type HttpReverseProxy ¶ added in v0.14.1
type HttpReverseProxy struct {
// contains filtered or unexported fields
}
func NewHttpReverseProxy ¶ added in v0.14.1
func NewHttpReverseProxy(option HttpReverseProxyOptions) *HttpReverseProxy
func (*HttpReverseProxy) CheckAuth ¶ added in v0.14.1
func (rp *HttpReverseProxy) CheckAuth(domain, location, user, passwd string) bool
func (*HttpReverseProxy) CreateConnection ¶ added in v0.14.1
func (*HttpReverseProxy) GetHeaders ¶ added in v0.20.0
func (rp *HttpReverseProxy) GetHeaders(domain string, location string) (headers map[string]string)
func (*HttpReverseProxy) GetRealHost ¶ added in v0.14.1
func (rp *HttpReverseProxy) GetRealHost(domain string, location string) (host string)
func (*HttpReverseProxy) Register ¶ added in v0.14.1
func (rp *HttpReverseProxy) Register(routeCfg VhostRouteConfig) error
func (*HttpReverseProxy) ServeHTTP ¶ added in v0.14.1
func (rp *HttpReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)
func (*HttpReverseProxy) UnRegister ¶ added in v0.14.1
func (rp *HttpReverseProxy) UnRegister(domain string, location string)
type HttpReverseProxyOptions ¶ added in v0.21.0
type HttpReverseProxyOptions struct {
ResponseHeaderTimeoutS int64
}
type ReverseProxy ¶ added in v0.14.1
type ReverseProxy struct { // Director must be a function which modifies // the request into a new request to be sent // using Transport. Its response is then copied // back to the original client unmodified. // Director must not access the provided Request // after returning. Director func(*http.Request) // The transport used to perform proxy requests. // If nil, http.DefaultTransport is used. Transport http.RoundTripper // FlushInterval specifies the flush interval // to flush to the client while copying the // response body. // If zero, no periodic flushing is done. FlushInterval time.Duration // ErrorLog specifies an optional logger for errors // that occur when attempting to proxy the request. // If nil, logging goes to os.Stderr via the log package's // standard logger. ErrorLog *log.Logger // BufferPool optionally specifies a buffer pool to // get byte slices for use by io.CopyBuffer when // copying HTTP response bodies. BufferPool BufferPool // ModifyResponse is an optional function that // modifies the Response from the backend. // If it returns an error, the proxy returns a StatusBadGateway error. ModifyResponse func(*http.Response) error WebSocketDialContext func(ctx context.Context, network, addr string) (net.Conn, error) }
ReverseProxy is an HTTP Handler that takes an incoming request and sends it to another server, proxying the response back to the client.
func NewSingleHostReverseProxy ¶ added in v0.14.1
func NewSingleHostReverseProxy(target *url.URL) *ReverseProxy
NewSingleHostReverseProxy returns a new ReverseProxy that routes URLs to the scheme, host, and base path provided in target. If the target's path is "/base" and the incoming request was for "/dir", the target request will be for /base/dir. NewSingleHostReverseProxy does not rewrite the Host header. To rewrite Host headers, use ReverseProxy directly with a custom Director policy.
func (*ReverseProxy) ServeHTTP ¶ added in v0.14.1
func (p *ReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)
type VhostMuxer ¶
type VhostMuxer struct {
// contains filtered or unexported fields
}
func NewVhostMuxer ¶
func (*VhostMuxer) Listen ¶
func (v *VhostMuxer) Listen(cfg *VhostRouteConfig) (l *Listener, err error)
listen for a new domain name, if rewriteHost is not empty and rewriteFunc is not nil then rewrite the host header to rewriteHost
type VhostRouteConfig ¶
type VhostRouter ¶
type VhostRouter struct {
// contains filtered or unexported fields
}
type VhostRouters ¶
type VhostRouters struct { RouterByDomain map[string][]*VhostRouter // contains filtered or unexported fields }
func NewVhostRouters ¶
func NewVhostRouters() *VhostRouters
func (*VhostRouters) Add ¶
func (r *VhostRouters) Add(domain, location string, payload interface{})
func (*VhostRouters) Del ¶
func (r *VhostRouters) Del(domain, location string)
func (*VhostRouters) Exist ¶
func (r *VhostRouters) Exist(host, path string) (vr *VhostRouter, exist bool)
func (*VhostRouters) Get ¶
func (r *VhostRouters) Get(host, path string) (vr *VhostRouter, exist bool)