Documentation
¶
Index ¶
- Constants
- Variables
- func CleanOriginConnsTask()
- func NewClientConn(rawConn net.Conn, isHTTP bool, isTLS bool, isInAllowList bool) net.Conn
- func NewClientTLSConn(conn *tls.Conn) net.Conn
- func NewOriginConn(rawConn net.Conn) net.Conn
- func OriginConnect(origin *serverconfigs.OriginConfig, serverPort int, remoteAddr string, ...) (originConn net.Conn, originAddr string, err error)
- type APIStream
- type BaseClientConn
- func (this *BaseClientConn) Bind(serverId int64, remoteAddr string, maxConnsPerServer int, maxConnsPerIP int) bool
- func (this *BaseClientConn) Fingerprint() []byte
- func (this *BaseClientConn) IsBound() bool
- func (this *BaseClientConn) IsClosed() bool
- func (this *BaseClientConn) LastRequestBytes() int64
- func (this *BaseClientConn) RawIP() string
- func (this *BaseClientConn) ServerId() int64
- func (this *BaseClientConn) SetFingerprint(fingerprint []byte)
- func (this *BaseClientConn) SetIsPersistent(isPersistent bool)
- func (this *BaseClientConn) SetLinger(seconds int) error
- func (this *BaseClientConn) SetServerId(serverId int64) (goNext bool)
- func (this *BaseClientConn) SetUserId(userId int64)
- func (this *BaseClientConn) SetUserPlanId(userPlanId int64)
- func (this *BaseClientConn) TCPConn() (tcpConn *net.TCPConn, ok bool)
- func (this *BaseClientConn) UserId() int64
- func (this *BaseClientConn) UserPlanId() int64
- type BaseListener
- type ClientConn
- func (this *ClientConn) Close() error
- func (this *ClientConn) CreatedAt() int64
- func (this *ClientConn) LastErr() error
- func (this *ClientConn) LastReadAt() int64
- func (this *ClientConn) LastWriteAt() int64
- func (this *ClientConn) LocalAddr() net.Addr
- func (this *ClientConn) Read(b []byte) (n int, err error)
- func (this *ClientConn) RemoteAddr() net.Addr
- func (this *ClientConn) SetDeadline(t time.Time) error
- func (this *ClientConn) SetReadDeadline(t time.Time) error
- func (this *ClientConn) SetWriteDeadline(t time.Time) error
- func (this *ClientConn) Write(b []byte) (n int, err error)
- type ClientConnInterface
- type ClientConnLimiter
- type ClientConnRemoteAddr
- type ClientListener
- type ClientTLSConn
- func (this *ClientTLSConn) Close() error
- func (this *ClientTLSConn) Fingerprint() []byte
- func (this *ClientTLSConn) LastRequestBytes() int64
- func (this *ClientTLSConn) LocalAddr() net.Addr
- func (this *ClientTLSConn) Read(b []byte) (n int, err error)
- func (this *ClientTLSConn) RemoteAddr() net.Addr
- func (this *ClientTLSConn) SetDeadline(t time.Time) error
- func (this *ClientTLSConn) SetIsPersistent(isPersistent bool)
- func (this *ClientTLSConn) SetReadDeadline(t time.Time) error
- func (this *ClientTLSConn) SetWriteDeadline(t time.Time) error
- func (this *ClientTLSConn) Write(b []byte) (n int, err error)
- type EmptyResponseWriter
- func (this *EmptyResponseWriter) Header() http.Header
- func (this *EmptyResponseWriter) Hijack() (conn net.Conn, buf *bufio.ReadWriter, err error)
- func (this *EmptyResponseWriter) StatusCode() int
- func (this *EmptyResponseWriter) Write(data []byte) (int, error)
- func (this *EmptyResponseWriter) WriteHeader(statusCode int)
- type HTTPAccessLogQueue
- type HTTPAccessLogViewer
- type HTTPCacheTaskManager
- type HTTPClient
- type HTTPClientPool
- type HTTPClientTransport
- type HTTPListener
- type HTTPRequest
- func (this *HTTPRequest) Allow()
- func (this *HTTPRequest) CalculateSize() (size int64)
- func (this *HTTPRequest) Close()
- func (this *HTTPRequest) ContentLength() int64
- func (this *HTTPRequest) Cookie(name string) string
- func (this *HTTPRequest) DeleteHeader(name string)
- func (this *HTTPRequest) DisableAccessLog()
- func (this *HTTPRequest) Do()
- func (this *HTTPRequest) Done()
- func (this *HTTPRequest) Format(source string) string
- func (this *HTTPRequest) Header() http.Header
- func (this *HTTPRequest) Host() string
- func (this *HTTPRequest) Id() string
- func (this *HTTPRequest) Method() string
- func (this *HTTPRequest) MetricCategory() string
- func (this *HTTPRequest) MetricKey(key string) string
- func (this *HTTPRequest) MetricServerId() int64
- func (this *HTTPRequest) MetricValue(value string) (result int64, ok bool)
- func (this *HTTPRequest) Node() maps.Map
- func (this *HTTPRequest) Path() string
- func (this *HTTPRequest) ProcessResponseHeaders(responseHeader http.Header, statusCode int)
- func (this *HTTPRequest) Proto() string
- func (this *HTTPRequest) ProtoMajor() int
- func (this *HTTPRequest) ProtoMinor() int
- func (this *HTTPRequest) RawRemoteAddr() string
- func (this *HTTPRequest) RawURI() string
- func (this *HTTPRequest) RemoteAddr() string
- func (this *HTTPRequest) RemotePort() int
- func (this *HTTPRequest) Server() maps.Map
- func (this *HTTPRequest) SetAttr(name string, value string)
- func (this *HTTPRequest) SetHeader(name string, values []string)
- func (this *HTTPRequest) SetURI(uri string)
- func (this *HTTPRequest) SetVar(name string, value string)
- func (this *HTTPRequest) TransferEncoding() string
- func (this *HTTPRequest) URI() string
- func (this *HTTPRequest) URL() string
- func (this *HTTPRequest) WAFClose()
- func (this *HTTPRequest) WAFFingerprint() []byte
- func (this *HTTPRequest) WAFGetCacheBody() []byte
- func (this *HTTPRequest) WAFMaxRequestSize() int64
- func (this *HTTPRequest) WAFOnAction(action interface{}) (goNext bool)
- func (this *HTTPRequest) WAFRaw() *http.Request
- func (this *HTTPRequest) WAFReadBody(max int64) (data []byte, err error)
- func (this *HTTPRequest) WAFRemoteIP() string
- func (this *HTTPRequest) WAFRestoreBody(data []byte)
- func (this *HTTPRequest) WAFServerId() int64
- func (this *HTTPRequest) WAFSetCacheBody(body []byte)
- type HTTPWriter
- func (this *HTTPWriter) AddHeaders(header http.Header)
- func (this *HTTPWriter) Close()
- func (this *HTTPWriter) DelayRead() bool
- func (this *HTTPWriter) DeleteHeader(name string)
- func (this *HTTPWriter) Flush()
- func (this *HTTPWriter) GetHeader(name string) string
- func (this *HTTPWriter) Header() http.Header
- func (this *HTTPWriter) HeaderData() []byte
- func (this *HTTPWriter) Hijack() (conn net.Conn, buf *bufio.ReadWriter, err error)
- func (this *HTTPWriter) Prepare(resp *http.Response, size int64, status int, enableCache bool) (delayHeaders bool)
- func (this *HTTPWriter) PrepareCache(resp *http.Response, size int64)
- func (this *HTTPWriter) PrepareCompression(resp *http.Response, size int64)
- func (this *HTTPWriter) PrepareWebP(resp *http.Response, size int64)
- func (this *HTTPWriter) Raw() http.ResponseWriter
- func (this *HTTPWriter) Redirect(status int, url string)
- func (this *HTTPWriter) Send(status int, body string)
- func (this *HTTPWriter) SendFile(status int, path string) (int64, error)
- func (this *HTTPWriter) SendResp(resp *http.Response) (int64, error)
- func (this *HTTPWriter) SentBodyBytes() int64
- func (this *HTTPWriter) SentHeaderBytes() int64
- func (this *HTTPWriter) SetCompression(config *serverconfigs.HTTPCompressionConfig)
- func (this *HTTPWriter) SetHeader(name string, values []string)
- func (this *HTTPWriter) SetOk()
- func (this *HTTPWriter) SetSentHeaderBytes(sentHeaderBytes int64)
- func (this *HTTPWriter) StatusCode() int
- func (this *HTTPWriter) Write(data []byte) (n int, err error)
- func (this *HTTPWriter) WriteHeader(statusCode int)
- func (this *HTTPWriter) WriteString(s string) (n int, err error)
- type IPLibraryUpdater
- func (this *IPLibraryUpdater) DataDir() string
- func (this *IPLibraryUpdater) DownloadFile(fileId int64, writer io.Writer) error
- func (this *IPLibraryUpdater) FindLatestFile() (code string, fileId int64, err error)
- func (this *IPLibraryUpdater) LogError(err error)
- func (this *IPLibraryUpdater) LogInfo(message string)
- type LingerConn
- type Listener
- type ListenerInterface
- type ListenerManager
- type Node
- type NodeStatusExecutor
- type OCSPUpdateTask
- type OriginConn
- type OriginState
- type OriginStateManager
- func (this *OriginStateManager) Fail(origin *serverconfigs.OriginConfig, tlsHost string, ...)
- func (this *OriginStateManager) IsAvailable(originId int64) bool
- func (this *OriginStateManager) Loop() error
- func (this *OriginStateManager) Start()
- func (this *OriginStateManager) Stop()
- func (this *OriginStateManager) Success(origin *serverconfigs.OriginConfig, callback func())
- type SyncAPINodesTask
- type SystemServiceManager
- type TCPListener
- type TOAManager
- type UDPConn
- type UDPIPv4Listener
- type UDPIPv6Listener
- type UDPListener
- type UDPPacketListener
- type UnixListener
- type UpgradeManager
- type User
- type UserManager
- type WebsocketResponseReader
Constants ¶
const (
// AccessLogMaxRequestBodySize 访问日志存储的请求内容最大尺寸 TODO 此值应该可以在访问日志页设置
AccessLogMaxRequestBodySize = 2 * 1024 * 1024
)
const HTTPIdleTimeout = 75 * time.Second
const (
LNExpiresHeader = "X-Edge-Ln-Expires"
)
const (
UDPConnLifeSeconds = 30
)
Variables ¶
var DaemonIsOn = false
var DaemonPid = 0
var HOSTNAME, _ = os.Hostname()
环境变量
var HTTPConnContextKey = &contextKey{key: "http-conn"}
SharedHTTPClientPool HTTP客户端池单例
Functions ¶
func CleanOriginConnsTask ¶ added in v1.2.7
func CleanOriginConnsTask()
func NewClientConn ¶
func NewOriginConn ¶ added in v1.2.7
NewOriginConn create new origin connection
func OriginConnect ¶
func OriginConnect(origin *serverconfigs.OriginConfig, serverPort int, remoteAddr string, tlsHost string) (originConn net.Conn, originAddr string, err error)
OriginConnect 连接源站
Types ¶
type APIStream ¶
type APIStream struct {
// contains filtered or unexported fields
}
func NewAPIStream ¶
func NewAPIStream() *APIStream
type BaseClientConn ¶
type BaseClientConn struct {
// contains filtered or unexported fields
}
func (*BaseClientConn) Bind ¶
func (this *BaseClientConn) Bind(serverId int64, remoteAddr string, maxConnsPerServer int, maxConnsPerIP int) bool
Bind 绑定服务
func (*BaseClientConn) Fingerprint ¶ added in v0.6.4
func (this *BaseClientConn) Fingerprint() []byte
Fingerprint 读取指纹信息
func (*BaseClientConn) IsClosed ¶
func (this *BaseClientConn) IsClosed() bool
func (*BaseClientConn) LastRequestBytes ¶ added in v1.2.7
func (this *BaseClientConn) LastRequestBytes() int64
LastRequestBytes 读取上一次请求发送的字节数
func (*BaseClientConn) ServerId ¶ added in v0.4.9
func (this *BaseClientConn) ServerId() int64
ServerId 读取当前连接绑定的服务ID
func (*BaseClientConn) SetFingerprint ¶ added in v0.6.4
func (this *BaseClientConn) SetFingerprint(fingerprint []byte)
SetFingerprint 设置指纹信息
func (*BaseClientConn) SetIsPersistent ¶ added in v0.6.4
func (this *BaseClientConn) SetIsPersistent(isPersistent bool)
func (*BaseClientConn) SetLinger ¶
func (this *BaseClientConn) SetLinger(seconds int) error
SetLinger 设置Linger
func (*BaseClientConn) SetServerId ¶ added in v0.4.9
func (this *BaseClientConn) SetServerId(serverId int64) (goNext bool)
SetServerId 设置服务ID
func (*BaseClientConn) SetUserId ¶ added in v0.4.9
func (this *BaseClientConn) SetUserId(userId int64)
SetUserId 设置所属服务的用户ID
func (*BaseClientConn) SetUserPlanId ¶ added in v1.2.9
func (this *BaseClientConn) SetUserPlanId(userPlanId int64)
func (*BaseClientConn) TCPConn ¶
func (this *BaseClientConn) TCPConn() (tcpConn *net.TCPConn, ok bool)
TCPConn 转换为TCPConn
func (*BaseClientConn) UserId ¶ added in v0.4.9
func (this *BaseClientConn) UserId() int64
UserId 获取当前连接所属服务的用户ID
func (*BaseClientConn) UserPlanId ¶ added in v1.2.9
func (this *BaseClientConn) UserPlanId() int64
UserPlanId 用户套餐ID
type BaseListener ¶
type BaseListener struct { Group *serverconfigs.ServerAddressGroup // contains filtered or unexported fields }
func (*BaseListener) CountActiveConnections ¶
func (this *BaseListener) CountActiveConnections() int
CountActiveConnections 获取当前活跃连接数
type ClientConn ¶
type ClientConn struct { BaseClientConn // contains filtered or unexported fields }
ClientConn 客户端连接
func (*ClientConn) Close ¶
func (this *ClientConn) Close() error
func (*ClientConn) CreatedAt ¶ added in v0.6.0
func (this *ClientConn) CreatedAt() int64
func (*ClientConn) LastErr ¶ added in v0.6.0
func (this *ClientConn) LastErr() error
func (*ClientConn) LastReadAt ¶ added in v0.6.0
func (this *ClientConn) LastReadAt() int64
func (*ClientConn) LastWriteAt ¶ added in v0.6.0
func (this *ClientConn) LastWriteAt() int64
func (*ClientConn) LocalAddr ¶
func (this *ClientConn) LocalAddr() net.Addr
func (*ClientConn) RemoteAddr ¶
func (this *ClientConn) RemoteAddr() net.Addr
func (*ClientConn) SetDeadline ¶
func (this *ClientConn) SetDeadline(t time.Time) error
func (*ClientConn) SetReadDeadline ¶
func (this *ClientConn) SetReadDeadline(t time.Time) error
func (*ClientConn) SetWriteDeadline ¶
func (this *ClientConn) SetWriteDeadline(t time.Time) error
type ClientConnInterface ¶
type ClientConnInterface interface { // IsClosed 是否已关闭 IsClosed() bool // IsBound 是否已绑定服务 IsBound() bool // Bind 绑定服务 Bind(serverId int64, remoteAddr string, maxConnsPerServer int, maxConnsPerIP int) bool // ServerId 获取服务ID ServerId() int64 // SetServerId 设置服务ID SetServerId(serverId int64) (goNext bool) // SetUserId 设置所属网站的用户ID SetUserId(userId int64) // SetUserPlanId 设置 SetUserPlanId(userPlanId int64) // UserId 获取当前连接所属服务的用户ID UserId() int64 // SetIsPersistent 设置是否为持久化 SetIsPersistent(isPersistent bool) // SetFingerprint 设置指纹信息 SetFingerprint(fingerprint []byte) // Fingerprint 读取指纹信息 Fingerprint() []byte // LastRequestBytes 读取上一次请求发送的字节数 LastRequestBytes() int64 }
type ClientConnLimiter ¶
type ClientConnLimiter struct {
// contains filtered or unexported fields
}
ClientConnLimiter 客户端连接数限制
func NewClientConnLimiter ¶
func NewClientConnLimiter() *ClientConnLimiter
func (*ClientConnLimiter) Add ¶
func (this *ClientConnLimiter) Add(rawRemoteAddr string, serverId int64, remoteAddr string, maxConnsPerServer int, maxConnsPerIP int) bool
Add 添加新连接 返回值为true的时候表示允许添加;否则表示不允许添加
func (*ClientConnLimiter) Conns ¶
func (this *ClientConnLimiter) Conns() (ipConns map[string][]string, serverConns map[int64][]string)
Conns 获取连接信息 用于调试
func (*ClientConnLimiter) Remove ¶
func (this *ClientConnLimiter) Remove(rawRemoteAddr string)
Remove 删除连接
type ClientConnRemoteAddr ¶
type ClientConnRemoteAddr struct {
// contains filtered or unexported fields
}
ClientConnRemoteAddr 客户端地址定义
type ClientListener ¶
type ClientListener struct {
// contains filtered or unexported fields
}
ClientListener 客户端网络监听
func NewClientListener ¶
func NewClientListener(listener net.Listener, isHTTP bool) *ClientListener
func (*ClientListener) Addr ¶
func (this *ClientListener) Addr() net.Addr
func (*ClientListener) Close ¶
func (this *ClientListener) Close() error
func (*ClientListener) IsTLS ¶
func (this *ClientListener) IsTLS() bool
func (*ClientListener) SetIsTLS ¶
func (this *ClientListener) SetIsTLS(isTLS bool)
type ClientTLSConn ¶
type ClientTLSConn struct {
BaseClientConn
}
ClientTLSConn TLS连接封装
func (*ClientTLSConn) Close ¶
func (this *ClientTLSConn) Close() error
func (*ClientTLSConn) Fingerprint ¶ added in v0.6.4
func (this *ClientTLSConn) Fingerprint() []byte
func (*ClientTLSConn) LastRequestBytes ¶ added in v1.2.7
func (this *ClientTLSConn) LastRequestBytes() int64
LastRequestBytes 读取上一次请求发送的字节数
func (*ClientTLSConn) LocalAddr ¶
func (this *ClientTLSConn) LocalAddr() net.Addr
func (*ClientTLSConn) RemoteAddr ¶
func (this *ClientTLSConn) RemoteAddr() net.Addr
func (*ClientTLSConn) SetDeadline ¶
func (this *ClientTLSConn) SetDeadline(t time.Time) error
func (*ClientTLSConn) SetIsPersistent ¶ added in v0.6.4
func (this *ClientTLSConn) SetIsPersistent(isPersistent bool)
func (*ClientTLSConn) SetReadDeadline ¶
func (this *ClientTLSConn) SetReadDeadline(t time.Time) error
func (*ClientTLSConn) SetWriteDeadline ¶
func (this *ClientTLSConn) SetWriteDeadline(t time.Time) error
type EmptyResponseWriter ¶
type EmptyResponseWriter struct {
// contains filtered or unexported fields
}
EmptyResponseWriter 空的响应Writer
func NewEmptyResponseWriter ¶
func NewEmptyResponseWriter(parentWriter http.ResponseWriter) *EmptyResponseWriter
func (*EmptyResponseWriter) Header ¶
func (this *EmptyResponseWriter) Header() http.Header
func (*EmptyResponseWriter) Hijack ¶
func (this *EmptyResponseWriter) Hijack() (conn net.Conn, buf *bufio.ReadWriter, err error)
Hijack Hijack
func (*EmptyResponseWriter) StatusCode ¶
func (this *EmptyResponseWriter) StatusCode() int
func (*EmptyResponseWriter) Write ¶
func (this *EmptyResponseWriter) Write(data []byte) (int, error)
func (*EmptyResponseWriter) WriteHeader ¶
func (this *EmptyResponseWriter) WriteHeader(statusCode int)
type HTTPAccessLogQueue ¶
type HTTPAccessLogQueue struct {
// contains filtered or unexported fields
}
HTTPAccessLogQueue HTTP访问日志队列
func NewHTTPAccessLogQueue ¶
func NewHTTPAccessLogQueue() *HTTPAccessLogQueue
NewHTTPAccessLogQueue 获取新对象
func (*HTTPAccessLogQueue) Push ¶
func (this *HTTPAccessLogQueue) Push(accessLog *pb.HTTPAccessLog)
Push 加入新访问日志
func (*HTTPAccessLogQueue) ToValidUTF8 ¶
func (this *HTTPAccessLogQueue) ToValidUTF8(accessLog *pb.HTTPAccessLog)
ToValidUTF8 处理访问日志中的非UTF-8字节
type HTTPAccessLogViewer ¶
type HTTPAccessLogViewer struct {
// contains filtered or unexported fields
}
HTTPAccessLogViewer 本地访问日志浏览器
func NewHTTPAccessLogViewer ¶
func NewHTTPAccessLogViewer() *HTTPAccessLogViewer
NewHTTPAccessLogViewer 获取新对象
func (*HTTPAccessLogViewer) HasConns ¶
func (this *HTTPAccessLogViewer) HasConns() bool
HasConns 检查是否有连接
func (*HTTPAccessLogViewer) Send ¶
func (this *HTTPAccessLogViewer) Send(accessLog *pb.HTTPAccessLog)
Send 发送日志
type HTTPCacheTaskManager ¶
type HTTPCacheTaskManager struct {
// contains filtered or unexported fields
}
HTTPCacheTaskManager 缓存任务管理
func NewHTTPCacheTaskManager ¶
func NewHTTPCacheTaskManager() *HTTPCacheTaskManager
func (*HTTPCacheTaskManager) Loop ¶
func (this *HTTPCacheTaskManager) Loop() error
func (*HTTPCacheTaskManager) PushTaskKeys ¶
func (this *HTTPCacheTaskManager) PushTaskKeys(keys []string)
func (*HTTPCacheTaskManager) Start ¶
func (this *HTTPCacheTaskManager) Start()
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient HTTP客户端
func (*HTTPClient) UpdateAccessTime ¶
func (this *HTTPClient) UpdateAccessTime()
UpdateAccessTime 更新访问时间
type HTTPClientPool ¶
type HTTPClientPool struct {
// contains filtered or unexported fields
}
HTTPClientPool 客户端池
func (*HTTPClientPool) Client ¶
func (this *HTTPClientPool) Client(req *HTTPRequest, origin *serverconfigs.OriginConfig, originAddr string, proxyProtocol *serverconfigs.ProxyProtocolConfig, followRedirects bool) (rawClient *http.Client, err error)
Client 根据地址获取客户端
type HTTPClientTransport ¶
type HTTPListener ¶
type HTTPListener struct { BaseListener Listener net.Listener // contains filtered or unexported fields }
func (*HTTPListener) Close ¶
func (this *HTTPListener) Close() error
func (*HTTPListener) Reload ¶
func (this *HTTPListener) Reload(group *serverconfigs.ServerAddressGroup)
func (*HTTPListener) Serve ¶
func (this *HTTPListener) Serve() error
func (*HTTPListener) ServeHTTP ¶
func (this *HTTPListener) ServeHTTP(rawWriter http.ResponseWriter, rawReq *http.Request)
ServerHTTP 处理HTTP请求
type HTTPRequest ¶
type HTTPRequest struct { // 外部参数 RawReq *http.Request RawWriter http.ResponseWriter ReqServer *serverconfigs.ServerConfig ReqHost string // 请求的Host ServerName string // 实际匹配到的Host ServerAddr string // 实际启动的服务器监听地址 IsHTTP bool IsHTTPS bool IsHTTP3 bool // contains filtered or unexported fields }
HTTPRequest HTTP请求
func (*HTTPRequest) CalculateSize ¶
func (this *HTTPRequest) CalculateSize() (size int64)
CalculateSize 计算当前请求的尺寸(预估)
func (*HTTPRequest) ContentLength ¶
func (this *HTTPRequest) ContentLength() int64
ContentLength 请求内容长度
func (*HTTPRequest) DeleteHeader ¶
func (this *HTTPRequest) DeleteHeader(name string)
DeleteHeader 删除请求Header
func (*HTTPRequest) DisableAccessLog ¶ added in v1.0.0
func (this *HTTPRequest) DisableAccessLog()
DisableAccessLog 在当前请求中不使用访问日志
func (*HTTPRequest) Format ¶
func (this *HTTPRequest) Format(source string) string
Format 利用请求参数格式化字符串
func (*HTTPRequest) Id ¶
func (this *HTTPRequest) Id() string
func (*HTTPRequest) MetricCategory ¶
func (this *HTTPRequest) MetricCategory() string
func (*HTTPRequest) MetricKey ¶
func (this *HTTPRequest) MetricKey(key string) string
func (*HTTPRequest) MetricServerId ¶
func (this *HTTPRequest) MetricServerId() int64
func (*HTTPRequest) MetricValue ¶
func (this *HTTPRequest) MetricValue(value string) (result int64, ok bool)
func (*HTTPRequest) Node ¶
func (this *HTTPRequest) Node() maps.Map
func (*HTTPRequest) ProcessResponseHeaders ¶ added in v1.2.0
func (this *HTTPRequest) ProcessResponseHeaders(responseHeader http.Header, statusCode int)
ProcessResponseHeaders 处理自定义Response Header
func (*HTTPRequest) Proto ¶
func (this *HTTPRequest) Proto() string
func (*HTTPRequest) ProtoMajor ¶
func (this *HTTPRequest) ProtoMajor() int
func (*HTTPRequest) ProtoMinor ¶
func (this *HTTPRequest) ProtoMinor() int
func (*HTTPRequest) RawRemoteAddr ¶
func (this *HTTPRequest) RawRemoteAddr() string
func (*HTTPRequest) RemoteAddr ¶
func (this *HTTPRequest) RemoteAddr() string
func (*HTTPRequest) RemotePort ¶
func (this *HTTPRequest) RemotePort() int
func (*HTTPRequest) Server ¶
func (this *HTTPRequest) Server() maps.Map
func (*HTTPRequest) SetAttr ¶
func (this *HTTPRequest) SetAttr(name string, value string)
func (*HTTPRequest) SetHeader ¶
func (this *HTTPRequest) SetHeader(name string, values []string)
SetHeader 设置请求Header
func (*HTTPRequest) SetVar ¶
func (this *HTTPRequest) SetVar(name string, value string)
func (*HTTPRequest) TransferEncoding ¶
func (this *HTTPRequest) TransferEncoding() string
TransferEncoding 获取传输编码
func (*HTTPRequest) WAFFingerprint ¶ added in v0.6.4
func (this *HTTPRequest) WAFFingerprint() []byte
func (*HTTPRequest) WAFGetCacheBody ¶
func (this *HTTPRequest) WAFGetCacheBody() []byte
WAFGetCacheBody 获取缓存中的Body
func (*HTTPRequest) WAFMaxRequestSize ¶ added in v1.2.7
func (this *HTTPRequest) WAFMaxRequestSize() int64
func (*HTTPRequest) WAFOnAction ¶
func (this *HTTPRequest) WAFOnAction(action interface{}) (goNext bool)
func (*HTTPRequest) WAFReadBody ¶
func (this *HTTPRequest) WAFReadBody(max int64) (data []byte, err error)
WAFReadBody 读取Body
func (*HTTPRequest) WAFRestoreBody ¶
func (this *HTTPRequest) WAFRestoreBody(data []byte)
WAFRestoreBody 恢复Body
func (*HTTPRequest) WAFSetCacheBody ¶
func (this *HTTPRequest) WAFSetCacheBody(body []byte)
WAFSetCacheBody 设置Body
type HTTPWriter ¶
type HTTPWriter struct {
// contains filtered or unexported fields
}
HTTPWriter 响应Writer
func NewHTTPWriter ¶
func NewHTTPWriter(req *HTTPRequest, httpResponseWriter http.ResponseWriter) *HTTPWriter
NewHTTPWriter 包装对象
func (*HTTPWriter) AddHeaders ¶
func (this *HTTPWriter) AddHeaders(header http.Header)
AddHeaders 添加一组Header
func (*HTTPWriter) DeleteHeader ¶
func (this *HTTPWriter) DeleteHeader(name string)
DeleteHeader 删除Header
func (*HTTPWriter) GetHeader ¶
func (this *HTTPWriter) GetHeader(name string) string
GetHeader 读取Header值
func (*HTTPWriter) HeaderData ¶
func (this *HTTPWriter) HeaderData() []byte
HeaderData 读取Header二进制数据
func (*HTTPWriter) Hijack ¶
func (this *HTTPWriter) Hijack() (conn net.Conn, buf *bufio.ReadWriter, err error)
Hijack Hijack
func (*HTTPWriter) Prepare ¶
func (this *HTTPWriter) Prepare(resp *http.Response, size int64, status int, enableCache bool) (delayHeaders bool)
Prepare 准备输出
func (*HTTPWriter) PrepareCache ¶
func (this *HTTPWriter) PrepareCache(resp *http.Response, size int64)
PrepareCache 准备缓存
func (*HTTPWriter) PrepareCompression ¶
func (this *HTTPWriter) PrepareCompression(resp *http.Response, size int64)
PrepareCompression 准备压缩
func (*HTTPWriter) PrepareWebP ¶
func (this *HTTPWriter) PrepareWebP(resp *http.Response, size int64)
PrepareWebP 准备WebP
func (*HTTPWriter) SendFile ¶
func (this *HTTPWriter) SendFile(status int, path string) (int64, error)
SendFile 发送文件内容,并终止请求
func (*HTTPWriter) SendResp ¶
func (this *HTTPWriter) SendResp(resp *http.Response) (int64, error)
SendResp 发送响应对象
func (*HTTPWriter) SentBodyBytes ¶
func (this *HTTPWriter) SentBodyBytes() int64
SentBodyBytes 读取发送的字节数
func (*HTTPWriter) SentHeaderBytes ¶
func (this *HTTPWriter) SentHeaderBytes() int64
SentHeaderBytes 计算发送的Header字节数
func (*HTTPWriter) SetCompression ¶
func (this *HTTPWriter) SetCompression(config *serverconfigs.HTTPCompressionConfig)
SetCompression 设置内容压缩配置
func (*HTTPWriter) SetHeader ¶
func (this *HTTPWriter) SetHeader(name string, values []string)
SetHeader 设置Header
func (*HTTPWriter) SetSentHeaderBytes ¶
func (this *HTTPWriter) SetSentHeaderBytes(sentHeaderBytes int64)
func (*HTTPWriter) WriteHeader ¶
func (this *HTTPWriter) WriteHeader(statusCode int)
WriteHeader 写入状态码
func (*HTTPWriter) WriteString ¶
func (this *HTTPWriter) WriteString(s string) (n int, err error)
WriteString 写入字符串
type IPLibraryUpdater ¶ added in v0.5.2
type IPLibraryUpdater struct { }
func NewIPLibraryUpdater ¶ added in v0.5.2
func NewIPLibraryUpdater() *IPLibraryUpdater
func (*IPLibraryUpdater) DataDir ¶ added in v0.5.2
func (this *IPLibraryUpdater) DataDir() string
DataDir 文件目录
func (*IPLibraryUpdater) DownloadFile ¶ added in v0.5.2
func (this *IPLibraryUpdater) DownloadFile(fileId int64, writer io.Writer) error
DownloadFile 下载文件
func (*IPLibraryUpdater) FindLatestFile ¶ added in v0.5.2
func (this *IPLibraryUpdater) FindLatestFile() (code string, fileId int64, err error)
FindLatestFile 检查最新的IP库文件
func (*IPLibraryUpdater) LogError ¶ added in v0.5.2
func (this *IPLibraryUpdater) LogError(err error)
LogError 错误日志
func (*IPLibraryUpdater) LogInfo ¶ added in v0.5.2
func (this *IPLibraryUpdater) LogInfo(message string)
LogInfo 普通日志
type LingerConn ¶
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
func NewListener ¶
func NewListener() *Listener
func (*Listener) Reload ¶
func (this *Listener) Reload(group *serverconfigs.ServerAddressGroup)
type ListenerInterface ¶
type ListenerInterface interface { // Init 初始化 Init() // Serve 监听 Serve() error // Close 关闭 Close() error // Reload 重载配置 Reload(serverGroup *serverconfigs.ServerAddressGroup) // CountActiveConnections 获取当前活跃的连接数 CountActiveConnections() int }
ListenerInterface 各协议监听器的接口
type ListenerManager ¶
type ListenerManager struct {
// contains filtered or unexported fields
}
ListenerManager 端口监听管理器
func (*ListenerManager) Start ¶
func (this *ListenerManager) Start(nodeConfig *nodeconfigs.NodeConfig) error
Start 启动监听
func (*ListenerManager) TotalActiveConnections ¶
func (this *ListenerManager) TotalActiveConnections() int
TotalActiveConnections 获取总的活跃连接数
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node 节点
func (*Node) InstallSystemService ¶
InstallSystemService 安装系统服务
type NodeStatusExecutor ¶
type NodeStatusExecutor struct {
// contains filtered or unexported fields
}
func NewNodeStatusExecutor ¶
func NewNodeStatusExecutor() *NodeStatusExecutor
func (*NodeStatusExecutor) Listen ¶
func (this *NodeStatusExecutor) Listen()
type OCSPUpdateTask ¶
type OCSPUpdateTask struct {
// contains filtered or unexported fields
}
OCSPUpdateTask 更新OCSP任务
func NewOCSPUpdateTask ¶
func NewOCSPUpdateTask() *OCSPUpdateTask
func (*OCSPUpdateTask) Loop ¶
func (this *OCSPUpdateTask) Loop() error
func (*OCSPUpdateTask) Start ¶
func (this *OCSPUpdateTask) Start()
func (*OCSPUpdateTask) Stop ¶
func (this *OCSPUpdateTask) Stop()
type OriginConn ¶ added in v1.2.7
OriginConn connection with origin site
func (*OriginConn) Close ¶ added in v1.2.7
func (this *OriginConn) Close() error
Close implement Close() for net.Conn interface
func (*OriginConn) ForceClose ¶ added in v1.2.7
func (this *OriginConn) ForceClose() error
func (*OriginConn) IsExpired ¶ added in v1.2.7
func (this *OriginConn) IsExpired() bool
type OriginState ¶
type OriginState struct { CountFails int64 UpdatedAt int64 Config *serverconfigs.OriginConfig Addr string TLSHost string ReverseProxy *serverconfigs.ReverseProxyConfig }
type OriginStateManager ¶
type OriginStateManager struct {
// contains filtered or unexported fields
}
OriginStateManager 源站状态管理
func NewOriginStateManager ¶
func NewOriginStateManager() *OriginStateManager
NewOriginStateManager 获取新管理对象
func (*OriginStateManager) Fail ¶
func (this *OriginStateManager) Fail(origin *serverconfigs.OriginConfig, tlsHost string, reverseProxy *serverconfigs.ReverseProxyConfig, callback func())
Fail 添加失败的源站
func (*OriginStateManager) IsAvailable ¶
func (this *OriginStateManager) IsAvailable(originId int64) bool
IsAvailable 检查是否正常
func (*OriginStateManager) Stop ¶
func (this *OriginStateManager) Stop()
func (*OriginStateManager) Success ¶
func (this *OriginStateManager) Success(origin *serverconfigs.OriginConfig, callback func())
Success 添加成功的源站
type SyncAPINodesTask ¶
type SyncAPINodesTask struct {
// contains filtered or unexported fields
}
SyncAPINodesTask API节点同步任务
func NewSyncAPINodesTask ¶
func NewSyncAPINodesTask() *SyncAPINodesTask
func (*SyncAPINodesTask) Loop ¶
func (this *SyncAPINodesTask) Loop() error
func (*SyncAPINodesTask) Start ¶
func (this *SyncAPINodesTask) Start()
func (*SyncAPINodesTask) Stop ¶
func (this *SyncAPINodesTask) Stop()
type SystemServiceManager ¶
type SystemServiceManager struct {
// contains filtered or unexported fields
}
SystemServiceManager 系统服务管理
func NewSystemServiceManager ¶
func NewSystemServiceManager() *SystemServiceManager
func (*SystemServiceManager) Setup ¶
func (this *SystemServiceManager) Setup() error
type TCPListener ¶
type TCPListener struct { BaseListener Listener net.Listener // contains filtered or unexported fields }
func (*TCPListener) Close ¶
func (this *TCPListener) Close() error
func (*TCPListener) Reload ¶
func (this *TCPListener) Reload(group *serverconfigs.ServerAddressGroup)
func (*TCPListener) Serve ¶
func (this *TCPListener) Serve() error
type TOAManager ¶
type TOAManager struct { }
func NewTOAManager ¶
func NewTOAManager() *TOAManager
func (*TOAManager) Apply ¶ added in v1.2.3
func (this *TOAManager) Apply(config *nodeconfigs.TOAConfig) error
func (*TOAManager) Config ¶
func (this *TOAManager) Config() *nodeconfigs.TOAConfig
func (*TOAManager) Quit ¶
func (this *TOAManager) Quit() error
func (*TOAManager) SendMsg ¶
func (this *TOAManager) SendMsg(msg string) error
type UDPConn ¶
type UDPConn struct {
// contains filtered or unexported fields
}
UDPConn 自定义的UDP连接管理
func NewUDPConn ¶
func NewUDPConn(server *serverconfigs.ServerConfig, addr net.Addr, proxyListener UDPPacketListener, cm any, serverConn *net.UDPConn) *UDPConn
type UDPIPv4Listener ¶ added in v0.5.3
type UDPIPv4Listener struct {
// contains filtered or unexported fields
}
func NewUDPIPv4Listener ¶ added in v0.5.3
func NewUDPIPv4Listener(rawListener *ipv4.PacketConn) *UDPIPv4Listener
func (*UDPIPv4Listener) LocalAddr ¶ added in v0.5.3
func (this *UDPIPv4Listener) LocalAddr() net.Addr
type UDPIPv6Listener ¶ added in v0.5.3
type UDPIPv6Listener struct {
// contains filtered or unexported fields
}
func NewUDPIPv6Listener ¶ added in v0.5.3
func NewUDPIPv6Listener(rawListener *ipv6.PacketConn) *UDPIPv6Listener
func (*UDPIPv6Listener) LocalAddr ¶ added in v0.5.3
func (this *UDPIPv6Listener) LocalAddr() net.Addr
type UDPListener ¶
type UDPListener struct { BaseListener IPv4Listener *ipv4.PacketConn IPv6Listener *ipv6.PacketConn // contains filtered or unexported fields }
func (*UDPListener) Close ¶
func (this *UDPListener) Close() error
func (*UDPListener) Reload ¶
func (this *UDPListener) Reload(group *serverconfigs.ServerAddressGroup)
func (*UDPListener) Serve ¶
func (this *UDPListener) Serve() error
type UDPPacketListener ¶ added in v0.5.3
type UnixListener ¶
type UnixListener struct { BaseListener Listener net.Listener }
func (*UnixListener) Close ¶
func (this *UnixListener) Close() error
func (*UnixListener) Reload ¶
func (this *UnixListener) Reload(group *serverconfigs.ServerAddressGroup)
func (*UnixListener) Serve ¶
func (this *UnixListener) Serve() error
type UpgradeManager ¶
type UpgradeManager struct {
// contains filtered or unexported fields
}
UpgradeManager 节点升级管理器 TODO 需要在集群中设置是否自动更新
func (*UpgradeManager) IsInstalling ¶ added in v0.5.0
func (this *UpgradeManager) IsInstalling() bool
IsInstalling 检查是否正在安装
type UserManager ¶ added in v0.5.6
type UserManager struct {
// contains filtered or unexported fields
}
func NewUserManager ¶ added in v0.5.6
func NewUserManager() *UserManager
func (*UserManager) CheckUserServersIsEnabled ¶ added in v0.5.6
func (this *UserManager) CheckUserServersIsEnabled(userId int64) (isEnabled bool)
func (*UserManager) UpdateUserServersIsEnabled ¶ added in v0.5.6
func (this *UserManager) UpdateUserServersIsEnabled(userId int64, isEnabled bool)
type WebsocketResponseReader ¶ added in v0.5.5
type WebsocketResponseReader struct {
// contains filtered or unexported fields
}
WebsocketResponseReader Websocket响应Reader
func NewWebsocketResponseReader ¶ added in v0.5.5
func NewWebsocketResponseReader(rawReader io.Reader) *WebsocketResponseReader
Source Files
¶
- api_stream.go
- client_conn.go
- client_conn_base.go
- client_conn_interface.go
- client_conn_limiter.go
- client_conn_traffic.go
- client_conn_utils.go
- client_listener.go
- client_tls_conn.go
- conn_linger.go
- http_access_log_queue.go
- http_access_log_viewer.go
- http_cache_task_manager.go
- http_client.go
- http_client_pool.go
- http_client_transport.go
- http_request.go
- http_request_acme.go
- http_request_auth.go
- http_request_cache.go
- http_request_cc.go
- http_request_error.go
- http_request_events.go
- http_request_fastcgi.go
- http_request_health_check.go
- http_request_host_redirect.go
- http_request_http3.go
- http_request_limit.go
- http_request_ln.go
- http_request_log.go
- http_request_metrics.go
- http_request_mismatch.go
- http_request_oss.go
- http_request_page.go
- http_request_plan_expires.go
- http_request_redirect_https.go
- http_request_referers.go
- http_request_reverse_proxy.go
- http_request_rewrite.go
- http_request_root.go
- http_request_shutdown.go
- http_request_stat.go
- http_request_sub.go
- http_request_traffic_limit.go
- http_request_uam.go
- http_request_url.go
- http_request_user_agent.go
- http_request_utils.go
- http_request_waf.go
- http_request_websocket.go
- http_writer.go
- http_writer_empty.go
- http_writer_ext.go
- ip_library_updater.go
- listener.go
- listener_base.go
- listener_base_ext.go
- listener_http.go
- listener_interface.go
- listener_manager.go
- listener_tcp.go
- listener_udp.go
- listener_unix.go
- node.go
- node_ext.go
- node_panic.go
- node_status_executor.go
- node_status_executor_unix.go
- node_tasks.go
- node_tasks_ext.go
- origin_conn.go
- origin_state.go
- origin_state_manager.go
- origin_utils.go
- system_services.go
- task_ocsp_update.go
- task_sync_api_nodes.go
- toa_manager.go
- upgrade_manager.go
- user_manager.go