Documentation ¶
Index ¶
- Constants
- Variables
- func AddRequestHook(hook *RequestHook)
- func CallRequestAfterHook(req *Request, writer *ResponseWriter) (goNext bool)
- func CallRequestBeforeHook(req *Request, writer *ResponseWriter) (goNext bool)
- type ClientPool
- type Listener
- func (this *Listener) ApplyServer(server *teaconfigs.ServerConfig)
- func (this *Listener) CloseTCPClient(lAddr string) error
- func (this *Listener) HasServer(serverId string) bool
- func (this *Listener) HasServers() bool
- func (this *Listener) Reload() error
- func (this *Listener) RemoveServer(serverId string)
- func (this *Listener) Reset()
- func (this *Listener) Shutdown() error
- func (this *Listener) Start() error
- func (this *Listener) TCPClients(maxSize int) []*TCPClient
- type Manager
- func (this *Manager) ApplyServer(server *teaconfigs.ServerConfig)
- func (this *Manager) FindAllServers() []*teaconfigs.ServerConfig
- func (this *Manager) FindServer(serverId string) *teaconfigs.ServerConfig
- func (this *Manager) FindServerErrors(serverId string) []string
- func (this *Manager) FindServerListeners(serverId string) []*Listener
- func (this *Manager) Reload() error
- func (this *Manager) RemoveServer(serverId string)
- func (this *Manager) Restart() error
- func (this *Manager) Shutdown() error
- func (this *Manager) Start() error
- func (this *Manager) Wait()
- type NamedServer
- type Request
- func (this *Request) CachePolicy() *shared.CachePolicy
- func (this *Request) Format(source string) string
- func (this *Request) IsCacheEnabled() bool
- func (this *Request) IsWatching() bool
- func (this *Request) Raw() *http.Request
- func (this *Request) SetAttr(key string, value string)
- func (this *Request) SetCacheEnabled()
- func (this *Request) SetCachePolicy(config *shared.CachePolicy)
- func (this *Request) SetHost(host string)
- func (this *Request) SetIsWatching(isWatching bool)
- func (this *Request) SetRawScheme(scheme string)
- func (this *Request) SetURI(uri string)
- func (this *Request) SetVarMapping(varName string, varValue string)
- func (this *Request) WriteResponseHeaders(writer *ResponseWriter, statusCode int)
- type RequestHook
- type ResponseWriter
- func (this *ResponseWriter) AddHeaders(header http.Header)
- func (this *ResponseWriter) Body() []byte
- func (this *ResponseWriter) BodyIsCopying() bool
- func (this *ResponseWriter) Close()
- func (this *ResponseWriter) Gzip(config *teaconfigs.GzipConfig)
- func (this *ResponseWriter) Header() http.Header
- func (this *ResponseWriter) HeaderData() []byte
- func (this *ResponseWriter) Prepare(size int64)
- func (this *ResponseWriter) Raw() http.ResponseWriter
- func (this *ResponseWriter) Reset(httpResponseWriter http.ResponseWriter)
- func (this *ResponseWriter) SentBodyBytes() int64
- func (this *ResponseWriter) SetBodyCopying(b bool)
- func (this *ResponseWriter) StatusCode() int
- func (this *ResponseWriter) Write(data []byte) (n int, err error)
- func (this *ResponseWriter) WriteHeader(statusCode int)
- func (this *ResponseWriter) WriteString(s string) (n int, err error)
- type Scheme
- type StaticDelivery
- type StaticFileCache
- type TCPClient
- type Tunnel
- type TunnelConnection
- func (this *TunnelConnection) Close() error
- func (this *TunnelConnection) IsAuthenticated() bool
- func (this *TunnelConnection) OnClose(handler func(tunnelConn *TunnelConnection))
- func (this *TunnelConnection) Ping() error
- func (this *TunnelConnection) RemoteAddr() string
- func (this *TunnelConnection) Write(req *http.Request) (*http.Response, error)
- type TunnelManager
- type TunnelResponseBody
Constants ¶
View Source
const ( TCPClientMaxAttempts = 3 // 失败最多尝试次数 TCPClientStreamSize = 128 // 读取客户端数据的队列长度 )
Variables ¶
View Source
var QPS = int32(0)
对外可读取的QPS
公用的静态文件分发器
客户端池单例
共享的管理对象
Functions ¶
func CallRequestAfterHook ¶
func CallRequestAfterHook(req *Request, writer *ResponseWriter) (goNext bool)
执行After Hook
func CallRequestBeforeHook ¶
func CallRequestBeforeHook(req *Request, writer *ResponseWriter) (goNext bool)
执行Before Hook
Types ¶
type Listener ¶
type Listener struct { IsChanged bool // 标记是否改变,用来在其他地方重启改变的监听器 Scheme Scheme // http, https, tcp, tcp+tls Address string Error error // contains filtered or unexported fields }
代理服务监听器
func (*Listener) ApplyServer ¶ added in v0.1.2
func (this *Listener) ApplyServer(server *teaconfigs.ServerConfig)
应用配置
func (*Listener) CloseTCPClient ¶ added in v0.1.6
关闭某个TCP连接
func (*Listener) RemoveServer ¶ added in v0.1.2
删除配置
func (*Listener) TCPClients ¶ added in v0.1.6
获取TCP连接列表
type Manager ¶ added in v0.1.2
type Manager struct {
// contains filtered or unexported fields
}
管理器
func (*Manager) ApplyServer ¶ added in v0.1.2
func (this *Manager) ApplyServer(server *teaconfigs.ServerConfig)
添加Server
func (*Manager) FindAllServers ¶ added in v0.1.7
func (this *Manager) FindAllServers() []*teaconfigs.ServerConfig
查找所有的Server
func (*Manager) FindServer ¶ added in v0.1.2
func (this *Manager) FindServer(serverId string) *teaconfigs.ServerConfig
查找Server
func (*Manager) FindServerErrors ¶ added in v0.1.2
查找Server相关错误
func (*Manager) FindServerListeners ¶ added in v0.1.6
查找Server对应的Listener
func (*Manager) RemoveServer ¶ added in v0.1.2
删除Server
type NamedServer ¶ added in v0.1.2
type NamedServer struct { Name string // 匹配后的域名 Server *teaconfigs.ServerConfig // 匹配后的服务配置 }
域名和服务映射
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
请求定义 HTTP HEADER RFC: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
func (*Request) CachePolicy ¶
func (this *Request) CachePolicy() *shared.CachePolicy
func (*Request) SetCacheEnabled ¶
func (this *Request) SetCacheEnabled()
func (*Request) SetCachePolicy ¶
func (this *Request) SetCachePolicy(config *shared.CachePolicy)
func (*Request) SetRawScheme ¶ added in v0.1.8
设置原始的scheme
func (*Request) SetVarMapping ¶ added in v0.1.5
添加自定义变量
func (*Request) WriteResponseHeaders ¶ added in v0.1.5
func (this *Request) WriteResponseHeaders(writer *ResponseWriter, statusCode int)
输出自定义Response Header
type RequestHook ¶
type RequestHook struct { BeforeRequest func(req *Request, writer *ResponseWriter) (goNext bool) AfterRequest func(req *Request, writer *ResponseWriter) (goNext bool) }
请求Hook定义
type ResponseWriter ¶
type ResponseWriter struct {
// contains filtered or unexported fields
}
响应Writer
func NewResponseWriter ¶
func NewResponseWriter(httpResponseWriter http.ResponseWriter) *ResponseWriter
包装对象
func (*ResponseWriter) AddHeaders ¶
func (this *ResponseWriter) AddHeaders(header http.Header)
添加一组Header
func (*ResponseWriter) BodyIsCopying ¶
func (this *ResponseWriter) BodyIsCopying() bool
判断是否在拷贝Body数据
func (*ResponseWriter) Gzip ¶
func (this *ResponseWriter) Gzip(config *teaconfigs.GzipConfig)
设置Gzip
func (*ResponseWriter) Reset ¶ added in v0.1.6
func (this *ResponseWriter) Reset(httpResponseWriter http.ResponseWriter)
重置
func (*ResponseWriter) SetBodyCopying ¶
func (this *ResponseWriter) SetBodyCopying(b bool)
设置拷贝Body数据
func (*ResponseWriter) Write ¶
func (this *ResponseWriter) Write(data []byte) (n int, err error)
写入数据
func (*ResponseWriter) WriteString ¶ added in v0.1.6
func (this *ResponseWriter) WriteString(s string) (n int, err error)
写入字符串
type StaticDelivery ¶ added in v0.1.2
type StaticDelivery struct {
// contains filtered or unexported fields
}
静态文件分发器
type StaticFileCache ¶ added in v0.1.2
type StaticFileCache struct {
// contains filtered or unexported fields
}
静态文件缓存
type TCPClient ¶ added in v0.1.6
type TCPClient struct {
// contains filtered or unexported fields
}
TCP连接客户端
func NewTCPClient ¶ added in v0.1.6
func NewTCPClient(serverPool func() *teaconfigs.ServerConfig, conn net.Conn) *TCPClient
创建新的客户端对象
type Tunnel ¶ added in v0.1.5
type Tunnel struct {
// contains filtered or unexported fields
}
隧道状态管理
type TunnelConnection ¶ added in v0.1.5
type TunnelConnection struct {
// contains filtered or unexported fields
}
隧道连接
func NewTunnelConnection ¶ added in v0.1.5
func NewTunnelConnection(conn net.Conn, tunnelConfig *teaconfigs.TunnelConfig) *TunnelConnection
获取新对象
func (*TunnelConnection) IsAuthenticated ¶ added in v0.1.6
func (this *TunnelConnection) IsAuthenticated() bool
判断是否已认证
func (*TunnelConnection) OnClose ¶ added in v0.1.6
func (this *TunnelConnection) OnClose(handler func(tunnelConn *TunnelConnection))
设置关闭回调
func (*TunnelConnection) RemoteAddr ¶ added in v0.1.6
func (this *TunnelConnection) RemoteAddr() string
远程地址
type TunnelManager ¶ added in v0.1.5
type TunnelManager struct {
// contains filtered or unexported fields
}
Tunnel管理器
func (*TunnelManager) FindTunnel ¶ added in v0.1.5
func (this *TunnelManager) FindTunnel(serverId, tunnelId string) *Tunnel
查找Tunnel
func (*TunnelManager) OnAttach ¶ added in v0.1.5
func (this *TunnelManager) OnAttach(server *teaconfigs.ServerConfig)
加载
func (*TunnelManager) OnDetach ¶ added in v0.1.5
func (this *TunnelManager) OnDetach(server *teaconfigs.ServerConfig)
卸载
type TunnelResponseBody ¶ added in v0.1.5
type TunnelResponseBody struct { io.ReadCloser // contains filtered or unexported fields }
Tunnel响应包装,主要是为了覆盖Close()方法
Source Files ¶
- client.go
- init.go
- listener.go
- manager.go
- named_server.go
- request.go
- request_backend.go
- request_fastcgi.go
- request_hook.go
- request_page.go
- request_proxy.go
- request_redirect_https.go
- request_rewrite.go
- request_root.go
- request_shutdown.go
- request_tunnel.go
- request_url.go
- request_waf.go
- request_websocket.go
- response.go
- static_delivery.go
- tcp_client.go
- tunnel.go
- tunnel_connection.go
- tunnel_manager.go
- tunnel_response_body.go
Click to show internal directories.
Click to hide internal directories.