nodes

package
v1.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 24, 2024 License: BSD-3-Clause Imports: 109 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AccessLogMaxRequestBodySize 访问日志存储的请求内容最大尺寸 TODO 此值应该可以在访问日志页设置
	AccessLogMaxRequestBodySize = 2 * 1024 * 1024
)
View Source
const HTTPIdleTimeout = 75 * time.Second
View Source
const (
	LNExpiresHeader = "X-Edge-Ln-Expires"
)
View Source
const (
	UDPConnLifeSeconds = 30
)

Variables

View Source
var DaemonIsOn = false
View Source
var DaemonPid = 0
View Source
var HOSTNAME, _ = os.Hostname()

环境变量

View Source
var HTTPConnContextKey = &contextKey{key: "http-conn"}
View Source
var SharedHTTPCacheTaskManager = NewHTTPCacheTaskManager()
View Source
var SharedHTTPClientPool = NewHTTPClientPool()

SharedHTTPClientPool HTTP客户端池单例

View Source
var SharedOriginStateManager = NewOriginStateManager()
View Source
var SharedUserManager = NewUserManager()

Functions

func CleanOriginConnsTask added in v1.2.7

func CleanOriginConnsTask()

func NewClientConn

func NewClientConn(rawConn net.Conn, isHTTP bool, isTLS bool, isInAllowList bool) net.Conn

func NewClientTLSConn

func NewClientTLSConn(conn *tls.Conn) net.Conn

func NewOriginConn added in v1.2.7

func NewOriginConn(rawConn net.Conn) net.Conn

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

func (*APIStream) Start

func (this *APIStream) Start()

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) IsBound

func (this *BaseClientConn) IsBound() bool

IsBound 是否已绑定服务

func (*BaseClientConn) IsClosed

func (this *BaseClientConn) IsClosed() bool

func (*BaseClientConn) LastRequestBytes added in v1.2.7

func (this *BaseClientConn) LastRequestBytes() int64

LastRequestBytes 读取上一次请求发送的字节数

func (*BaseClientConn) RawIP

func (this *BaseClientConn) RawIP() string

RawIP 原本IP

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 获取当前活跃连接数

func (*BaseListener) Init

func (this *BaseListener) Init()

Init 初始化

func (*BaseListener) Reset

func (this *BaseListener) Reset()

Reset 清除既有配置

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) Read

func (this *ClientConn) Read(b []byte) (n int, err error)

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

func (*ClientConn) Write

func (this *ClientConn) Write(b []byte) (n int, err 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) Accept

func (this *ClientListener) Accept() (net.Conn, error)

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) Read

func (this *ClientTLSConn) Read(b []byte) (n int, err error)

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

func (*ClientTLSConn) Write

func (this *ClientTLSConn) Write(b []byte) (n int, err 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) Start

func (this *HTTPAccessLogQueue) Start()

Start 开始处理访问日志

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 发送日志

func (*HTTPAccessLogViewer) Start

func (this *HTTPAccessLogViewer) Start() error

Start 启动

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 NewHTTPClient

func NewHTTPClient(rawClient *http.Client) *HTTPClient

NewHTTPClient 获取新客户端对象

func (*HTTPClient) AccessTime

func (this *HTTPClient) AccessTime() int64

AccessTime 获取访问时间

func (*HTTPClient) Close

func (this *HTTPClient) Close()

Close 关闭

func (*HTTPClient) RawClient

func (this *HTTPClient) RawClient() *http.Client

RawClient 获取原始客户端对象

func (*HTTPClient) UpdateAccessTime

func (this *HTTPClient) UpdateAccessTime()

UpdateAccessTime 更新访问时间

type HTTPClientPool

type HTTPClientPool struct {
	// contains filtered or unexported fields
}

HTTPClientPool 客户端池

func NewHTTPClientPool

func NewHTTPClientPool() *HTTPClientPool

NewHTTPClientPool 获取新对象

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 HTTPClientTransport struct {
	*http.Transport
}

func (*HTTPClientTransport) RoundTrip

func (this *HTTPClientTransport) RoundTrip(req *http.Request) (*http.Response, error)

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)

ServeHTTPWithAddr 处理HTTP请求

func (*HTTPListener) ServeHTTPWithAddr added in v1.3.3

func (this *HTTPListener) ServeHTTPWithAddr(rawWriter http.ResponseWriter, rawReq *http.Request, serverAddr string)

ServeHTTPWithAddr 处理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) Allow

func (this *HTTPRequest) Allow()

Allow 放行

func (*HTTPRequest) CalculateSize

func (this *HTTPRequest) CalculateSize() (size int64)

CalculateSize 计算当前请求的尺寸(预估)

func (*HTTPRequest) Close

func (this *HTTPRequest) Close()

Close 关闭连接

func (*HTTPRequest) ContentLength

func (this *HTTPRequest) ContentLength() int64

ContentLength 请求内容长度

func (*HTTPRequest) Cookie

func (this *HTTPRequest) Cookie(name string) string

Cookie 获取Cookie

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) DisableStat added in v1.3.0

func (this *HTTPRequest) DisableStat()

DisableStat 停用统计

func (*HTTPRequest) Do

func (this *HTTPRequest) Do()

Do 执行请求

func (*HTTPRequest) Done

func (this *HTTPRequest) Done()

Done 设置已完成

func (*HTTPRequest) Format

func (this *HTTPRequest) Format(source string) string

Format 利用请求参数格式化字符串

func (*HTTPRequest) Header

func (this *HTTPRequest) Header() http.Header

Header 读取Header

func (*HTTPRequest) Host

func (this *HTTPRequest) Host() string

Host 获取Host

func (*HTTPRequest) Id

func (this *HTTPRequest) Id() string

func (*HTTPRequest) Method

func (this *HTTPRequest) Method() string

Method 请求方法

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) Path

func (this *HTTPRequest) Path() string

Path 请求的URL中路径部分

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) RawURI

func (this *HTTPRequest) RawURI() string

RawURI 原始的请求URI

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) SetURI

func (this *HTTPRequest) SetURI(uri string)

SetURI 设置当前请求的URI

func (*HTTPRequest) SetVar

func (this *HTTPRequest) SetVar(name string, value string)

func (*HTTPRequest) TransferEncoding

func (this *HTTPRequest) TransferEncoding() string

TransferEncoding 获取传输编码

func (*HTTPRequest) URI

func (this *HTTPRequest) URI() string

URI 获取当前请求的URI

func (*HTTPRequest) URL

func (this *HTTPRequest) URL() string

URL 获取完整的URL

func (*HTTPRequest) WAFClose

func (this *HTTPRequest) WAFClose()

WAFClose 关闭连接

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) WAFRaw

func (this *HTTPRequest) WAFRaw() *http.Request

WAFRaw 原始请求

func (*HTTPRequest) WAFReadBody

func (this *HTTPRequest) WAFReadBody(max int64) (data []byte, err error)

WAFReadBody 读取Body

func (*HTTPRequest) WAFRemoteIP

func (this *HTTPRequest) WAFRemoteIP() string

WAFRemoteIP 客户端IP

func (*HTTPRequest) WAFRestoreBody

func (this *HTTPRequest) WAFRestoreBody(data []byte)

WAFRestoreBody 恢复Body

func (*HTTPRequest) WAFServerId

func (this *HTTPRequest) WAFServerId() int64

WAFServerId 服务ID

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) Close

func (this *HTTPWriter) Close()

Close 关闭

func (*HTTPWriter) DelayRead

func (this *HTTPWriter) DelayRead() bool

DelayRead 是否延迟读取Reader

func (*HTTPWriter) DeleteHeader

func (this *HTTPWriter) DeleteHeader(name string)

DeleteHeader 删除Header

func (*HTTPWriter) Flush

func (this *HTTPWriter) Flush()

Flush Flush

func (*HTTPWriter) GetHeader

func (this *HTTPWriter) GetHeader(name string) string

GetHeader 读取Header值

func (*HTTPWriter) Header

func (this *HTTPWriter) Header() http.Header

Header 获取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) Raw

func (this *HTTPWriter) Raw() http.ResponseWriter

Raw 包装前的原始的Writer

func (*HTTPWriter) Redirect

func (this *HTTPWriter) Redirect(status int, url string)

Redirect 跳转

func (*HTTPWriter) Send

func (this *HTTPWriter) Send(status int, body string)

Send 直接发送内容,并终止请求

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) SetOk

func (this *HTTPWriter) SetOk()

SetOk 设置成功

func (*HTTPWriter) SetSentHeaderBytes

func (this *HTTPWriter) SetSentHeaderBytes(sentHeaderBytes int64)

func (*HTTPWriter) StatusCode

func (this *HTTPWriter) StatusCode() int

StatusCode 读取状态码

func (*HTTPWriter) Write

func (this *HTTPWriter) Write(data []byte) (n int, err error)

Write 写入数据

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 LingerConn interface {
	SetLinger(sec int) error
}

type Listener

type Listener struct {
	// contains filtered or unexported fields
}

func NewListener

func NewListener() *Listener

func (*Listener) Close

func (this *Listener) Close() error

func (*Listener) FullAddr

func (this *Listener) FullAddr() string

func (*Listener) Listen

func (this *Listener) Listen() error

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 NewListenerManager

func NewListenerManager() *ListenerManager

NewListenerManager 获取新对象

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 NewNode

func NewNode() *Node

func (*Node) Daemon

func (this *Node) Daemon()

Daemon 实现守护进程

func (*Node) InstallSystemService

func (this *Node) InstallSystemService() error

InstallSystemService 安装系统服务

func (*Node) Start

func (this *Node) Start()

Start 启动

func (*Node) Test

func (this *Node) Test() error

Test 检查配置

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

type OriginConn struct {
	net.Conn
	// contains filtered or unexported fields
}

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

func (*OriginConn) Read added in v1.2.7

func (this *OriginConn) Read(b []byte) (n int, err error)

Read implement Read() for net.Conn interface

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) Loop

func (this *OriginStateManager) Loop() error

Loop 单次循环检查

func (*OriginStateManager) Start

func (this *OriginStateManager) Start()

Start 启动

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

func (*UDPConn) Close

func (this *UDPConn) Close() error

func (*UDPConn) IsOk

func (this *UDPConn) IsOk() bool

func (*UDPConn) Write

func (this *UDPConn) Write(b []byte) (n int, err error)

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

func (*UDPIPv4Listener) ReadFrom added in v0.5.3

func (this *UDPIPv4Listener) ReadFrom(b []byte) (n int, cm any, src net.Addr, err error)

func (*UDPIPv4Listener) WriteTo added in v0.5.3

func (this *UDPIPv4Listener) WriteTo(b []byte, cm any, dst net.Addr) (n int, err error)

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

func (*UDPIPv6Listener) ReadFrom added in v0.5.3

func (this *UDPIPv6Listener) ReadFrom(b []byte) (n int, cm any, src net.Addr, err error)

func (*UDPIPv6Listener) WriteTo added in v0.5.3

func (this *UDPIPv6Listener) WriteTo(b []byte, cm any, dst net.Addr) (n int, err error)

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 UDPPacketListener interface {
	ReadFrom(b []byte) (n int, cm any, src net.Addr, err error)
	WriteTo(b []byte, cm any, dst net.Addr) (n int, err error)
	LocalAddr() net.Addr
}

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 NewUpgradeManager

func NewUpgradeManager() *UpgradeManager

NewUpgradeManager 获取新对象

func (*UpgradeManager) IsInstalling added in v0.5.0

func (this *UpgradeManager) IsInstalling() bool

IsInstalling 检查是否正在安装

func (*UpgradeManager) Start

func (this *UpgradeManager) Start()

Start 启动升级

type User added in v0.5.6

type User struct {
	ServersEnabled bool
}

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

func (*WebsocketResponseReader) Read added in v0.5.5

func (this *WebsocketResponseReader) Read(p []byte) (n int, err error)

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL