serverconfigs

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: BSD-3-Clause Imports: 32 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DomainMismatchActionPage  = "page"
	DomainMismatchActionClose = "close"
)
View Source
const (
	DefaultTCPPortRangeMin = 10000
	DefaultTCPPortRangeMax = 40000
)
View Source
const (
	HTTPRewriteTargetProxy = 1
	HTTPRewriteTargetURL   = 2
)
View Source
const DefaultOpenFileCacheMax = 1024
View Source
const DefaultPlanExpireNoticePageBody = `` /* 241-byte string literal not displayed */

DefaultPlanExpireNoticePageBody 套餐过期时提示

View Source
const DefaultTrafficLimitNoticePageBody = `` /* 276-byte string literal not displayed */

DefaultTrafficLimitNoticePageBody 达到流量限制时默认提示内容

View Source
const HealthCheckHeaderName = "X-Edge-Health-Check-Key"

Variables

View Source
var AccessLogSyslogStoragePriorities = []maps.Map{
	{
		"name":  "[无]",
		"value": -1,
	},
	{
		"name":  "EMERG",
		"value": AccessLogSyslogStoragePriorityEmerg,
	},
	{
		"name":  "ALERT",
		"value": AccessLogSyslogStoragePriorityAlert,
	},
	{
		"name":  "CRIT",
		"value": AccessLogSyslogStoragePriorityCrit,
	},
	{
		"name":  "ERR",
		"value": AccessLogSyslogStoragePriorityErr,
	},
	{
		"name":  "WARNING",
		"value": AccessLogSyslogStoragePriorityWarning,
	},
	{
		"name":  "NOTICE",
		"value": AccessLogSyslogStoragePriorityNotice,
	},
	{
		"name":  "INFO",
		"value": AccessLogSyslogStoragePriorityInfo,
	},
	{
		"name":  "DEBUG",
		"value": AccessLogSyslogStoragePriorityDebug,
	},
}
View Source
var AllCachePolicyStorageTypes = []maps.Map{
	{
		"name": "文件缓存",
		"type": CachePolicyStorageFile,
	},
	{
		"name": "内存缓存",
		"type": CachePolicyStorageMemory,
	},
}
View Source
var AllHTTPCommonRequestHeaders = append(append([]string{}, HTTPCommonRequestHeaders...), HTTPCommonRequestHeaders2...)
View Source
var AllHTTPCommonResponseHeaders = append(append([]string{}, HTTPCommonResponseHeaders...), HTTPCommonResponseHeaders2...)
View Source
var DefaultHTTPAccessLogRef = NewHTTPAccessLogRef()

DefaultHTTPAccessLogRef 默认的访问日志配置

View Source
var DefaultHTTPCCThresholds = []*HTTPCCThreshold{} // stub
View Source
var DefaultIPLibraryType = IPLibraryTypeIP2Region
View Source
var DefaultSkippedResponseCacheControlValues = []string{"private", "no-cache", "no-store"}
View Source
var HTTPAccessLogFields = []maps.Map{
	{
		"code": HTTPAccessLogFieldHeader,
		"name": "请求Header列表",
	},
	{
		"code": HTTPAccessLogFieldSentHeader,
		"name": "响应Header列表",
	},
	{
		"code": HTTPAccessLogFieldArg,
		"name": "参数列表",
	},
	{
		"code": HTTPAccessLogFieldCookie,
		"name": "Cookie列表",
	},
	{
		"code": HTTPAccessLogFieldExtend,
		"name": "位置和浏览器分析",
	},
	{
		"code": HTTPAccessLogFieldReferer,
		"name": "请求来源",
	},
	{
		"code": HTTPAccessLogFieldUserAgent,
		"name": "终端信息",
	},
	{
		"code": HTTPAccessLogFieldRequestBody,
		"name": "请求Body",
	},
}
View Source
var HTTPAccessLogShortFields = []maps.Map{
	{
		"code": HTTPAccessLogFieldHeader,
		"name": "请求Header列表",
	},
	{
		"code": HTTPAccessLogFieldSentHeader,
		"name": "响应Header列表",
	},
}

HTTPAccessLogShortFields 精简版的日志字段,用来用

View Source
var HTTPCommonRequestHeaders = []string{
	"A-IM",
	"Accept",
	"Accept-Charset",
	"Accept-Datetime",
	"Accept-Encoding",
	"Accept-Language",
	"Access-Control-Request-Method",
	"Access-Control-Request-Headers",
	"Authorization",
	"Cache-Control",
	"Connection",
	"Content-Encoding",
	"Content-Length",
	"Content-MD5",
	"Content-Type",
	"Cookie",
	"Date",
	"Expect",
	"Forwarded",
	"From",
	"Host",
	"HTTP2-Settings",
	"If-Match",
	"If-Modified-Since",
	"If-None-Match",
	"If-Range",
	"If-Unmodified-Since",
	"Max-Forwards",
	"Origin",
	"Pragma",
	"Prefer",
	"Proxy-Authorization",
	"Range",
	"Referer",
	"TE",
	"Trailer",
	"Transfer-Encoding",
	"User-Agent",
	"Upgrade",
	"Via",
	"Warning",
	"Keep-Alive",
}
View Source
var HTTPCommonRequestHeaders2 = []string{
	"Upgrade-Insecure-Requests",
	"X-Requested-With",
	"DNT",
	"X-Forwarded-For",
	"X-Forwarded-Host",
	"X-Forwarded-Proto",
	"X-Forwarded-By",
	"X-Real-IP",
	"Front-End-Https",
	"X-Http-Method-Override",
	"X-ATT-DeviceId",
	"X-Wap-Profile",
	"Proxy-Connection",
	"X-UIDH",
	"X-Csrf-Token",
	"X-Request-ID",
	"X-Correlation-ID",
	"Correlation-ID",
	"Save-Data",
	"Device-Memory",
	"Downlink",
	"Early-Data",
	"ECT",
	"RTT",
	"Sec-CH-UA",
	"Sec-CH-UA-Arch",
	"Sec-CH-UA-Bitness",
	"Sec-CH-UA-Full-Version",
	"Sec-CH-UA-Full-Version-List",
	"Sec-CH-UA-Mobile",
	"Sec-CH-UA-Model",
	"Sec-CH-UA-Platform",
	"Sec-CH-UA-Platform-Version",
	"Sec-Fetch-Dest",
	"Sec-Fetch-Mode",
	"Sec-Fetch-Site",
	"Sec-Fetch-User",
	"Sec-GPC",
	"Service-Worker-Navigation-Preload",
	"Viewport-Width",
	"Want-Digest",
}
View Source
var HTTPCommonResponseHeaders = []string{
	"Accept-CH",
	"Access-Control-Allow-Origin",
	"Access-Control-Allow-Credentials",
	"Access-Control-Expose-Headers",
	"Access-Control-Max-Age",
	"Access-Control-Allow-Methods",
	"Access-Control-Allow-Headers",
	"Accept-Patch",
	"Accept-Post",
	"Accept-Ranges",
	"Age",
	"Allow",
	"Alt-Svc",
	"Cache-Control",
	"Clear-Site-Data",
	"Connection",
	"Content-Disposition",
	"Content-Encoding",
	"Content-Language",
	"Content-Length",
	"Content-Location",
	"Content-MD5",
	"Content-Range",
	"Content-Type",
	"Date",
	"Delta-Base",
	"ETag",
	"Expires",
	"IM",
	"Last-Modified",
	"Link",
	"Location",
	"P3P",
	"Pragma",
	"Preference-Applied",
	"Proxy-Authenticate",
	"Public-Key-Pins",
	"Retry-After",
	"Server",
	"Server-Timing",
	"Set-Cookie",
	"Strict-Transport-Security",
	"Trailer",
	"Transfer-Encoding",
	"Tk",
	"Upgrade",
	"Vary",
	"Via",
	"Warning",
	"WWW-Authenticate",
	"X-Frame-Options",
	"Keep-Alive",
	"Referrer-Policy",
}
View Source
var HTTPCommonResponseHeaders2 = []string{
	"Content-Security-Policy",
	"X-Content-Security-Policy",
	"Content-Security-Policy-Report-Only",
	"Cross-Origin-Embedder-Policy",
	"Cross-Origin-Opener-Policy",
	"Cross-Origin-Resource-Policy",
	"Digest",
	"X-WebKit-CSP",
	"Expect-CT",
	"NEL",
	"Permissions-Policy",
	"Refresh",
	"Report-To",
	"Status",
	"Timing-Allow-Origin",
	"X-Content-Duration",
	"X-Content-Type-Options",
	"X-Powered-By",
	"X-Redirect-By",
	"X-Request-ID",
	"X-Correlation-ID",
	"X-UA-Compatible",
	"X-XSS-Protection",
	"Sec-WebSocket-Accept",
	"SourceMap",
	"X-DNS-Prefetch-Control",
}
View Source
var IPLibraryTypes = []maps.Map{
	{
		"name":        "ip2region",
		"code":        IPLibraryTypeIP2Region,
		"description": "一个开源的IP库:https://github.com/lionsoul2014/ip2region",
		"ext":         ".db",
	},
}

所有的IP库类型

Functions

func AllLocationPatternTypes

func AllLocationPatternTypes() []maps.Map

AllLocationPatternTypes 取得所有的匹配类型信息

func AllServerTypes

func AllServerTypes() []maps.Map

AllServerTypes 获取所有的服务类型

func FindAccessLogStorageTypeName

func FindAccessLogStorageTypeName(storageType string) string

FindAccessLogStorageTypeName 根据类型查找名称

func FindAccessLogSyslogStoragePriorityName

func FindAccessLogSyslogStoragePriorityName(priority AccessLogSyslogStoragePriority) string

func FindAllAccessLogStorageTypes

func FindAllAccessLogStorageTypes() []*shared.Definition

FindAllAccessLogStorageTypes 所有存储引擎列表

func FindAllMetricChartTypes

func FindAllMetricChartTypes() []*shared.Definition

func FindAllMetricKeyDefinitions

func FindAllMetricKeyDefinitions(category MetricItemCategory) []*shared.Definition

FindAllMetricKeyDefinitions 指标对象定义

func FindAllServerProtocols added in v0.5.0

func FindAllServerProtocols() []maps.Map

FindAllServerProtocols 查找所有协议

func FindAllServerProtocolsForType added in v0.5.0

func FindAllServerProtocolsForType(serverType ServerType) []maps.Map

FindAllServerProtocolsForType 获取所有协议

func FindCachePolicyStorageName

func FindCachePolicyStorageName(policyType CachePolicyStorageType) string

根据类型查找名称

func FindIPLibraryWithType

func FindIPLibraryWithType(libraryType string) maps.Map

根据类型查找IP库

func FindLocationPatternType

func FindLocationPatternType(patternType int) maps.Map

FindLocationPatternType 查找单个匹配类型信息

func FindLocationPatternTypeName

func FindLocationPatternTypeName(patternType int) string

FindLocationPatternTypeName 查找单个匹配类型名称

func FindMetricChartTypeName

func FindMetricChartTypeName(chartType MetricChartType) string

func FindMetricPeriodUnitName

func FindMetricPeriodUnitName(unit string) string

func FindMetricValueName

func FindMetricValueName(category MetricItemCategory, code string) string

func FindMetricValueType

func FindMetricValueType(category MetricItemCategory, code string) string

func FindServerType

func FindServerType(code string) maps.Map

FindServerType 查找服务类型

func HumanMetricTime

func HumanMetricTime(periodUnit MetricItemPeriodUnit, time string) string

HumanMetricTime 格式化时间,让时间更易读

func IsCommonRequestHeader added in v0.5.6

func IsCommonRequestHeader(headerName string) bool

IsCommonRequestHeader 判断某个HTTP请求Header名称是否为通用

func IsHTTPServerType

func IsHTTPServerType(serverType ServerType) bool

IsHTTPServerType 判断某个服务类型是否属于HTTP簇

func NormalizeServerNames

func NormalizeServerNames(serverNames []*ServerNameConfig)

NormalizeServerNames 格式化一组域名

func PlainServerNames

func PlainServerNames(serverNames []*ServerNameConfig) (result []string)

PlainServerNames 获取所有域名

Types

type AccessLogCommandStorageConfig

type AccessLogCommandStorageConfig struct {
	Command string   `yaml:"command" json:"command"`
	Args    []string `yaml:"args" json:"args"`
	Dir     string   `yaml:"dir" json:"dir"`
}

AccessLogCommandStorageConfig 通过命令行存储

type AccessLogESStorageConfig

type AccessLogESStorageConfig struct {
	Endpoint     string `yaml:"endpoint" json:"endpoint"`
	Index        string `yaml:"index" json:"index"`
	MappingType  string `yaml:"mappingType" json:"mappingType"`
	Username     string `yaml:"username" json:"username"`
	Password     string `yaml:"password" json:"password"`
	IsDataStream bool   `yaml:"isDataStream" json:"isDataStream"` // 是否为Data Stream模式
}

AccessLogESStorageConfig ElasticSearch存储策略

type AccessLogFileStorageConfig

type AccessLogFileStorageConfig struct {
	Path       string `yaml:"path" json:"path"`             // 文件路径,支持变量:${year|month|week|day|hour|minute|second}
	AutoCreate bool   `yaml:"autoCreate" json:"autoCreate"` // 是否自动创建目录
}

AccessLogFileStorageConfig 文件存储配置

type AccessLogQueueConfig

type AccessLogQueueConfig struct {
	MaxLength      int `yaml:"maxLength" json:"maxLength"`           // 队列最大长度
	CountPerSecond int `yaml:"countPerSecond" json:"countPerSecond"` // 每秒写入数量
	Percent        int `yaml:"percent" json:"percent"`               // 比例,如果为0-100,默认为100

	EnableAutoPartial bool  `yaml:"enableAutoPartial" json:"enableAutoPartial"` // 是否启动自动分表
	RowsPerTable      int64 `yaml:"rowsPerTable" json:"rowsPerTable"`           // 单表最大行数
}

AccessLogQueueConfig 访问日志队列配置

type AccessLogStorageType

type AccessLogStorageType = string

AccessLogStorageType 访问日志存储类型

const (
	AccessLogStorageTypeFile    AccessLogStorageType = "file"
	AccessLogStorageTypeES      AccessLogStorageType = "es"
	AccessLogStorageTypeTCP     AccessLogStorageType = "tcp"
	AccessLogStorageTypeSyslog  AccessLogStorageType = "syslog"
	AccessLogStorageTypeCommand AccessLogStorageType = "command"
)

type AccessLogSyslogStorageConfig

type AccessLogSyslogStorageConfig struct {
	Protocol   string                         `yaml:"protocol" json:"protocol"` // SysLogStorageProtocol*
	ServerAddr string                         `yaml:"serverAddr" json:"serverAddr"`
	ServerPort int                            `yaml:"serverPort" json:"serverPort"`
	Socket     string                         `yaml:"socket" json:"socket"` // sock file
	Tag        string                         `yaml:"tag" json:"tag"`
	Priority   AccessLogSyslogStoragePriority `yaml:"priority" json:"priority"`
}

AccessLogSyslogStorageConfig syslog存储策略

type AccessLogSyslogStoragePriority

type AccessLogSyslogStoragePriority = int
const (
	AccessLogSyslogStoragePriorityEmerg AccessLogSyslogStoragePriority = iota
	AccessLogSyslogStoragePriorityAlert
	AccessLogSyslogStoragePriorityCrit
	AccessLogSyslogStoragePriorityErr
	AccessLogSyslogStoragePriorityWarning
	AccessLogSyslogStoragePriorityNotice
	AccessLogSyslogStoragePriorityInfo
	AccessLogSyslogStoragePriorityDebug
)

type AccessLogSyslogStorageProtocol

type AccessLogSyslogStorageProtocol = string
const (
	AccessLogSyslogStorageProtocolTCP    AccessLogSyslogStorageProtocol = "tcp"
	AccessLogSyslogStorageProtocolUDP    AccessLogSyslogStorageProtocol = "udp"
	AccessLogSyslogStorageProtocolNone   AccessLogSyslogStorageProtocol = "none"
	AccessLogSyslogStorageProtocolSocket AccessLogSyslogStorageProtocol = "socket"
)

type AccessLogTCPStorageConfig

type AccessLogTCPStorageConfig struct {
	Network string `yaml:"network" json:"network"` // tcp, unix
	Addr    string `yaml:"addr" json:"addr"`
}

AccessLogTCPStorageConfig TCP存储策略

type BaseProtocol

type BaseProtocol struct {
	IsOn   bool                    `yaml:"isOn" json:"isOn"`     // 是否开启
	Listen []*NetworkAddressConfig `yaml:"listen" json:"listen"` // 绑定的网络地址
}

BaseProtocol 协议基础数据结构

func (*BaseProtocol) AddListen

func (this *BaseProtocol) AddListen(addr ...*NetworkAddressConfig)

AddListen 添加地址

func (*BaseProtocol) AllPorts added in v1.0.0

func (this *BaseProtocol) AllPorts() []int

AllPorts 获取所有端口号

func (*BaseProtocol) FullAddresses

func (this *BaseProtocol) FullAddresses() []string

FullAddresses 获取完整的地址列表

func (*BaseProtocol) InitBase

func (this *BaseProtocol) InitBase() error

InitBase 初始化

type CacheDir added in v0.5.8

type CacheDir struct {
	Path     string               `yaml:"path" json:"path"`         // 目录
	Capacity *shared.SizeCapacity `yaml:"capacity" json:"capacity"` // 容量限制 TODO 暂时不实现
}

type CachePolicyStorageType

type CachePolicyStorageType = string
const (
	CachePolicyStorageFile   CachePolicyStorageType = "file"
	CachePolicyStorageMemory CachePolicyStorageType = "memory"
)

type CommonScript

type CommonScript struct {
	Id       int64  `yaml:"id" json:"id"`
	IsOn     bool   `yaml:"isOn" json:"isOn"`
	Filename string `yaml:"filename" json:"filename"`
	Code     string `yaml:"code" json:"code"`
}

CommonScript 公共脚本

type ConfigCode added in v1.0.0

type ConfigCode = string
const (
	ConfigCodeUAM            ConfigCode = "uam"
	ConfigCodeCC             ConfigCode = "cc"
	ConfigCodeHostRedirects  ConfigCode = "hostRedirects"
	ConfigCodeLocations      ConfigCode = "locations"
	ConfigCodeRewrites       ConfigCode = "rewrites"
	ConfigCodeWAF            ConfigCode = "waf"
	ConfigCodeCache          ConfigCode = "cache"
	ConfigCodeAuth           ConfigCode = "auth"
	ConfigCodeReferers       ConfigCode = "referers"
	ConfigCodeUserAgent      ConfigCode = "userAgent"
	ConfigCodeCharset        ConfigCode = "charset"
	ConfigCodeAccessLog      ConfigCode = "accessLog"
	ConfigCodeStat           ConfigCode = "stat"
	ConfigCodeCompression    ConfigCode = "compression"
	ConfigCodeOptimization   ConfigCode = "optimization"
	ConfigCodePages          ConfigCode = "pages"
	ConfigCodeHeaders        ConfigCode = "headers"
	ConfigCodeWebsocket      ConfigCode = "websocket"
	ConfigCodeWebp           ConfigCode = "webp"
	ConfigCodeRoot           ConfigCode = "root"
	ConfigCodeFastcgi        ConfigCode = "fastcgi"
	ConfigCodeRemoteAddr     ConfigCode = "remoteAddr"
	ConfigCodeRequestLimit   ConfigCode = "requestLimit"
	ConfigCodeTraffic        ConfigCode = "traffic"
	ConfigCodeRequestScripts ConfigCode = "requestScripts"
	ConfigCodeReverseProxy   ConfigCode = "reverseProxy"
)

type DomainMismatchAction

type DomainMismatchAction struct {
	Code    string   `yaml:"code" json:"code"`       // 动作代号
	Options maps.Map `yaml:"options" json:"options"` // 动作选项
}

func (*DomainMismatchAction) Init

func (this *DomainMismatchAction) Init() error

type DomainMismatchCloseOptions

type DomainMismatchCloseOptions struct {
}

type DomainMismatchPageOptions

type DomainMismatchPageOptions struct {
	StatusCode  int    `yaml:"statusCode" json:"statusCode"`
	ContentHTML string `yaml:"contentHTML" json:"contentHTML"`
}

type FTPServerConfig

type FTPServerConfig struct {
	Username string `yaml:"username" json:"username"` // 用户名
	Password string `yaml:"password" json:"password"` // 密码
	Dir      string `yaml:"dir" json:"dir"`           // 目录
}

FTP源站配置

type FTPServerRef

type FTPServerRef struct {
	IsOn        bool  `yaml:"isOn" json:"isOn"`
	FTPServerId int64 `yaml:"ftpServerId" json:"ftpServerId"`
}

type FollowProtocolConfig added in v1.0.0

type FollowProtocolConfig struct {
	IsPrior bool `yaml:"isPrior" json:"isPrior"` // 是否覆盖父级配置
	IsOn    bool `yaml:"isOn" json:"isOn"`       // 是否启用
	HTTP    struct {
		Port       int  `yaml:"port" json:"port"`             // 端口
		FollowPort bool `yaml:"followPort" json:"followPort"` // 跟随端口
	} `yaml:"http" json:"http"` // HTTP配置
	HTTPS struct {
		Port       int  `yaml:"port" json:"port"`             // 端口
		FollowPort bool `yaml:"followPort" json:"followPort"` // 跟随端口
	} `yaml:"https" json:"https"` // HTTPS配置
}

FollowProtocolConfig 协议跟随配置

func NewFollowProtocolConfig added in v1.0.0

func NewFollowProtocolConfig() *FollowProtocolConfig

func (*FollowProtocolConfig) Init added in v1.0.0

func (this *FollowProtocolConfig) Init() error

type GlobalConfig

type GlobalConfig struct {
	// HTTP & HTTPS相关配置
	HTTPAll struct {
		//MatchDomainStrictly  bool                  `yaml:"matchDomainStrictly" json:"matchDomainStrictly"`   // 是否严格匹配域名
		//AllowMismatchDomains []string              `yaml:"allowMismatchDomains" json:"allowMismatchDomains"` // 允许的不匹配的域名
		//DefaultDomain        string                `yaml:"defaultDomain" json:"defaultDomain"`               // 默认的域名
		//DomainMismatchAction *DomainMismatchAction `yaml:"domainMismatchAction" json:"domainMismatchAction"` // 不匹配时采取的动作
		DomainAuditingIsOn   bool   `yaml:"domainAuditingIsOn" json:"domainAuditingIsOn"`     // 域名是否需要审核
		DomainAuditingPrompt string `yaml:"domainAuditingPrompt" json:"domainAuditingPrompt"` // 域名审核的提示
	} `yaml:"httpAll" json:"httpAll"`

	TCPAll struct {
		PortRangeMin int   `yaml:"portRangeMin" json:"portRangeMin"` // 最小端口
		PortRangeMax int   `yaml:"portRangeMax" json:"portRangeMax"` // 最大端口
		DenyPorts    []int `yaml:"denyPorts" json:"denyPorts"`       // 禁止使用的端口
	} `yaml:"tcpAll" json:"tcpAll"`
}

GlobalConfig 服务相关的全局设置 Deprecated

func (*GlobalConfig) Init

func (this *GlobalConfig) Init() error

type GlobalServerConfig added in v0.5.3

type GlobalServerConfig struct {
	HTTPAll struct {
		MatchDomainStrictly  bool                  `yaml:"matchDomainStrictly" json:"matchDomainStrictly"`   // 是否严格匹配域名
		AllowMismatchDomains []string              `yaml:"allowMismatchDomains" json:"allowMismatchDomains"` // 允许的不匹配的域名
		AllowNodeIP          bool                  `yaml:"allowNodeIP" json:"allowNodeIP"`                   // 允许IP直接访问
		NodeIPShowPage       bool                  `yaml:"nodeIPShowPage" json:"nodeIPShowPage"`             // 访问IP地址是否显示页面
		NodeIPPageHTML       string                `yaml:"nodeIPPageHTML" json:"nodeIPPageHTML"`             // 访问IP地址页面内容
		DefaultDomain        string                `yaml:"defaultDomain" json:"defaultDomain"`               // 默认的域名
		DomainMismatchAction *DomainMismatchAction `yaml:"domainMismatchAction" json:"domainMismatchAction"` // 不匹配时采取的动作

		SupportsLowVersionHTTP  bool   `yaml:"supportsLowVersionHTTP" json:"supportsLowVersionHTTP"`   // 是否启用低版本HTTP
		MatchCertFromAllServers bool   `yaml:"matchCertFromAllServers" json:"matchCertFromAllServers"` // 从所有服务中匹配证书(不要轻易开启!)
		ForceLnRequest          bool   `yaml:"forceLnRequest" json:"forceLnRequest"`                   // 强制从Ln请求内容
		ServerName              string `yaml:"serverName" json:"serverName"`                           // Server名称
	} `yaml:"httpAll" json:"httpAll"` // HTTP统一配置

	HTTPAccessLog struct {
		IsOn                     bool `yaml:"isOn" json:"isOn"`                                         // 是否启用此功能
		EnableRequestHeaders     bool `yaml:"enableRequestHeaders" json:"enableRequestHeaders"`         // 记录请求Header
		CommonRequestHeadersOnly bool `yaml:"commonRequestHeadersOnly" json:"commonRequestHeadersOnly"` // 只保留通用Header
		EnableResponseHeaders    bool `yaml:"enableResponseHeaders" json:"enableResponseHeaders"`       // 记录响应Header
		EnableCookies            bool `yaml:"enableCookies" json:"enableCookies"`                       // 记录Cookie
		EnableServerNotFound     bool `yaml:"enableServerNotFound" json:"enableServerNotFound"`         // 记录服务找不到的日志
	} `yaml:"httpAccessLog" json:"httpAccessLog"` // 访问日志配置

	Stat struct {
		Upload struct {
			MaxCities    int16 `yaml:"maxCities" json:"maxCities"`       // 最大区域数量
			MaxProviders int16 `yaml:"maxProviders" json:"maxProviders"` // 最大运营商数量
			MaxSystems   int16 `yaml:"maxSystems" json:"maxSystems"`     // 最大操作系统数量
			MaxBrowsers  int16 `yaml:"maxBrowsers" json:"maxBrowsers"`   // 最大浏览器数量
		} `yaml:"upload" json:"upload"` // 上传相关设置
	} `yaml:"stat" json:"stat"` // 统计相关配置

	Performance struct {
		Debug            bool `yaml:"debug" json:"debug"`                       // Debug模式
		AutoWriteTimeout bool `yaml:"autoWriteTimeout" json:"autoWriteTimeout"` // 是否自动写超时
		AutoReadTimeout  bool `yaml:"autoReadTimeout" json:"autoReadTimeout"`   // 是否自动读超时
	} `yaml:"performance" json:"performance"` // 性能

	Log struct {
		RecordServerError bool `yaml:"recordServerError" json:"recordServerError"` // 记录服务错误到运行日志
	} `yaml:"log" json:"log"` // 运行日志配置
}

GlobalServerConfig 全局的服务配置

func NewGlobalServerConfig added in v1.2.1

func NewGlobalServerConfig() *GlobalServerConfig

func (*GlobalServerConfig) Init added in v0.5.3

func (this *GlobalServerConfig) Init() error

type HTTPAccessLogField

type HTTPAccessLogField = int
const (
	HTTPAccessLogFieldHeader       HTTPAccessLogField = 1
	HTTPAccessLogFieldSentHeader   HTTPAccessLogField = 2
	HTTPAccessLogFieldArg          HTTPAccessLogField = 3
	HTTPAccessLogFieldCookie       HTTPAccessLogField = 4
	HTTPAccessLogFieldExtend       HTTPAccessLogField = 5
	HTTPAccessLogFieldReferer      HTTPAccessLogField = 6
	HTTPAccessLogFieldUserAgent    HTTPAccessLogField = 7
	HTTPAccessLogFieldRequestBody  HTTPAccessLogField = 8
	HTTPAccessLogFieldResponseBody HTTPAccessLogField = 9
)

type HTTPAccessLogRef

type HTTPAccessLogRef struct {
	IsPrior bool `yaml:"isPrior" json:"isPrior"` // 是否覆盖
	IsOn    bool `yaml:"isOn" json:"isOn"`       // 是否启用

	Fields []int `yaml:"fields" json:"fields"` // 记录的字段

	Status1 bool `yaml:"status1" json:"status1"` // 1xx
	Status2 bool `yaml:"status2" json:"status2"` // 2xx
	Status3 bool `yaml:"status3" json:"status3"` // 3xx
	Status4 bool `yaml:"status4" json:"status4"` // 4xx
	Status5 bool `yaml:"status5" json:"status5"` // 5xx

	EnableClientClosed bool `yaml:"enableClientClosed" json:"enableClientClosed"` // 是否记录客户端关闭事件

	StorageOnly     bool    `yaml:"storageOnly" json:"storageOnly"`         // 是否只输出到存储策略
	StoragePolicies []int64 `yaml:"storagePolicies" json:"storagePolicies"` // 存储策略Ids

	FirewallOnly bool `yaml:"firewallOnly" json:"firewallOnly"` // 是否只记录防火墙相关日志
}

HTTPAccessLogRef 代理访问日志配置

func NewHTTPAccessLogRef

func NewHTTPAccessLogRef() *HTTPAccessLogRef

NewHTTPAccessLogRef 获取新对象

func (*HTTPAccessLogRef) ContainsField

func (this *HTTPAccessLogRef) ContainsField(field int) bool

ContainsField 检查是否包含某个Field

func (*HTTPAccessLogRef) ContainsStoragePolicy

func (this *HTTPAccessLogRef) ContainsStoragePolicy(storagePolicyId int64) bool

ContainsStoragePolicy 是否包含某个存储策略

func (*HTTPAccessLogRef) Init

func (this *HTTPAccessLogRef) Init() error

Init 校验

func (*HTTPAccessLogRef) Match

func (this *HTTPAccessLogRef) Match(status int) bool

Match 判断是否应该记录

type HTTPAuthBaseMethod added in v0.5.2

type HTTPAuthBaseMethod struct {
	Exts    []string `json:"exts"`
	Domains []string `json:"domains"`
}

func (*HTTPAuthBaseMethod) MatchRequest added in v0.5.2

func (this *HTTPAuthBaseMethod) MatchRequest(req *http.Request) bool

func (*HTTPAuthBaseMethod) SetDomains added in v0.5.2

func (this *HTTPAuthBaseMethod) SetDomains(domains []string)

func (*HTTPAuthBaseMethod) SetExts added in v0.5.2

func (this *HTTPAuthBaseMethod) SetExts(exts []string)

type HTTPAuthBasicMethod

type HTTPAuthBasicMethod struct {
	HTTPAuthBaseMethod

	Users   []*HTTPAuthBasicMethodUser `json:"users"`
	Realm   string                     `json:"realm"`
	Charset string                     `json:"charset"`
	// contains filtered or unexported fields
}

HTTPAuthBasicMethod BasicAuth方法定义

func NewHTTPAuthBasicMethod

func NewHTTPAuthBasicMethod() *HTTPAuthBasicMethod

func (*HTTPAuthBasicMethod) Filter

func (this *HTTPAuthBasicMethod) Filter(req *http.Request, doSubReq func(subReq *http.Request) (status int, err error), formatter func(string) string) (ok bool, newURI string, uriChanged bool, err error)

func (*HTTPAuthBasicMethod) Init

func (this *HTTPAuthBasicMethod) Init(params map[string]any) error

type HTTPAuthBasicMethodUser

type HTTPAuthBasicMethodUser struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

HTTPAuthBasicMethodUser BasicAuth中的用户

func (*HTTPAuthBasicMethodUser) Validate

func (this *HTTPAuthBasicMethodUser) Validate(password string) (bool, error)

type HTTPAuthConfig

type HTTPAuthConfig struct {
	IsPrior    bool                 `yaml:"isPrior" json:"isPrior"`
	IsOn       bool                 `yaml:"isOn" json:"isOn"`
	PolicyRefs []*HTTPAuthPolicyRef `yaml:"policyRefs" json:"policyRefs"`
}

HTTPAuthConfig 认证配置

func (*HTTPAuthConfig) Init

func (this *HTTPAuthConfig) Init() error

type HTTPAuthMethodInterface

type HTTPAuthMethodInterface interface {
	// Init 初始化
	Init(params map[string]any) error

	// MatchRequest 是否匹配请求
	MatchRequest(req *http.Request) bool

	// Filter 过滤
	Filter(req *http.Request, subReqFunc func(subReq *http.Request) (status int, err error), formatter func(string) string) (ok bool, newURI string, uriChanged bool, err error)

	// SetExts 设置扩展名
	SetExts(exts []string)

	// SetDomains 设置域名
	SetDomains(domains []string)
}

HTTPAuthMethodInterface HTTP认证接口定义

type HTTPAuthPolicy

type HTTPAuthPolicy struct {
	Id     int64                  `json:"id"`
	Name   string                 `json:"name"`
	IsOn   bool                   `json:"isOn"`
	Type   HTTPAuthType           `json:"type"`
	Params map[string]interface{} `json:"params"`
	// contains filtered or unexported fields
}

HTTPAuthPolicy HTTP认证策略

func (*HTTPAuthPolicy) Filter

func (this *HTTPAuthPolicy) Filter(req *http.Request, subReqFunc func(subReq *http.Request) (status int, err error), formatter func(string) string) (ok bool, newURI string, uriChanged bool, err error)

Filter 过滤

func (*HTTPAuthPolicy) Init

func (this *HTTPAuthPolicy) Init() error

Init 初始化

func (*HTTPAuthPolicy) MatchRequest added in v0.5.2

func (this *HTTPAuthPolicy) MatchRequest(req *http.Request) bool

MatchRequest 检查是否匹配请求

func (*HTTPAuthPolicy) Method

func (this *HTTPAuthPolicy) Method() HTTPAuthMethodInterface

Method 获取认证实例

type HTTPAuthPolicyRef

type HTTPAuthPolicyRef struct {
	IsOn         bool            `yaml:"isOn" json:"isOn"`
	AuthPolicyId int64           `yaml:"authPolicyId" json:"authPolicyId"`
	AuthPolicy   *HTTPAuthPolicy `yaml:"authPolicy" json:"authPolicy"`
}

HTTPAuthPolicyRef 认证策略引用

func (*HTTPAuthPolicyRef) Init

func (this *HTTPAuthPolicyRef) Init() error

type HTTPAuthSubRequestMethod

type HTTPAuthSubRequestMethod struct {
	HTTPAuthBaseMethod

	URL    string `json:"url"`
	Method string `json:"method"`
	// contains filtered or unexported fields
}

HTTPAuthSubRequestMethod 使用URL认证

func NewHTTPAuthSubRequestMethod

func NewHTTPAuthSubRequestMethod() *HTTPAuthSubRequestMethod

func (*HTTPAuthSubRequestMethod) Filter

func (this *HTTPAuthSubRequestMethod) Filter(req *http.Request, doSubReq func(subReq *http.Request) (status int, err error), formatter func(string) string) (ok bool, newURI string, uriChanged bool, err error)

Filter 过滤

func (*HTTPAuthSubRequestMethod) Init

func (this *HTTPAuthSubRequestMethod) Init(params map[string]any) error

Init 初始化

type HTTPAuthType

type HTTPAuthType = string
const (
	HTTPAuthTypeBasicAuth  HTTPAuthType = "basicAuth"  // BasicAuth
	HTTPAuthTypeSubRequest HTTPAuthType = "subRequest" // 子请求
)

type HTTPAuthTypeDefinition

type HTTPAuthTypeDefinition struct {
	Name        string `json:"name"`
	Code        string `json:"code"`
	Description string `json:"description"`
}

func FindAllHTTPAuthTypes

func FindAllHTTPAuthTypes(role string) []*HTTPAuthTypeDefinition

type HTTPBrotliCompressionConfig

type HTTPBrotliCompressionConfig struct {
	Id   int64 `yaml:"id" json:"id"` // ID
	IsOn bool  `yaml:"isOn" json:"isOn"`

	Level     int8                           `yaml:"level" json:"level"`         // 级别
	MinLength *shared.SizeCapacity           `yaml:"minLength" json:"minLength"` // 最小压缩对象比如4m, 24k
	MaxLength *shared.SizeCapacity           `yaml:"maxLength" json:"maxLength"` // 最大压缩对象
	Conds     *shared.HTTPRequestCondsConfig `yaml:"conds" json:"conds"`         // 匹配条件
	// contains filtered or unexported fields
}

func (*HTTPBrotliCompressionConfig) Init

func (this *HTTPBrotliCompressionConfig) Init() error

type HTTPCCConfig added in v0.6.4

type HTTPCCConfig struct {
	IsPrior bool `yaml:"isPrior" json:"isPrior"` // 是否覆盖父级
	IsOn    bool `yaml:"isOn" json:"isOn"`       // 是否启用
}

HTTPCCConfig HTTP CC防护配置

func DefaultHTTPCCConfig added in v1.0.0

func DefaultHTTPCCConfig() *HTTPCCConfig

DefaultHTTPCCConfig 默认的CC配置

func NewHTTPCCConfig added in v0.6.4

func NewHTTPCCConfig() *HTTPCCConfig

func (*HTTPCCConfig) Init added in v0.6.4

func (this *HTTPCCConfig) Init() error

func (*HTTPCCConfig) MatchURL added in v0.6.4

func (this *HTTPCCConfig) MatchURL(url string) bool

type HTTPCCThreshold added in v1.1.0

type HTTPCCThreshold struct {
}

func NewHTTPCCThreshold added in v1.1.0

func NewHTTPCCThreshold() *HTTPCCThreshold

func (*HTTPCCThreshold) Clone added in v1.1.0

func (this *HTTPCCThreshold) Clone() *HTTPCCThreshold

func (*HTTPCCThreshold) Merge added in v1.1.0

func (this *HTTPCCThreshold) Merge(threshold *HTTPCCThreshold)

func (*HTTPCCThreshold) MergeIfEmpty added in v1.1.0

func (this *HTTPCCThreshold) MergeIfEmpty(threshold *HTTPCCThreshold)

type HTTPCSSOptimizationConfig added in v1.2.1

type HTTPCSSOptimizationConfig struct {
	IsOn bool `yaml:"isOn" json:"isOn"`

	Precision int  `yaml:"precision" json:"precision"`
	KeepCSS2  bool `yaml:"keepCSS2" json:"keepCSS2"`
}

func NewHTTPCSSOptimizationConfig added in v1.2.1

func NewHTTPCSSOptimizationConfig() *HTTPCSSOptimizationConfig

func (*HTTPCSSOptimizationConfig) AsMinifier added in v1.2.1

func (this *HTTPCSSOptimizationConfig) AsMinifier() *css.Minifier

func (*HTTPCSSOptimizationConfig) Init added in v1.2.1

func (this *HTTPCSSOptimizationConfig) Init() error

type HTTPCacheConfig

type HTTPCacheConfig struct {
	IsPrior bool `yaml:"isPrior" json:"isPrior"`
	IsOn    bool `yaml:"isOn" json:"isOn"`

	AddStatusHeader          bool `yaml:"addStatusHeader" json:"addStatusHeader"`                   // 是否增加命中状态Header(X-Cache)
	AddAgeHeader             bool `yaml:"addAgeHeader" json:"addAgeHeader"`                         // 是否增加Age Header
	EnableCacheControlMaxAge bool `yaml:"enableCacheControlMaxAge" json:"enableCacheControlMaxAge"` // 是否支持Cache-Control: max-age=...
	DisablePolicyRefs        bool `yaml:"disablePolicyRefs" json:"disablePolicyRefs"`               // 是否停用策略中定义的条件

	PurgeIsOn bool   `yaml:"purgeIsOn" json:"purgeIsOn"` // 是否允许使用Purge方法清理
	PurgeKey  string `yaml:"purgeKey" json:"purgeKey"`   // Purge时使用的X-Edge-Purge-Key

	Stale *HTTPCacheStaleConfig `yaml:"stale" json:"stale"` // 陈旧缓存使用策略

	CacheRefs []*HTTPCacheRef `yaml:"cacheRefs" json:"cacheRefs"` // 缓存条件配置
}

func (*HTTPCacheConfig) AsJSON

func (this *HTTPCacheConfig) AsJSON() ([]byte, error)

func (*HTTPCacheConfig) Init

func (this *HTTPCacheConfig) Init() error

type HTTPCachePolicy

type HTTPCachePolicy struct {
	Id                   int64                  `yaml:"id" json:"id"`
	IsOn                 bool                   `yaml:"isOn" json:"isOn"`                                 // 是否开启
	Name                 string                 `yaml:"name" json:"name"`                                 // 名称
	Description          string                 `yaml:"description" json:"description"`                   // 描述
	Capacity             *shared.SizeCapacity   `yaml:"capacity" json:"capacity"`                         // 最大内容容量
	MaxSize              *shared.SizeCapacity   `yaml:"maxSize" json:"maxSize"`                           // 单个缓存最大尺寸
	Type                 CachePolicyStorageType `yaml:"type" json:"type"`                                 // 类型
	Options              map[string]interface{} `yaml:"options" json:"options"`                           // 选项
	Life                 *shared.TimeDuration   `yaml:"life" json:"life"`                                 // 默认有效期 TODO 需要实现
	MinLife              *shared.TimeDuration   `yaml:"minLife" json:"minLife"`                           // 最小有效期 TODO 需要实现
	MaxLife              *shared.TimeDuration   `yaml:"maxLife" json:"maxLife"`                           // 最大有效期 TODO 需要实现
	SyncCompressionCache bool                   `yaml:"syncCompressionCache" json:"syncCompressionCache"` // 同步写入压缩缓存

	CacheRefs []*HTTPCacheRef `yaml:"cacheRefs" json:"cacheRefs"` // 缓存配置

	PersistenceAutoPurgeCount    int     `yaml:"persistenceAutoPurgeCount" json:"persistenceAutoPurgeCount"`       // 每次自动清理的条数 TODO 需要实现
	PersistenceAutoPurgeInterval int     `yaml:"persistenceAutoPurgeInterval" json:"persistenceAutoPurgeInterval"` // 自动清理的时间间隔(秒) TODO 需要实现
	PersistenceLFUFreePercent    float32 `yaml:"persistenceLFUFreePercent" json:"persistenceLFUFreePercent"`       // LFU算法执行阈值,剩余空间比例,使用百分比,比如20 TODO 需要实现
	PersistenceHitSampleRate     int     `yaml:"persistenceHitSampleRate" json:"persistenceHitSampleRate"`         // 热点数据采样比例 TODO 需要实现

	MemoryAutoPurgeCount     int     `yaml:"memoryAutoPurgeCount" json:"memoryAutoPurgeCount"`         // 每次自动清理的条数 TODO 需要实现
	MemoryAutoPurgeInterval  int     `yaml:"memoryAutoPurgeInterval" json:"memoryAutoPurgeInterval"`   // 自动清理的时间间隔(秒) TODO 需要实现
	MemoryLFUFreePercent     float32 `yaml:"memoryLFUFreePercent" json:"memoryLFUFreePercent"`         // LFU算法执行阈值,剩余空间比例,使用百分比,比如20 TODO 需要实现
	MemoryAutoFlushQueueSize int     `yaml:"memoryAutoFlushQueueSize" json:"memoryAutoFlushQueueSize"` // 自动刷新到持久层队列尺寸 TODO 需要实现
	// contains filtered or unexported fields
}

HTTPCachePolicy 缓存策略配置

func (*HTTPCachePolicy) CapacityBytes

func (this *HTTPCachePolicy) CapacityBytes() int64

CapacityBytes 容量

func (*HTTPCachePolicy) Init

func (this *HTTPCachePolicy) Init() error

Init 校验

func (*HTTPCachePolicy) IsSame

func (this *HTTPCachePolicy) IsSame(anotherPolicy *HTTPCachePolicy) bool

IsSame 对比Policy是否有变化

func (*HTTPCachePolicy) MaxSizeBytes

func (this *HTTPCachePolicy) MaxSizeBytes() int64

MaxSizeBytes 单个缓存最大尺寸

func (*HTTPCachePolicy) UpdateDiskDir

func (this *HTTPCachePolicy) UpdateDiskDir(dir string, subDirs []*CacheDir)

UpdateDiskDir 修改文件路径

type HTTPCacheRef

type HTTPCacheRef struct {
	IsOn          bool  `yaml:"isOn" json:"isOn"`
	CachePolicyId int64 `yaml:"cachePolicyId" json:"cachePolicyId"`

	Key         string                 `yaml:"key" json:"key"`                 // 每个缓存的Key规则,里面可以有变量
	Life        *shared.TimeDuration   `yaml:"life" json:"life"`               // 时间
	ExpiresTime *HTTPExpiresTimeConfig `yaml:"expiresTime" json:"expiresTime"` // 客户端过期时间
	Status      []int                  `yaml:"status" json:"status"`           // 缓存的状态码列表
	MinSize     *shared.SizeCapacity   `yaml:"minSize" json:"minSize"`         // 能够缓存的最小尺寸
	MaxSize     *shared.SizeCapacity   `yaml:"maxSize" json:"maxSize"`         // 能够缓存的最大尺寸
	Methods     []string               `yaml:"methods" json:"methods"`         // 支持的请求方法

	SkipResponseCacheControlValues []string `yaml:"skipCacheControlValues" json:"skipCacheControlValues"`     // 可以跳过的响应的Cache-Control值
	SkipResponseSetCookie          bool     `yaml:"skipSetCookie" json:"skipSetCookie"`                       // 是否跳过响应的Set-Cookie Header
	EnableRequestCachePragma       bool     `yaml:"enableRequestCachePragma" json:"enableRequestCachePragma"` // 是否支持客户端的Pragma: no-cache
	AllowChunkedEncoding           bool     `yaml:"allowChunkedEncoding" json:"allowChunkedEncoding"`         // 是否允许分片内容
	AllowPartialContent            bool     `yaml:"allowPartialContent" json:"allowPartialContent"`           // 支持分段内容缓存
	ForcePartialContent            bool     `yaml:"forcePartialContent" json:"forcePartialContent"`           // 强制分段内容优先
	EnableIfNoneMatch              bool     `yaml:"enableIfNoneMatch" json:"enableIfNoneMatch"`
	EnableIfModifiedSince          bool     `yaml:"enableIfModifiedSince" json:"enableIfModifiedSince"`

	Conds      *shared.HTTPRequestCondsConfig `yaml:"conds" json:"conds"`           // 复杂请求条件组合
	SimpleCond *shared.HTTPRequestCond        `yaml:"simpleCond" json:"simpleCond"` // 简单条件

	CachePolicy *HTTPCachePolicy `yaml:"cachePolicy" json:"cachePolicy"`

	IsReverse bool `yaml:"isReverse" json:"isReverse"` // 是否为反向条件,反向条件的不缓存
	// contains filtered or unexported fields
}

func (*HTTPCacheRef) ContainsCacheControl

func (this *HTTPCacheRef) ContainsCacheControl(value string) bool

ContainsCacheControl 是否包含某个Cache-Control值

func (*HTTPCacheRef) Init

func (this *HTTPCacheRef) Init() error

func (*HTTPCacheRef) LifeSeconds

func (this *HTTPCacheRef) LifeSeconds() int64

LifeSeconds 生命周期

func (*HTTPCacheRef) MatchRequest

func (this *HTTPCacheRef) MatchRequest(req *http.Request) bool

MatchRequest 匹配请求

func (*HTTPCacheRef) MatchStatus

func (this *HTTPCacheRef) MatchStatus(statusCode int) bool

MatchStatus 检查是否包含某个状态码

func (*HTTPCacheRef) MaxSizeBytes

func (this *HTTPCacheRef) MaxSizeBytes() int64

MaxSizeBytes 最大数据尺寸

func (*HTTPCacheRef) MinSizeBytes

func (this *HTTPCacheRef) MinSizeBytes() int64

MinSizeBytes 最小数据尺寸

type HTTPCacheStaleConfig

type HTTPCacheStaleConfig struct {
	IsPrior bool `yaml:"isPrior" json:"isPrior"`
	IsOn    bool `yaml:"isOn" json:"isOn"` // 是否启用

	Status                    []int                `yaml:"status" json:"status"`                                       // 状态列表
	SupportStaleIfErrorHeader bool                 `yaml:"supportStaleIfErrorHeader" json:"supportStaleIfErrorHeader"` // 是否支持stale-if-error
	Life                      *shared.TimeDuration `yaml:"life" json:"life"`                                           // 陈旧内容生命周期
}

HTTPCacheStaleConfig Stale策略配置

type HTTPCharsetConfig

type HTTPCharsetConfig struct {
	IsPrior bool   `yaml:"isPrior" json:"isPrior"` // 是否覆盖
	IsOn    bool   `yaml:"isOn" json:"isOn"`       // 是否启用
	Charset string `yaml:"charset" json:"charset"` // 字符集
	IsUpper bool   `yaml:"isUpper" json:"isUpper"` // 是否要大写

}

字符集设置

func (*HTTPCharsetConfig) Init

func (this *HTTPCharsetConfig) Init() error

初始化

type HTTPCompressionConfig

type HTTPCompressionConfig struct {
	IsPrior bool `yaml:"isPrior" json:"isPrior"`
	IsOn    bool `yaml:"isOn" json:"isOn"`

	UseDefaultTypes bool                  `yaml:"useDefaultTypes" json:"useDefaultTypes"` // 是否使用默认的类型
	Types           []HTTPCompressionType `yaml:"types" json:"types"`                     // 支持的类型,如果为空表示默认顺序
	Level           int8                  `yaml:"level" json:"level"`                     // 级别:1-12
	DecompressData  bool                  `yaml:"decompressData" json:"decompressData"`   // 是否解压已压缩内容

	GzipRef    *HTTPCompressionRef `yaml:"gzipRef" json:"gzipRef"`
	DeflateRef *HTTPCompressionRef `yaml:"deflateRef" json:"deflateRef"`
	BrotliRef  *HTTPCompressionRef `yaml:"brotliRef" json:"brotliRef"`

	Gzip    *HTTPGzipCompressionConfig    `yaml:"gzip" json:"gzip"`
	Deflate *HTTPDeflateCompressionConfig `yaml:"deflate" json:"deflate"`
	Brotli  *HTTPBrotliCompressionConfig  `yaml:"brotli" json:"brotli"`

	MinLength            *shared.SizeCapacity           `yaml:"minLength" json:"minLength"`                       // 最小压缩对象比如4m, 24k
	MaxLength            *shared.SizeCapacity           `yaml:"maxLength" json:"maxLength"`                       // 最大压缩对象
	MimeTypes            []string                       `yaml:"mimeTypes" json:"mimeTypes"`                       // 支持的MimeType,支持image/*这样的通配符使用
	Extensions           []string                       `yaml:"extensions" json:"extensions"`                     // 文件扩展名,包含点符号,不区分大小写
	ExceptExtensions     []string                       `yaml:"exceptExtensions" json:"exceptExtensions"`         // 例外扩展名
	Conds                *shared.HTTPRequestCondsConfig `yaml:"conds" json:"conds"`                               // 匹配条件
	EnablePartialContent bool                           `yaml:"enablePartialContent" json:"enablePartialContent"` // 支持PartialContent压缩
	// contains filtered or unexported fields
}

HTTPCompressionConfig 内容压缩配置

func (*HTTPCompressionConfig) Init

func (this *HTTPCompressionConfig) Init() error

Init 初始化

func (*HTTPCompressionConfig) MatchAcceptEncoding

func (this *HTTPCompressionConfig) MatchAcceptEncoding(acceptEncodings string) (compressionType HTTPCompressionType, compressionEncoding string, ok bool)

MatchAcceptEncoding 根据Accept-Encoding选择优先的压缩方式

func (*HTTPCompressionConfig) MatchResponse

func (this *HTTPCompressionConfig) MatchResponse(mimeType string, contentLength int64, requestExt string, formatter shared.Formatter) bool

MatchResponse 是否匹配响应

func (*HTTPCompressionConfig) MaxBytes

func (this *HTTPCompressionConfig) MaxBytes() int64

MaxBytes 可压缩最大尺寸

func (*HTTPCompressionConfig) MinBytes

func (this *HTTPCompressionConfig) MinBytes() int64

MinBytes 可压缩最小尺寸

type HTTPCompressionRef

type HTTPCompressionRef struct {
	Id   int64 `yaml:"id" json:"id"`
	IsOn bool  `yaml:"isOn" json:"isOn"`
}

type HTTPCompressionType

type HTTPCompressionType = string
const (
	HTTPCompressionTypeGzip    HTTPCompressionType = "gzip"
	HTTPCompressionTypeDeflate HTTPCompressionType = "deflate"
	HTTPCompressionTypeBrotli  HTTPCompressionType = "brotli"
	HTTPCompressionTypeZSTD    HTTPCompressionType = "zstd"
)

type HTTPDeflateCompressionConfig

type HTTPDeflateCompressionConfig struct {
	Id   int64 `yaml:"id" json:"id"` // ID
	IsOn bool  `yaml:"isOn" json:"isOn"`

	Level     int8                           `yaml:"level" json:"level"`         // 级别
	MinLength *shared.SizeCapacity           `yaml:"minLength" json:"minLength"` // 最小压缩对象比如4m, 24k
	MaxLength *shared.SizeCapacity           `yaml:"maxLength" json:"maxLength"` // 最大压缩对象
	Conds     *shared.HTTPRequestCondsConfig `yaml:"conds" json:"conds"`         // 匹配条件
	// contains filtered or unexported fields
}

func (*HTTPDeflateCompressionConfig) Init

func (this *HTTPDeflateCompressionConfig) Init() error

type HTTPExpiresTimeConfig

type HTTPExpiresTimeConfig struct {
	IsPrior       bool                 `yaml:"isPrior" json:"isPrior"`             // 是否覆盖父级设置
	IsOn          bool                 `yaml:"isOn" json:"isOn"`                   // 是否启用
	Overwrite     bool                 `yaml:"overwrite" json:"overwrite"`         // 是否覆盖
	AutoCalculate bool                 `yaml:"autoCalculate" json:"autoCalculate"` // 是否自动计算
	Duration      *shared.TimeDuration `yaml:"duration" json:"duration"`           // 周期
}

HTTPExpiresTimeConfig 发送到客户端的过期时间设置

type HTTPFastcgiConfig

type HTTPFastcgiConfig struct {
	Id   int64 `yaml:"id" json:"id"`
	IsOn bool  `yaml:"isOn" json:"isOn"`

	// fastcgi地址配置
	// 支持unix:/tmp/php-fpm.sock ...
	Address string `yaml:"address" json:"address"`

	Index           string               `yaml:"index" json:"index"`                     // @TODO
	Params          []*HTTPFastcgiParam  `yaml:"params" json:"params"`                   // 参数
	ReadTimeout     *shared.TimeDuration `yaml:"readTimeout" json:"readTimeout"`         // @TODO 读取超时时间
	SendTimeout     *shared.TimeDuration `yaml:"sendTimeout" json:"sendTimeout"`         // @TODO 发送超时时间
	ConnTimeout     *shared.TimeDuration `yaml:"connTimeout" json:"connTimeout"`         // @TODO 连接超时时间
	Weight          int                  `yaml:"weight" json:"weight"`                   // TODO 权重
	PoolSize        int                  `yaml:"poolSize" json:"poolSize"`               // 连接池尺寸
	PathInfoPattern string               `yaml:"pathInfoPattern" json:"pathInfoPattern"` // PATH_INFO匹配正则
	// contains filtered or unexported fields
}

HTTPFastcgiConfig Fastcgi配置

func (*HTTPFastcgiConfig) FilterParams

func (this *HTTPFastcgiConfig) FilterParams() maps.Map

FilterParams 过滤参数

func (*HTTPFastcgiConfig) Init

func (this *HTTPFastcgiConfig) Init() error

Init 初始化

func (*HTTPFastcgiConfig) Network

func (this *HTTPFastcgiConfig) Network() string

Network 网络协议

func (*HTTPFastcgiConfig) Param

func (this *HTTPFastcgiConfig) Param(paramName string) string

Param 读取参数

func (*HTTPFastcgiConfig) PathInfoRegexp

func (this *HTTPFastcgiConfig) PathInfoRegexp() *regexp.Regexp

PathInfoRegexp PATH_INFO正则

func (*HTTPFastcgiConfig) ReadTimeoutDuration

func (this *HTTPFastcgiConfig) ReadTimeoutDuration() time.Duration

ReadTimeoutDuration 超时时间

func (*HTTPFastcgiConfig) RealAddress

func (this *HTTPFastcgiConfig) RealAddress() string

RealAddress 网络地址

type HTTPFastcgiParam

type HTTPFastcgiParam struct {
	Name  string `yaml:"name" json:"name"`
	Value string `yaml:"value" json:"value"`
}

HTTPFastcgiParam Fastcgi参数

type HTTPFastcgiRef

type HTTPFastcgiRef struct {
	IsPrior    bool    `yaml:"isPrior" json:"isPrior"`       // 是否覆盖
	IsOn       bool    `yaml:"isOn" json:"isOn"`             // 是否开启
	FastcgiIds []int64 `yaml:"fastcgiIds" json:"fastcgiIds"` // Fastcgi ID列表
}

type HTTPFileCacheStorage

type HTTPFileCacheStorage struct {
	Dir          string           `yaml:"dir" json:"dir"`                   // 目录
	SubDirs      []*CacheDir      `yaml:"cacheDir" json:"subDirs"`          // 子目录
	MemoryPolicy *HTTPCachePolicy `yaml:"memoryPolicy" json:"memoryPolicy"` // 内存二级缓存

	OpenFileCache  *OpenFileCacheConfig `yaml:"openFileCache" json:"openFileCache"`   // open file cache配置
	EnableSendfile bool                 `yaml:"enableSendFile" json:"enableSendfile"` // 是否启用Sendfile
}

HTTPFileCacheStorage 文件缓存存储策略

func (*HTTPFileCacheStorage) Init

func (this *HTTPFileCacheStorage) Init() error

type HTTPFilterPolicy

type HTTPFilterPolicy struct {
}

func (*HTTPFilterPolicy) Init

func (this *HTTPFilterPolicy) Init() error

type HTTPFilterRef

type HTTPFilterRef struct {
	IsPrior        bool  `yaml:"isPrior" json:"isPrior"`
	IsOn           bool  `yaml:"isOn" json:"isOn"`
	FilterPolicyId int64 `yaml:"filterPolicyId" json:"filterPolicyId"`
}

func (*HTTPFilterRef) Init

func (this *HTTPFilterRef) Init() error

type HTTPGzipCompressionConfig

type HTTPGzipCompressionConfig struct {
	Id        int64                          `yaml:"id" json:"id"`               // ID
	IsOn      bool                           `yaml:"isOn" json:"isOn"`           // 是否启用
	Level     int8                           `yaml:"level" json:"level"`         // 1-9
	MinLength *shared.SizeCapacity           `yaml:"minLength" json:"minLength"` // 最小压缩对象比如4m, 24k
	MaxLength *shared.SizeCapacity           `yaml:"maxLength" json:"maxLength"` // 最大压缩对象
	Conds     *shared.HTTPRequestCondsConfig `yaml:"conds" json:"conds"`         // 匹配条件
	// contains filtered or unexported fields
}

HTTPGzipCompressionConfig gzip配置

func (*HTTPGzipCompressionConfig) Init

func (this *HTTPGzipCompressionConfig) Init() error

Init 校验

func (*HTTPGzipCompressionConfig) MaxBytes

func (this *HTTPGzipCompressionConfig) MaxBytes() int64

MaxBytes 可压缩最大尺寸

func (*HTTPGzipCompressionConfig) MinBytes

func (this *HTTPGzipCompressionConfig) MinBytes() int64

MinBytes 可压缩最小尺寸

type HTTPGzipRef

type HTTPGzipRef struct {
	IsPrior bool  `yaml:"isPrior" json:"isPrior"` // 是否覆盖
	IsOn    bool  `yaml:"isOn" json:"isOn"`       // 是否开启
	GzipId  int64 `yaml:"gzipId" json:"gzipId"`   // 使用的配置ID
}

type HTTPHTMLOptimizationConfig added in v1.2.1

type HTTPHTMLOptimizationConfig struct {
	IsOn bool `yaml:"isOn" json:"isOn"`

	KeepComments            bool `yaml:"keepComments" json:"keepComments"`
	KeepConditionalComments bool `yaml:"keepConditionalComments" json:"keepConditionalComments"`
	KeepDefaultAttrVals     bool `yaml:"keepDefaultAttrVals" json:"keepDefaultAttrVals"`
	KeepDocumentTags        bool `yaml:"keepDocumentTags" json:"keepDocumentTags"`
	KeepEndTags             bool `yaml:"keepEndTags" json:"keepEndTags"`
	KeepQuotes              bool `yaml:"keepQuotes" json:"keepQuotes"`
	KeepWhitespace          bool `yaml:"keepWhitespace" json:"keepWhitespace"`
}

func NewHTTPHTMLOptimizationConfig added in v1.2.1

func NewHTTPHTMLOptimizationConfig() *HTTPHTMLOptimizationConfig

func (*HTTPHTMLOptimizationConfig) AsMinifier added in v1.2.1

func (this *HTTPHTMLOptimizationConfig) AsMinifier() *html.Minifier

func (*HTTPHTMLOptimizationConfig) Init added in v1.2.1

func (this *HTTPHTMLOptimizationConfig) Init() error

type HTTPHostRedirectConfig

type HTTPHostRedirectConfig struct {
	IsOn   bool `yaml:"isOn" json:"isOn"`     // 是否开启
	Status int  `yaml:"status" json:"status"` // 跳转用的状态码

	Type string               `yaml:"type" json:"type"` // 类型
	Mode HTTPHostRedirectType `yaml:"mode" json:"mode"` // 模式

	// URL跳转
	BeforeURL string `yaml:"beforeURL" json:"beforeURL"` // 跳转前的地址
	AfterURL  string `yaml:"afterURL" json:"afterURL"`   // 跳转后的地址

	MatchPrefix bool `yaml:"matchPrefix" json:"matchPrefix"` // 只匹配前缀部分
	MatchRegexp bool `yaml:"matchRegexp" json:"matchRegexp"` // 匹配正则表达式

	KeepRequestURI bool                           `yaml:"keepRequestURI" json:"keepRequestURI"` // 保留请求URI
	KeepArgs       bool                           `yaml:"keepArgs" json:"keepArgs"`             // 保留参数
	Conds          *shared.HTTPRequestCondsConfig `yaml:"conds" json:"conds"`                   // 匹配条件

	// 域名跳转
	DomainsAll              bool     `yaml:"domainAll" json:"domainsAll"`                            // 所有域名都跳转
	DomainsBefore           []string `yaml:"domainsBefore" json:"domainsBefore"`                     // 指定跳转之前的域名
	DomainBeforeIgnorePorts bool     `yaml:"domainBeforeIgnorePorts" json:"domainBeforeIgnorePorts"` // 忽略跳转前端口
	DomainAfter             string   `yaml:"domainAfter" json:"domainAfter"`                         // 跳转之后的域名
	DomainAfterScheme       string   `yaml:"domainAfterScheme" json:"domainAfterScheme"`             // 跳转之后的协议

	// 端口跳转
	PortsAll        bool     `yaml:"portsAll" json:"portsAll"`               // 所有端口
	PortsBefore     []string `yaml:"portsBefore" json:"portsBefore"`         // 跳转之前的端口:8080, 8080-8090
	PortAfter       int      `yaml:"port" json:"portAfter"`                  // 跳转之后的端口
	PortAfterScheme string   `yaml:"portAfterScheme" json:"portAfterScheme"` // 跳转之后的协议
	// contains filtered or unexported fields
}

HTTPHostRedirectConfig 主机名跳转设置

func (*HTTPHostRedirectConfig) BeforeHasQuery added in v1.1.0

func (this *HTTPHostRedirectConfig) BeforeHasQuery() bool

BeforeHasQuery 判断跳转前URL是否有查询参数

func (*HTTPHostRedirectConfig) BeforeURLRegexp

func (this *HTTPHostRedirectConfig) BeforeURLRegexp() *regexp.Regexp

BeforeURLRegexp 跳转前URL正则表达式

func (*HTTPHostRedirectConfig) ContainsPort added in v0.5.6

func (this *HTTPHostRedirectConfig) ContainsPort(reqPort int) bool

ContainsPort 是否包含端口

func (*HTTPHostRedirectConfig) Init

func (this *HTTPHostRedirectConfig) Init() error

Init 初始化

func (*HTTPHostRedirectConfig) MatchRequest

func (this *HTTPHostRedirectConfig) MatchRequest(formatter func(source string) string) bool

MatchRequest 判断请求是否符合条件

func (*HTTPHostRedirectConfig) RealBeforeURL

func (this *HTTPHostRedirectConfig) RealBeforeURL() string

RealBeforeURL 跳转前URL

type HTTPHostRedirectType added in v0.5.6

type HTTPHostRedirectType = string
const (
	HTTPHostRedirectTypeURL    HTTPHostRedirectType = "url"
	HTTPHostRedirectTypeDomain HTTPHostRedirectType = "domain"
	HTTPHostRedirectTypePort   HTTPHostRedirectType = "port"
)

type HTTPJavascriptOptimizationConfig added in v1.2.1

type HTTPJavascriptOptimizationConfig struct {
	IsOn bool `yaml:"isOn" json:"isOn"`

	Precision    int  `yaml:"precision" json:"precision"`
	Version      int  `yaml:"version" json:"version"`
	KeepVarNames bool `yaml:"keepVarNames" json:"keepVarNames"`
}

func NewHTTPJavascriptOptimizationConfig added in v1.2.1

func NewHTTPJavascriptOptimizationConfig() *HTTPJavascriptOptimizationConfig

func (*HTTPJavascriptOptimizationConfig) AsMinifier added in v1.2.1

func (this *HTTPJavascriptOptimizationConfig) AsMinifier() *js.Minifier

func (*HTTPJavascriptOptimizationConfig) Init added in v1.2.1

type HTTPLocationConfig

type HTTPLocationConfig struct {
	Id              int64                          `yaml:"id" json:"id"`                           // ID
	IsOn            bool                           `yaml:"isOn" json:"isOn"`                       // 是否启用
	Pattern         string                         `yaml:"pattern" json:"pattern"`                 // 匹配规则 TODO 未来支持更多样的匹配规则
	Name            string                         `yaml:"name" json:"name"`                       // 名称
	Web             *HTTPWebConfig                 `yaml:"web" json:"web"`                         // Web配置
	URLPrefix       string                         `yaml:"urlPrefix" json:"urlPrefix"`             // 实际的URL前缀,TODO 未来支持变量
	Description     string                         `yaml:"description" json:"description"`         // 描述
	ReverseProxyRef *ReverseProxyRef               `yaml:"reverseProxyRef" json:"reverseProxyRef"` // 反向代理引用
	ReverseProxy    *ReverseProxyConfig            `yaml:"reverseProxy" json:"reverseProxy"`       // 反向代理设置
	IsBreak         bool                           `yaml:"isBreak" json:"isBreak"`                 // 终止向下解析
	Children        []*HTTPLocationConfig          `yaml:"children" json:"children"`               // 子规则
	Conds           *shared.HTTPRequestCondsConfig `yaml:"conds" json:"conds"`                     // 匹配条件
	Domains         []string                       `yaml:"domains" json:"domains"`                 // 所属域名
	// contains filtered or unexported fields
}

func (*HTTPLocationConfig) ExtractPattern

func (this *HTTPLocationConfig) ExtractPattern() error

ExtractPattern 分析匹配条件

func (*HTTPLocationConfig) Init

func (this *HTTPLocationConfig) Init(ctx context.Context) error

func (*HTTPLocationConfig) IsCaseInsensitive

func (this *HTTPLocationConfig) IsCaseInsensitive() bool

IsCaseInsensitive 是否大小写非敏感

func (*HTTPLocationConfig) IsReverse

func (this *HTTPLocationConfig) IsReverse() bool

IsReverse 是否翻转

func (*HTTPLocationConfig) Match

func (this *HTTPLocationConfig) Match(path string, formatter func(source string) string) (vars map[string]string, isMatched bool)

Match 判断是否匹配路径 TODO 支持子Location

func (*HTTPLocationConfig) PatternString

func (this *HTTPLocationConfig) PatternString() string

PatternString 模式字符串 去掉了模式字符

func (*HTTPLocationConfig) PatternType

func (this *HTTPLocationConfig) PatternType() int

PatternType 模式类型

func (*HTTPLocationConfig) SetPattern

func (this *HTTPLocationConfig) SetPattern(pattern string, patternType int, caseInsensitive bool, reverse bool)

SetPattern 组合参数为一个字符串

type HTTPLocationPatternType

type HTTPLocationPatternType = int

HTTPLocationPatternType 匹配类型

const (
	HTTPLocationPatternTypePrefix HTTPLocationPatternType = 1
	HTTPLocationPatternTypeSuffix HTTPLocationPatternType = 4
	HTTPLocationPatternTypeExact  HTTPLocationPatternType = 2
	HTTPLocationPatternTypeRegexp HTTPLocationPatternType = 3
)

内置的匹配类型定义

type HTTPLocationRef

type HTTPLocationRef struct {
	IsOn       bool               `yaml:"isOn" json:"isOn"`             // 是否启用
	LocationId int64              `yaml:"locationId" json:"locationId"` // 路径ID
	Children   []*HTTPLocationRef `yaml:"children" json:"children"`     // 子路径规则
}

type HTTPMemoryCacheStorage

type HTTPMemoryCacheStorage struct {
}

func (*HTTPMemoryCacheStorage) Init

func (this *HTTPMemoryCacheStorage) Init() error

type HTTPPageConfig

type HTTPPageConfig struct {
	Id        int64    `yaml:"id" json:"id"`               // 页面ID
	IsOn      bool     `yaml:"isOn" json:"isOn"`           // 是否开启 TODO
	Status    []string `yaml:"status" json:"status"`       // 响应支持40x, 50x, 3x2
	NewStatus int      `yaml:"newStatus" json:"newStatus"` // 新状态码

	BodyType shared.BodyType `yaml:"bodyType" json:"bodyType"` // 内容类型
	URL      string          `yaml:"url" json:"url"`           // URL
	Body     string          `yaml:"body" json:"body"`         // 输出的内容
	// contains filtered or unexported fields
}

HTTPPageConfig 特殊页面配置 TODO 需要支持Header定义

func NewHTTPPageConfig

func NewHTTPPageConfig() *HTTPPageConfig

NewHTTPPageConfig 获取新对象

func (*HTTPPageConfig) Init

func (this *HTTPPageConfig) Init() error

Init 校验

func (*HTTPPageConfig) Match

func (this *HTTPPageConfig) Match(status int) bool

Match 检查是否匹配

type HTTPPageOptimizationConfig added in v1.2.1

type HTTPPageOptimizationConfig struct {
	IsPrior bool `yaml:"isPrior" json:"isPrior"`

	HTML       *HTTPHTMLOptimizationConfig       `yaml:"html" json:"html"`
	Javascript *HTTPJavascriptOptimizationConfig `yaml:"javascript" json:"javascript"`
	CSS        *HTTPCSSOptimizationConfig        `yaml:"css" json:"css"`
	// contains filtered or unexported fields
}

func NewHTTPPageOptimizationConfig added in v1.2.1

func NewHTTPPageOptimizationConfig() *HTTPPageOptimizationConfig

func (*HTTPPageOptimizationConfig) CheckIsOn added in v1.2.1

func (this *HTTPPageOptimizationConfig) CheckIsOn() bool

func (*HTTPPageOptimizationConfig) FilterResponse added in v1.2.1

func (this *HTTPPageOptimizationConfig) FilterResponse(resp *http.Response) error

func (*HTTPPageOptimizationConfig) Init added in v1.2.1

func (this *HTTPPageOptimizationConfig) Init() error

func (*HTTPPageOptimizationConfig) IsOn added in v1.2.1

func (this *HTTPPageOptimizationConfig) IsOn() bool

type HTTPPageOptimizationMimeType added in v1.2.1

type HTTPPageOptimizationMimeType = string
const (
	HTTPPageOptimizationMimeTypeHTML       HTTPPageOptimizationMimeType = "text/html"
	HTTPPageOptimizationMimeTypeJavascript HTTPPageOptimizationMimeType = "text/javascript"
	HTTPPageOptimizationMimeTypeCSS        HTTPPageOptimizationMimeType = "text/css"
)

type HTTPProtocolConfig

type HTTPProtocolConfig struct {
	BaseProtocol `yaml:",inline"`
}

func NewHTTPProtocolConfigFromJSON

func NewHTTPProtocolConfigFromJSON(configJSON []byte) (*HTTPProtocolConfig, error)

func (*HTTPProtocolConfig) AsJSON

func (this *HTTPProtocolConfig) AsJSON() ([]byte, error)

AsJSON 转换为JSON

func (*HTTPProtocolConfig) Init

func (this *HTTPProtocolConfig) Init() error

type HTTPRedirectToHTTPSConfig

type HTTPRedirectToHTTPSConfig struct {
	IsPrior bool   `yaml:"isPrior" json:"isPrior"` // 是否覆盖
	IsOn    bool   `yaml:"isOn" json:"isOn"`       // 是否开启
	Status  int    `yaml:"status" json:"status"`   // 跳转用的状态码
	Host    string `yaml:"host" json:"host"`       // 跳转后的Host
	Port    int    `yaml:"port" json:"port"`       // 跳转后的端口

	OnlyDomains   []string `yaml:"onlyDomains" json:"onlyDomains"`     // 允许的域名
	ExceptDomains []string `yaml:"exceptDomains" json:"exceptDomains"` // 排除的域名
}

HTTPRedirectToHTTPSConfig 跳转到HTTPS配置

func (*HTTPRedirectToHTTPSConfig) Init

func (this *HTTPRedirectToHTTPSConfig) Init() error

Init 初始化

func (*HTTPRedirectToHTTPSConfig) MatchDomain

func (this *HTTPRedirectToHTTPSConfig) MatchDomain(domain string) bool

MatchDomain 检查域名是否匹配

type HTTPRemoteAddrConfig

type HTTPRemoteAddrConfig struct {
	IsPrior      bool   `yaml:"isPrior" json:"isPrior"`
	IsOn         bool   `yaml:"isOn" json:"isOn"`
	Value        string `yaml:"value" json:"value"`               // 值变量
	IsCustomized bool   `yaml:"isCustomized" json:"isCustomized"` // 是否自定义
	// contains filtered or unexported fields
}

HTTPRemoteAddrConfig HTTP获取客户端IP地址方式

func (*HTTPRemoteAddrConfig) Init

func (this *HTTPRemoteAddrConfig) Init() error

Init 初始化

func (*HTTPRemoteAddrConfig) IsEmpty

func (this *HTTPRemoteAddrConfig) IsEmpty() bool

IsEmpty 是否为空

type HTTPRequestLimitConfig

type HTTPRequestLimitConfig struct {
	IsPrior             bool                 `yaml:"isPrior" json:"isPrior"`                         // 是否覆盖父级
	IsOn                bool                 `yaml:"isOn" json:"isOn"`                               // 是否启用
	MaxConns            int                  `yaml:"maxConns" json:"maxConns"`                       // 并发连接数
	MaxConnsPerIP       int                  `yaml:"maxConnsPerIP" json:"maxConnsPerIP"`             // 单个IP并发连接数
	OutBandwidthPerConn *shared.SizeCapacity `yaml:"outBandwidthPerConn" json:"outBandwidthPerConn"` // 下行流量限制
	MaxBodySize         *shared.SizeCapacity `yaml:"maxBodySize" json:"maxBodySize"`                 // 单个请求最大尺寸
	// contains filtered or unexported fields
}

HTTPRequestLimitConfig HTTP请求限制相关限制配置

func (*HTTPRequestLimitConfig) Init

func (this *HTTPRequestLimitConfig) Init() error

func (*HTTPRequestLimitConfig) MaxBodyBytes

func (this *HTTPRequestLimitConfig) MaxBodyBytes() int64

func (*HTTPRequestLimitConfig) OutBandwidthPerConnBytes

func (this *HTTPRequestLimitConfig) OutBandwidthPerConnBytes() int64

type HTTPRequestScriptsConfig

type HTTPRequestScriptsConfig struct {
	InitGroup    *ScriptGroupConfig `yaml:"initGroup" json:"initGroup"`
	RequestGroup *ScriptGroupConfig `yaml:"requestGroup" json:"requestGroup"`
}

func (*HTTPRequestScriptsConfig) Init

func (this *HTTPRequestScriptsConfig) Init() error

func (*HTTPRequestScriptsConfig) IsEmpty

func (this *HTTPRequestScriptsConfig) IsEmpty() bool

type HTTPRewriteMode

type HTTPRewriteMode = string
const (
	HTTPRewriteModeRedirect HTTPRewriteMode = "redirect" // 跳转
	HTTPRewriteModeProxy    HTTPRewriteMode = "proxy"    // 代理
)

type HTTPRewriteRef

type HTTPRewriteRef struct {
	IsOn          bool  `yaml:"isOn" json:"isOn"`                   // 是否启用
	RewriteRuleId int64 `yaml:"rewriteRuleId" json:"rewriteRuleId"` // 规则ID
}

重写规则的引用

type HTTPRewriteRule

type HTTPRewriteRule struct {
	Id   int64 `yaml:"id" json:"id"`     // ID
	IsOn bool  `yaml:"isOn" json:"isOn"` // 是否开启

	// 开启的条件
	// 语法为:cond param operator value 比如:
	// - cond ${status} gte 200
	// - cond ${arg.name} eq lily
	// - cond ${requestPath} regexp .*\.png
	Conds *shared.HTTPRequestCondsConfig `yaml:"conds" json:"conds"` // 匹配条件

	// 规则
	// 语法为:pattern regexp 比如:
	// - pattern ^/article/(\d+).html
	Pattern string `yaml:"pattern" json:"pattern"`

	// 模式
	Mode           HTTPRewriteMode `yaml:"mode" json:"mode"`
	RedirectStatus int             `yaml:"redirectStatus" json:"redirectStatus"` // 跳转的状态码
	ProxyHost      string          `yaml:"proxyHost" json:"proxyHost"`           // 代理模式下的Host

	// 要替换成的URL
	// 支持反向引用:${0}, ${1}, ...,也支持?P<NAME>语法
	// - 如果以 proxy:// 开头,表示目标为代理,首先会尝试作为代理ID请求,如果找不到,会尝试作为代理Host请求
	Replace string `yaml:"replace" json:"replace"`

	// 其他选项
	IsBreak   bool `yaml:"isBreak" json:"isBreak"`     // 终止向下解析
	WithQuery bool `yaml:"withQuery" json:"withQuery"` // 是否保留QueryString
	// contains filtered or unexported fields
}

HTTPRewriteRule 重写规则定义 TODO 实现对其他代理服务的引用

func (*HTTPRewriteRule) Init

func (this *HTTPRewriteRule) Init() error

Init 校验

func (*HTTPRewriteRule) IsExternalURL

func (this *HTTPRewriteRule) IsExternalURL(url string) bool

IsExternalURL 判断是否是外部URL

func (*HTTPRewriteRule) MatchRequest

func (this *HTTPRewriteRule) MatchRequest(requestPath string, formatter func(source string) string) (replace string, varMapping map[string]string, matched bool)

MatchRequest 对某个请求执行规则

func (*HTTPRewriteRule) ProxyHostHasVariables

func (this *HTTPRewriteRule) ProxyHostHasVariables() bool

ProxyHostHasVariables 判断ProxyHost是否有变量

type HTTPRootConfig

type HTTPRootConfig struct {
	IsPrior     bool     `yaml:"isPrior" json:"isPrior"`         // 是否优先
	IsOn        bool     `yaml:"isOn" json:"isOn"`               // 是否启用
	Dir         string   `yaml:"dir" json:"dir"`                 // 目录
	Indexes     []string `yaml:"indexes" json:"indexes"`         // 默认首页文件
	StripPrefix string   `yaml:"stripPrefix" json:"stripPrefix"` // 去除URL前缀
	DecodePath  bool     `yaml:"decodePath" json:"decodePath"`   // 是否对请求路径进行解码
	IsBreak     bool     `yaml:"isBreak" json:"isBreak"`         // 找不到文件的情况下是否终止
	// contains filtered or unexported fields
}

Web文档目录配置

func (*HTTPRootConfig) HasVariables

func (this *HTTPRootConfig) HasVariables() bool

判断是否有变量

func (*HTTPRootConfig) Init

func (this *HTTPRootConfig) Init() error

初始化

type HTTPSProtocolConfig

type HTTPSProtocolConfig struct {
	BaseProtocol `yaml:",inline"`

	SSLPolicyRef *sslconfigs.SSLPolicyRef `yaml:"sslPolicyRef" json:"sslPolicyRef"`
	SSLPolicy    *sslconfigs.SSLPolicy    `yaml:"sslPolicy" json:"sslPolicy"`
}

HTTPSProtocolConfig HTTPS协议配置

func NewHTTPSProtocolConfigFromJSON

func NewHTTPSProtocolConfigFromJSON(configJSON []byte) (*HTTPSProtocolConfig, error)

func (*HTTPSProtocolConfig) AsJSON

func (this *HTTPSProtocolConfig) AsJSON() ([]byte, error)

AsJSON 转换为JSON

func (*HTTPSProtocolConfig) Init

func (this *HTTPSProtocolConfig) Init(ctx context.Context) error

Init 初始化

type HTTPShutdownConfig

type HTTPShutdownConfig struct {
	IsPrior bool `yaml:"isPrior" json:"isPrior"`
	IsOn    bool `yaml:"isOn" json:"isOn"`

	BodyType shared.BodyType `yaml:"bodyType" json:"bodyType"` // 内容类型
	URL      string          `yaml:"url" json:"url"`           // URL
	Body     string          `yaml:"body" json:"body"`         // 输出的内容

	Status int `yaml:"status" json:"status"`
}

HTTPShutdownConfig 关闭页面配置

func (*HTTPShutdownConfig) Init

func (this *HTTPShutdownConfig) Init() error

Init 校验

type HTTPStatRef

type HTTPStatRef struct {
	IsPrior bool `yaml:"isPrior" json:"isPrior"` // 是否覆盖
	IsOn    bool `yaml:"isOn" json:"isOn"`       // 是否开启
}

func (*HTTPStatRef) Init

func (this *HTTPStatRef) Init() error

type HTTPStatus

type HTTPStatus struct {
	Code int    `json:"code"`
	Text string `json:"text"`
}

func AllHTTPRedirectStatusList

func AllHTTPRedirectStatusList() []*HTTPStatus

type HTTPWebConfig

type HTTPWebConfig struct {
	Id                 int64                               `yaml:"id" json:"id"`                                 // ID
	IsOn               bool                                `yaml:"isOn" json:"isOn"`                             // 是否启用
	Locations          []*HTTPLocationConfig               `yaml:"locations" json:"locations"`                   // 路径规则 TODO
	LocationRefs       []*HTTPLocationRef                  `yaml:"locationRefs" json:"locationRefs"`             // 路径规则应用
	Compression        *HTTPCompressionConfig              `yaml:"compression" json:"compression"`               // 压缩配置
	Optimization       *HTTPPageOptimizationConfig         `yaml:"optimization" json:"optimization"`             // 页面优化配置
	WebP               *WebPImageConfig                    `yaml:"webp" json:"webp"`                             // WebP配置
	Charset            *HTTPCharsetConfig                  `yaml:"charset" json:"charset"`                       // 字符编码
	Shutdown           *HTTPShutdownConfig                 `yaml:"shutdown" json:"shutdown"`                     // 临时关闭配置
	Pages              []*HTTPPageConfig                   `yaml:"pages" json:"pages"`                           // 特殊页面配置
	RedirectToHttps    *HTTPRedirectToHTTPSConfig          `yaml:"redirectToHTTPS" json:"redirectToHTTPS"`       // 是否自动跳转到Https
	Root               *HTTPRootConfig                     `yaml:"root" json:"root"`                             // 资源根目录 TODO
	MaxRequestBodySize string                              `yaml:"maxRequestBodySize" json:"maxRequestBodySize"` // 请求body最大尺寸 TODO 需要实现
	AccessLogRef       *HTTPAccessLogRef                   `yaml:"accessLog" json:"accessLog"`                   // 访问日志配置
	StatRef            *HTTPStatRef                        `yaml:"statRef" json:"statRef"`                       // 统计配置
	Cache              *HTTPCacheConfig                    `yaml:"cache" json:"cache"`                           // 缓存配置
	FirewallRef        *firewallconfigs.HTTPFirewallRef    `yaml:"firewallRef" json:"firewallRef"`               // 防火墙设置
	FirewallPolicy     *firewallconfigs.HTTPFirewallPolicy `yaml:"firewallPolicy" json:"firewallPolicy"`         // 防火墙策略
	WebsocketRef       *HTTPWebsocketRef                   `yaml:"websocketRef" json:"websocketRef"`             // Websocket应用配置
	Websocket          *HTTPWebsocketConfig                `yaml:"websocket" json:"websocket"`                   // Websocket配置
	RewriteRefs        []*HTTPRewriteRef                   `yaml:"rewriteRefs" json:"rewriteRefs"`               // 重写规则配置
	RewriteRules       []*HTTPRewriteRule                  `yaml:"rewriteRules" json:"rewriteRules"`             // 重写规则
	FastcgiRef         *HTTPFastcgiRef                     `yaml:"fastcgiRef" json:"fastcgiRef"`                 // Fastcgi引用
	FastcgiList        []*HTTPFastcgiConfig                `yaml:"fastcgiList" json:"fastcgiList"`               // Fastcgi配置
	UserAgent          *UserAgentConfig                    `yaml:"userAgent" json:"userAgent"`                   // UserAgent配置

	RequestHeaderPolicyRef  *shared.HTTPHeaderPolicyRef `yaml:"requestHeaderPolicyRef" json:"requestHeaderPolicyRef"`   // 请求Header
	RequestHeaderPolicy     *shared.HTTPHeaderPolicy    `yaml:"requestHeaderPolicy" json:"requestHeaderPolicy"`         // 请求Header策略
	ResponseHeaderPolicyRef *shared.HTTPHeaderPolicyRef `yaml:"responseHeaderPolicyRef" json:"responseHeaderPolicyRef"` // 响应Header`
	ResponseHeaderPolicy    *shared.HTTPHeaderPolicy    `yaml:"responseHeaderPolicy" json:"responseHeaderPolicy"`       // 响应Header策略

	FilterRefs     []*HTTPFilterRef    `yaml:"filterRefs" json:"filterRefs"`         // 筛选配置 TODO
	FilterPolicies []*HTTPFilterPolicy `yaml:"filterPolicies" json:"filterPolicies"` // 筛选策略

	HostRedirects []*HTTPHostRedirectConfig `yaml:"hostRedirects" json:"hostRedirects"` // 主机跳转
	Auth          *HTTPAuthConfig           `yaml:"auth" json:"auth"`                   // 认证配置
	Referers      *ReferersConfig           `yaml:"referers" json:"referers"`           // 防盗链设置

	RemoteAddr   *HTTPRemoteAddrConfig `yaml:"remoteAddr" json:"remoteAddr"`     // 客户端IP获取方式
	MergeSlashes bool                  `yaml:"mergeSlashes" json:"mergeSlashes"` // 是否合并路径中的斜杠(/)

	RequestLimit   *HTTPRequestLimitConfig   `yaml:"requestLimit" json:"requestLimit"`     // 并发请求限制
	RequestScripts *HTTPRequestScriptsConfig `yaml:"requestScripts" json:"requestScripts"` // HTTP请求相关脚本

	// UAM, CC ...
	UAM *UAMConfig    `yaml:"uam" json:"uam"`
	CC  *HTTPCCConfig `yaml:"cc" json:"cc"`
}

func (*HTTPWebConfig) Init

func (this *HTTPWebConfig) Init(ctx context.Context) error

func (*HTTPWebConfig) RemoveLocationRef

func (this *HTTPWebConfig) RemoveLocationRef(locationId int64)

type HTTPWebsocketConfig

type HTTPWebsocketConfig struct {
	Id   int64 `yaml:"id" json:"id"`     // ID
	IsOn bool  `yaml:"isOn" json:"isOn"` // 是否开启

	// 握手超时时间
	HandshakeTimeout *shared.TimeDuration `yaml:"handshakeTimeout" json:"handshakeTimeout"`

	// 允许的来源域名,支持 www.example.com, example.com, .example.com, *.example.com
	AllowAllOrigins bool     `yaml:"allowAllOrigins" json:"allowAllOrigins"`
	AllowedOrigins  []string `yaml:"allowedOrigins" json:"allowedOrigins"`

	// 向后传递的来源
	RequestSameOrigin bool   `yaml:"requestSameOrigin" json:"requestSameOrigin"` // 和请求一致
	RequestOrigin     string `yaml:"requestOrigin" json:"requestOrigin"`         // 自行指定Origin,支持变量
	// contains filtered or unexported fields
}

HTTPWebsocketConfig websocket设置

func (*HTTPWebsocketConfig) HandshakeTimeoutDuration

func (this *HTTPWebsocketConfig) HandshakeTimeoutDuration() time.Duration

获取握手超时时间

func (*HTTPWebsocketConfig) Init

func (this *HTTPWebsocketConfig) Init() error

校验

func (*HTTPWebsocketConfig) MatchOrigin

func (this *HTTPWebsocketConfig) MatchOrigin(origin string) bool

匹配域名

func (*HTTPWebsocketConfig) RequestOriginHasVariables

func (this *HTTPWebsocketConfig) RequestOriginHasVariables() bool

判断请求Origin是否有变量

type HTTPWebsocketRef

type HTTPWebsocketRef struct {
	IsPrior     bool  `yaml:"isPrior" json:"isPrior"`
	IsOn        bool  `yaml:"isOn" json:"isOn"`
	WebsocketId int64 `yaml:"websocketId" json:"websocketId"`
}

func (*HTTPWebsocketRef) Init

func (this *HTTPWebsocketRef) Init() error

type HealthCheckConfig

type HealthCheckConfig struct {
	IsOn             bool                 `yaml:"isOn" json:"isOn"`                         // 是否开启
	URL              string               `yaml:"url" json:"url"`                           // 读取的URL
	Interval         *shared.TimeDuration `yaml:"interval" json:"interval"`                 // 检测周期
	StatusCodes      []int                `yaml:"statusCodes" json:"statusCodes"`           // 返回的状态码要求
	Timeout          *shared.TimeDuration `yaml:"timeout" json:"timeout"`                   // 超时时间
	CountTries       int64                `yaml:"countTries" json:"countTries"`             // 尝试次数
	TryDelay         *shared.TimeDuration `yaml:"tryDelay" json:"tryDelay"`                 // 尝试间隔
	FailActions      []maps.Map           `yaml:"failActions" json:"failActions"`           // 失败采取的动作 TODO
	RecoverActions   []maps.Map           `yaml:"recoverActions" json:"recoverActions"`     // 恢复采取的动作 TODO
	AutoDown         bool                 `yaml:"autoDown" json:"autoDown"`                 // 是否自动下线
	CountUp          int                  `yaml:"countUp" json:"countUp"`                   // 连续在线认定次数
	CountDown        int                  `yaml:"countDown" json:"countDown"`               // 连续离线认定次数
	UserAgent        string               `yaml:"userAgent" json:"userAgent"`               // 发起请求用的UserAgent
	OnlyBasicRequest bool                 `yaml:"onlyBasicRequest" json:"onlyBasicRequest"` // 只做基础的请求,不处理WAF、反向代理等
	AccessLogIsOn    bool                 `yaml:"accessLogIsOn" json:"accessLogIsOn"`       // 是否关闭访问日志
}

HealthCheckConfig 健康检查设置

func (*HealthCheckConfig) Init

func (this *HealthCheckConfig) Init() error

Init 初始化

type IPLibraryType

type IPLibraryType = string
const (
	IPLibraryTypeIP2Region IPLibraryType = "ip2region"
)

type IPVersion

type IPVersion = string
const (
	IPv4 IPVersion = "4"
	IPv6 IPVersion = "6"
)

type MetricChartType

type MetricChartType = string
const (
	MetricChartTypePie      MetricChartType = "pie"
	MetricChartTypeBar      MetricChartType = "bar"
	MetricChartTypeTimeBar  MetricChartType = "timeBar"
	MetricChartTypeTimeLine MetricChartType = "timeLine"
	MetricChartTypeTable    MetricChartType = "table"
)

type MetricItemCategory

type MetricItemCategory = string

MetricItemCategory 指标分类

const (
	MetricItemCategoryHTTP MetricItemCategory = "http"
	MetricItemCategoryTCP  MetricItemCategory = "tcp"
	MetricItemCategoryUDP  MetricItemCategory = "udp"
)

func FindAllMetricItemCategoryCodes

func FindAllMetricItemCategoryCodes() []MetricItemCategory

type MetricItemConfig

type MetricItemConfig struct {
	Id            int64                `yaml:"id" json:"id"`
	IsOn          bool                 `yaml:"isOn" json:"isOn"`
	Category      MetricItemCategory   `yaml:"category" json:"category"`
	Period        int                  `yaml:"period" json:"period"`         // 统计周期
	PeriodUnit    MetricItemPeriodUnit `yaml:"periodUnit" json:"periodUnit"` // 统计周期单位
	Keys          []string             `yaml:"keys" json:"keys"`
	Value         string               `yaml:"value" json:"value"`
	Version       int32                `yaml:"version" json:"version"`
	ExpiresPeriod int                  `yaml:"expiresPeriod" json:"expiresPeriod"` // 过期周期
	// contains filtered or unexported fields
}

MetricItemConfig 指标配置

func (*MetricItemConfig) CurrentTime

func (this *MetricItemConfig) CurrentTime() string

CurrentTime 根据周期计算时间

func (*MetricItemConfig) HasHTTPConnectionValue

func (this *MetricItemConfig) HasHTTPConnectionValue() bool

func (*MetricItemConfig) Init

func (this *MetricItemConfig) Init() error

Init 初始化

func (*MetricItemConfig) LocalExpiresTime

func (this *MetricItemConfig) LocalExpiresTime() string

LocalExpiresTime 根据周期计算本地端过期时间

func (*MetricItemConfig) ServerExpiresDay

func (this *MetricItemConfig) ServerExpiresDay() string

ServerExpiresDay 根据周期计算服务器端数据过期日期

func (*MetricItemConfig) ServerExpiresTime

func (this *MetricItemConfig) ServerExpiresTime() string

ServerExpiresTime 根据周期计算服务器端数据过期时间

func (*MetricItemConfig) UploadDuration

func (this *MetricItemConfig) UploadDuration() time.Duration

UploadDuration 上传数据的周期

type MetricItemPeriodUnit

type MetricItemPeriodUnit = string

MetricItemPeriodUnit 指标周期单位

const (
	MetricItemPeriodUnitMinute MetricItemPeriodUnit = "minute"
	MetricItemPeriodUnitHour   MetricItemPeriodUnit = "hour"
	MetricItemPeriodUnitDay    MetricItemPeriodUnit = "day"
	MetricItemPeriodUnitWeek   MetricItemPeriodUnit = "week"
	MetricItemPeriodUnitMonth  MetricItemPeriodUnit = "month"
)

type MetricItemValueType

type MetricItemValueType = string

MetricItemValueType 值类型

const (
	MetricItemValueTypeCount MetricItemValueType = "count" // 数量
	MetricItemValueTypeByte  MetricItemValueType = "byte"  //  字节
)

type MetricValueDefinition

type MetricValueDefinition struct {
	Name        string `json:"name"`
	Code        string `json:"code"`
	Description string `json:"description"`
	Icon        string `json:"icon"`
	Type        string `json:"type"`
}

MetricValueDefinition 指标数值定义

func FindAllMetricValueDefinitions

func FindAllMetricValueDefinitions(category MetricItemCategory) []*MetricValueDefinition

FindAllMetricValueDefinitions 指标数值定义

type NetworkAddressConfig

type NetworkAddressConfig struct {
	Protocol  Protocol `yaml:"protocol" json:"protocol"`   // 协议,http、tcp、tcp4、tcp6、unix、udp等
	Host      string   `yaml:"host" json:"host"`           // 主机地址或主机名,支持变量
	PortRange string   `yaml:"portRange" json:"portRange"` // 端口范围,支持 8080、8080-8090、8080:8090

	MinPort int `yaml:"minPort" json:"minPort"` // minPort和maxPort只是用来记录PortRange分解后的结果,不需要用户输入
	MaxPort int `yaml:"maxPort" json:"maxPort"`
	// contains filtered or unexported fields
}

NetworkAddressConfig 网络地址配置

func (*NetworkAddressConfig) Addresses

func (this *NetworkAddressConfig) Addresses() []string

Addresses 所有的地址列表,不包括scheme

func (*NetworkAddressConfig) FullAddresses

func (this *NetworkAddressConfig) FullAddresses() []string

FullAddresses 所有的地址列表,包含scheme

func (*NetworkAddressConfig) HostHasVariables

func (this *NetworkAddressConfig) HostHasVariables() bool

HostHasVariables 判断Host是否包含变量

func (*NetworkAddressConfig) Init

func (this *NetworkAddressConfig) Init() error

Init 初始化

func (*NetworkAddressConfig) PickAddress

func (this *NetworkAddressConfig) PickAddress() string

PickAddress 选择其中一个地址

type OpenFileCacheConfig

type OpenFileCacheConfig struct {
	IsOn bool `yaml:"isOn" json:"isOn"`
	Max  int  `yaml:"max" json:"max"`
}

OpenFileCacheConfig open file cache配置

func (*OpenFileCacheConfig) Init

func (this *OpenFileCacheConfig) Init() error

type OriginConfig

type OriginConfig struct {
	Id           int64                 `yaml:"id" json:"id"`                     // ID
	IsOn         bool                  `yaml:"isOn" json:"isOn"`                 // 是否启用
	Version      int                   `yaml:"version" json:"version"`           // 版本
	Name         string                `yaml:"name" json:"name"`                 // 名称
	Addr         *NetworkAddressConfig `yaml:"addr" json:"addr"`                 // 地址
	HTTP2Enabled bool                  `yaml:"http2Enabled" json:"http2Enabled"` // 是否支持HTTP2
	OSS          *ossconfigs.OSSConfig `yaml:"oss" json:"oss"`                   // 对象存储配置
	Description  string                `yaml:"description" json:"description"`   // 描述
	Code         string                `yaml:"code" json:"code"`                 // 代号

	Weight       uint                 `yaml:"weight" json:"weight"`           // 权重
	ConnTimeout  *shared.TimeDuration `yaml:"connTimeout" json:"connTimeout"` // 连接失败超时
	ReadTimeout  *shared.TimeDuration `yaml:"readTimeout" json:"readTimeout"` // 读取超时时间
	IdleTimeout  *shared.TimeDuration `yaml:"idleTimeout" json:"idleTimeout"` // 空闲连接超时时间
	MaxFails     int                  `yaml:"maxFails" json:"maxFails"`       // 最多失败次数
	MaxConns     int                  `yaml:"maxConns" json:"maxConns"`       // 最大并发连接数
	MaxIdleConns int                  `yaml:"idleConns" json:"idleConns"`     // 最大空闲连接数

	Domains []string `yaml:"domains" json:"domains"` // 所属域名

	StripPrefix    string                `yaml:"stripPrefix" json:"stripPrefix"`       // 去除URL前缀
	RequestURI     string                `yaml:"requestURI" json:"requestURI"`         // 转发后的请求URI
	RequestHost    string                `yaml:"requestHost" json:"requestHost"`       // 自定义主机名
	FollowPort     bool                  `yaml:"followPort" json:"followPort"`         // 端口跟随
	FollowProtocol *FollowProtocolConfig `yaml:"followProtocol" json:"followProtocol"` // 协议跟随

	RequestHeaderPolicyRef  *shared.HTTPHeaderPolicyRef `yaml:"requestHeaderPolicyRef" json:"requestHeaderPolicyRef"`   // 请求Header
	RequestHeaderPolicy     *shared.HTTPHeaderPolicy    `yaml:"requestHeaderPolicy" json:"requestHeaderPolicy"`         // 请求Header策略
	ResponseHeaderPolicyRef *shared.HTTPHeaderPolicyRef `yaml:"responseHeaderPolicyRef" json:"responseHeaderPolicyRef"` // 响应Header`
	ResponseHeaderPolicy    *shared.HTTPHeaderPolicy    `yaml:"responseHeaderPolicy" json:"responseHeaderPolicy"`       // 响应Header策略

	// 健康检查URL,目前支持:
	// - http|https 返回2xx-3xx认为成功
	HealthCheck *HealthCheckConfig `yaml:"healthCheck" json:"healthCheck"` // TODO

	CertRef *sslconfigs.SSLCertRef    `yaml:"certRef" json:"certRef"` // 证书的引用
	Cert    *sslconfigs.SSLCertConfig `yaml:"cert" json:"cert"`       // 请求源服务器用的证书

	// ftp
	FTPServerRef *FTPServerRef    `yaml:"ftpServerRef" json:"ftpServerRef"` // TODO
	FTPServer    *FTPServerConfig `yaml:"ftpServer" json:"ftpServer"`       // TODO

	IsOk bool `yaml:"isOk" json:"isOk"` // 是否可以正常访问,仅仅用于运行时检查
	// contains filtered or unexported fields
}

OriginConfig 源站服务配置

func (*OriginConfig) AddrSummary added in v1.2.0

func (this *OriginConfig) AddrSummary() string

AddrSummary 地址描述

func (*OriginConfig) CandidateCodes

func (this *OriginConfig) CandidateCodes() []string

CandidateCodes 候选对象代号

func (*OriginConfig) CandidateWeight

func (this *OriginConfig) CandidateWeight() uint

CandidateWeight 候选对象权重

func (*OriginConfig) ConnTimeoutDuration

func (this *OriginConfig) ConnTimeoutDuration() time.Duration

ConnTimeoutDuration 连接超时时间

func (*OriginConfig) IdleTimeoutDuration

func (this *OriginConfig) IdleTimeoutDuration() time.Duration

IdleTimeoutDuration 休眠超时时间

func (*OriginConfig) Init

func (this *OriginConfig) Init(ctx context.Context) error

Init 校验

func (*OriginConfig) IsOSS added in v1.2.0

func (this *OriginConfig) IsOSS() bool

IsOSS 判断当前源站是否为OSS

func (*OriginConfig) ReadTimeoutDuration

func (this *OriginConfig) ReadTimeoutDuration() time.Duration

ReadTimeoutDuration 读取超时时间

func (*OriginConfig) RequestHostHasVariables

func (this *OriginConfig) RequestHostHasVariables() bool

RequestHostHasVariables 判断RequestHost是否有变量

func (*OriginConfig) RequestURIHasVariables

func (this *OriginConfig) RequestURIHasVariables() bool

RequestURIHasVariables 判断RequestURI是否有变量

func (*OriginConfig) UniqueKey

func (this *OriginConfig) UniqueKey() string

UniqueKey 唯一Key

type OriginGroupConfig

type OriginGroupConfig struct {
	Origins []*OriginConfig `yaml:"origins" json:"origins"` // 源站列表
}

TODO 需要实现

type OriginRef

type OriginRef struct {
	IsOn     bool  `yaml:"isOn" json:"isOn"`
	OriginId int64 `yaml:"originId" json:"originId"`
}

type PlanConfig

type PlanConfig struct {
	Id   int64  `yaml:"id" json:"id"`
	Name string `yaml:"name" json:"name"`
}

func (*PlanConfig) Init

func (this *PlanConfig) Init() error

type Protocol

type Protocol string
const (
	ProtocolHTTP  Protocol = "http"
	ProtocolHTTPS Protocol = "https"
	ProtocolTCP   Protocol = "tcp"
	ProtocolTLS   Protocol = "tls"
	ProtocolUnix  Protocol = "unix"
	ProtocolUDP   Protocol = "udp"

	// 子协议
	ProtocolHTTP4 Protocol = "http4"
	ProtocolHTTP6 Protocol = "http6"

	ProtocolHTTPS4 Protocol = "https4"
	ProtocolHTTPS6 Protocol = "https6"

	ProtocolTCP4 Protocol = "tcp4"
	ProtocolTCP6 Protocol = "tcp6"

	ProtocolTLS4 Protocol = "tls4"
	ProtocolTLS6 Protocol = "tls6"
)

func AllProtocols

func AllProtocols() []Protocol

func (Protocol) IsHTTPFamily

func (this Protocol) IsHTTPFamily() bool

func (Protocol) IsHTTPSFamily

func (this Protocol) IsHTTPSFamily() bool

func (Protocol) IsOSS added in v1.2.0

func (this Protocol) IsOSS() bool

func (Protocol) IsTCPFamily

func (this Protocol) IsTCPFamily() bool

func (Protocol) IsTLSFamily

func (this Protocol) IsTLSFamily() bool

func (Protocol) IsUDPFamily

func (this Protocol) IsUDPFamily() bool

func (Protocol) IsUnixFamily

func (this Protocol) IsUnixFamily() bool

func (Protocol) Primary

func (this Protocol) Primary() Protocol

Primary 主协议

func (Protocol) Scheme

func (this Protocol) Scheme() string

Scheme schema

func (Protocol) String

func (this Protocol) String() string

转换为字符串

type ProxyProtocolConfig

type ProxyProtocolConfig struct {
	IsOn    bool                 `yaml:"isOn" json:"isOn"`
	Version ProxyProtocolVersion `yaml:"version" json:"version"`
}

ProxyProtocolConfig PROXY Protocol配置

func (*ProxyProtocolConfig) Init

func (this *ProxyProtocolConfig) Init() error

Init 初始化

type ProxyProtocolVersion

type ProxyProtocolVersion = int
const (
	ProxyProtocolVersion1 ProxyProtocolVersion = 1
	ProxyProtocolVersion2 ProxyProtocolVersion = 2
)

type ReferersConfig added in v0.5.3

type ReferersConfig struct {
	IsPrior         bool     `yaml:"isPrior" json:"isPrior"`
	IsOn            bool     `yaml:"isOn" json:"isOn"`
	AllowEmpty      bool     `yaml:"allowEmpty" json:"allowEmpty"`           // 来源域名允许为空
	AllowSameDomain bool     `yaml:"allowSameDomain" json:"allowSameDomain"` // 允许来源域名和当前访问的域名一致,相当于在站内访问
	AllowDomains    []string `yaml:"allowDomains" json:"allowDomains"`       // 允许的来源域名列表
	DenyDomains     []string `yaml:"denyDomains" json:"denyDomains"`         // 禁止的来源域名列表
	CheckOrigin     bool     `yaml:"checkOrigin" json:"checkOrigin"`         // 是否检查Origin
}

ReferersConfig 防盗链设置

func NewReferersConfig added in v1.1.0

func NewReferersConfig() *ReferersConfig

NewReferersConfig 获取新防盗链配置对象

func (*ReferersConfig) Init added in v0.5.3

func (this *ReferersConfig) Init() error

func (*ReferersConfig) MatchDomain added in v0.5.3

func (this *ReferersConfig) MatchDomain(requestDomain string, refererDomain string) bool

type RequestHostType

type RequestHostType = int8
const (
	RequestHostTypeProxyServer RequestHostType = 0
	RequestHostTypeOrigin      RequestHostType = 1
	RequestHostTypeCustomized  RequestHostType = 2
)

type ReverseProxyConfig

type ReverseProxyConfig struct {
	Id                int64             `yaml:"id" json:"id"`                               // ID
	IsOn              bool              `yaml:"isOn" json:"isOn"`                           // 是否启用
	PrimaryOrigins    []*OriginConfig   `yaml:"primaryOrigins" json:"primaryOrigins"`       // 主要源站列表
	PrimaryOriginRefs []*OriginRef      `yaml:"primaryOriginRefs" json:"primaryOriginRefs"` // 主要源站引用
	BackupOrigins     []*OriginConfig   `yaml:"backupOrigins" json:"backupOrigins"`         // 备用源站列表
	BackupOriginRefs  []*OriginRef      `yaml:"backupOriginRefs" json:"backupOriginRefs"`   // 备用源站引用
	Scheduling        *SchedulingConfig `yaml:"scheduling" json:"scheduling"`               // 调度算法选项

	ConnTimeout  *shared.TimeDuration `yaml:"connTimeout" json:"connTimeout"`   // 连接失败超时 TODO
	ReadTimeout  *shared.TimeDuration `yaml:"readTimeout" json:"readTimeout"`   // 读取超时时间 TODO
	IdleTimeout  *shared.TimeDuration `yaml:"idleTimeout" json:"idleTimeout"`   // 空闲连接超时时间 TODO
	MaxFails     int                  `yaml:"maxFails" json:"maxFails"`         // 最多失败次数 TODO
	MaxConns     int                  `yaml:"maxConns" json:"maxConns"`         // 最大并发连接数 TODO
	MaxIdleConns int                  `yaml:"maxIdleConns" json:"maxIdleConns"` // 最大空闲连接数 TODO

	StripPrefix              string          `yaml:"stripPrefix" json:"stripPrefix"`                           // 去除URL前缀
	RequestHostType          RequestHostType `yaml:"requestHostType" json:"requestHostType"`                   // 请求Host类型
	RequestHost              string          `yaml:"requestHost" json:"requestHost"`                           // 请求Host,支持变量
	RequestURI               string          `yaml:"requestURI" json:"requestURI"`                             // 请求URI,支持变量,如果同时定义了StripPrefix,则先执行StripPrefix
	RequestHostExcludingPort bool            `yaml:"requestHostExcludingPort" json:"requestHostExcludingPort"` // 请求Host不包括端口

	AddHeaders []string `yaml:"addHeaders" json:"addHeaders"` // 自动添加的Header

	AutoFlush bool `yaml:"autoFlush" json:"autoFlush"` // 是否自动刷新缓冲区,在比如SSE(server-sent events)场景下很有用

	ProxyProtocol   *ProxyProtocolConfig  `yaml:"proxyProtocol" json:"proxyProtocol"`     // PROXY Protocol
	FollowRedirects bool                  `yaml:"followRedirects" json:"followRedirects"` // 回源跟随
	FollowProtocol  *FollowProtocolConfig `yaml:"followProtocol" json:"followProtocol"`   // 协议跟随 TODO
	// contains filtered or unexported fields
}

ReverseProxyConfig 反向代理设置

func (*ReverseProxyConfig) AddBackupOrigin

func (this *ReverseProxyConfig) AddBackupOrigin(origin *OriginConfig)

AddBackupOrigin 添加备用源站配置

func (*ReverseProxyConfig) AddPrimaryOrigin

func (this *ReverseProxyConfig) AddPrimaryOrigin(origin *OriginConfig)

AddPrimaryOrigin 添加主源站配置

func (*ReverseProxyConfig) AnyOrigin added in v0.5.0

func (this *ReverseProxyConfig) AnyOrigin(call *shared.RequestCall, excludingOriginIds []int64) *OriginConfig

AnyOrigin 取下一个任意的源站

func (*ReverseProxyConfig) FindSchedulingConfig

func (this *ReverseProxyConfig) FindSchedulingConfig() *SchedulingConfig

FindSchedulingConfig 获取调度配置对象

func (*ReverseProxyConfig) Init

func (this *ReverseProxyConfig) Init(ctx context.Context) error

Init 初始化

func (*ReverseProxyConfig) NextOrigin

func (this *ReverseProxyConfig) NextOrigin(call *shared.RequestCall) *OriginConfig

NextOrigin 取得下一个可用的源站

func (*ReverseProxyConfig) RequestHostHasVariables

func (this *ReverseProxyConfig) RequestHostHasVariables() bool

RequestHostHasVariables 判断RequestHost是否有变量

func (*ReverseProxyConfig) RequestURIHasVariables

func (this *ReverseProxyConfig) RequestURIHasVariables() bool

RequestURIHasVariables 判断RequestURI是否有变量

func (*ReverseProxyConfig) ResetScheduling

func (this *ReverseProxyConfig) ResetScheduling()

ResetScheduling 重置调度算法

func (*ReverseProxyConfig) SetupScheduling

func (this *ReverseProxyConfig) SetupScheduling(isBackup bool, checkOk bool, lock bool)

SetupScheduling 设置调度算法

func (*ReverseProxyConfig) ShouldAddXForwardedByHeader

func (this *ReverseProxyConfig) ShouldAddXForwardedByHeader() bool

ShouldAddXForwardedByHeader 是否添加X-Forwarded-By

func (*ReverseProxyConfig) ShouldAddXForwardedForHeader

func (this *ReverseProxyConfig) ShouldAddXForwardedForHeader() bool

ShouldAddXForwardedForHeader 是否添加X-Forwarded-For

func (*ReverseProxyConfig) ShouldAddXForwardedHostHeader

func (this *ReverseProxyConfig) ShouldAddXForwardedHostHeader() bool

ShouldAddXForwardedHostHeader 是否添加X-Forwarded-Host

func (*ReverseProxyConfig) ShouldAddXForwardedProtoHeader

func (this *ReverseProxyConfig) ShouldAddXForwardedProtoHeader() bool

ShouldAddXForwardedProtoHeader 是否添加X-Forwarded-Proto

func (*ReverseProxyConfig) ShouldAddXRealIPHeader

func (this *ReverseProxyConfig) ShouldAddXRealIPHeader() bool

ShouldAddXRealIPHeader 是否添加X-Real-IP

type ReverseProxyRef

type ReverseProxyRef struct {
	IsPrior        bool  `yaml:"isPrior" json:"isPrior"`               // 是否覆盖
	IsOn           bool  `yaml:"isOn" json:"isOn"`                     // 是否启用
	ReverseProxyId int64 `yaml:"reverseProxyId" json:"reverseProxyId"` // 反向代理ID
}

ReverseProxyRef 反向代理引用

func (*ReverseProxyRef) Init

func (this *ReverseProxyRef) Init() error

Init 初始化

type SchedulingConfig

type SchedulingConfig struct {
	Code    string   `yaml:"code" json:"code"`       // 类型
	Options maps.Map `yaml:"options" json:"options"` // 选项
}

SchedulingConfig 调度算法配置

func NewSchedulingConfig

func NewSchedulingConfig() *SchedulingConfig

NewSchedulingConfig 获取新对象

func (*SchedulingConfig) Clone

func (this *SchedulingConfig) Clone() *SchedulingConfig

Clone 克隆

type SchedulingGroup

type SchedulingGroup struct {
	Scheduling *SchedulingConfig `yaml:"scheduling" json:"scheduling"`

	PrimaryOrigins []*OriginConfig
	BackupOrigins  []*OriginConfig
	// contains filtered or unexported fields
}

SchedulingGroup 负载均衡分组

func (*SchedulingGroup) AnyOrigin added in v0.5.0

func (this *SchedulingGroup) AnyOrigin(excludingOriginIds []int64) *OriginConfig

AnyOrigin 取下一个任意源站

func (*SchedulingGroup) Init

func (this *SchedulingGroup) Init() error

Init 初始化

func (*SchedulingGroup) NextOrigin

func (this *SchedulingGroup) NextOrigin(call *shared.RequestCall) *OriginConfig

NextOrigin 取得下一个可用源站

func (*SchedulingGroup) SetupScheduling

func (this *SchedulingGroup) SetupScheduling(isBackup bool, checkOk bool)

SetupScheduling 设置调度算法

type ScriptConfig

type ScriptConfig struct {
	IsPrior bool `yaml:"isPrior" json:"isPrior"`
	IsOn    bool `yaml:"isOn" json:"isOn"`

	Code string `yaml:"code" json:"code"`
}

func (*ScriptConfig) Init

func (this *ScriptConfig) Init() error

type ScriptGroupConfig

type ScriptGroupConfig struct {
	IsOn    bool            `yaml:"isOn" json:"isOn"`
	IsPrior bool            `yaml:"isPrior" json:"isPrior"`
	Scripts []*ScriptConfig `yaml:"scripts" json:"scripts"`
	// contains filtered or unexported fields
}

func (*ScriptGroupConfig) Init

func (this *ScriptGroupConfig) Init() error

func (*ScriptGroupConfig) IsEmpty

func (this *ScriptGroupConfig) IsEmpty() bool

type ServerAddressGroup

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

func NewServerAddressGroup

func NewServerAddressGroup(fullAddr string) *ServerAddressGroup

func (*ServerAddressGroup) Add

func (this *ServerAddressGroup) Add(server *ServerConfig)

Add 添加服务

func (*ServerAddressGroup) Addr

func (this *ServerAddressGroup) Addr() string

Addr 获取当前分组的地址

func (*ServerAddressGroup) FirstServer

func (this *ServerAddressGroup) FirstServer() *ServerConfig

FirstServer 获取第一个Server

func (*ServerAddressGroup) FirstTLSServer

func (this *ServerAddressGroup) FirstTLSServer() *ServerConfig

FirstTLSServer 获取第一个TLS Server

func (*ServerAddressGroup) FullAddr

func (this *ServerAddressGroup) FullAddr() string

FullAddr 获取完整的地址

func (*ServerAddressGroup) IsHTTP

func (this *ServerAddressGroup) IsHTTP() bool

IsHTTP 判断当前分组是否为HTTP

func (*ServerAddressGroup) IsHTTPS

func (this *ServerAddressGroup) IsHTTPS() bool

IsHTTPS 判断当前分组是否为HTTPS

func (*ServerAddressGroup) IsTCP

func (this *ServerAddressGroup) IsTCP() bool

IsTCP 判断当前分组是否为TCP

func (*ServerAddressGroup) IsTLS

func (this *ServerAddressGroup) IsTLS() bool

IsTLS 判断当前分组是否为TLS

func (*ServerAddressGroup) IsUDP

func (this *ServerAddressGroup) IsUDP() bool

IsUDP 判断当前分组是否为UDP

func (*ServerAddressGroup) IsUnix

func (this *ServerAddressGroup) IsUnix() bool

IsUnix 判断当前分组是否为Unix

func (*ServerAddressGroup) MatchServerCNAME

func (this *ServerAddressGroup) MatchServerCNAME(serverName string) *ServerConfig

MatchServerCNAME 使用CNAME查找服务

func (*ServerAddressGroup) MatchServerName

func (this *ServerAddressGroup) MatchServerName(serverName string) *ServerConfig

MatchServerName 使用域名查找服务

func (*ServerAddressGroup) Protocol

func (this *ServerAddressGroup) Protocol() Protocol

Protocol 获取当前分组的协议

func (*ServerAddressGroup) Servers

func (this *ServerAddressGroup) Servers() []*ServerConfig

Servers 读取所有服务

type ServerConfig

type ServerConfig struct {
	Id               int64               `yaml:"id" json:"id"`                             // ID
	ClusterId        int64               `yaml:"clusterId" json:"clusterId"`               // 集群ID
	UserId           int64               `yaml:"userId" json:"userId"`                     // 用户ID
	Type             string              `yaml:"type" json:"type"`                         // 类型
	IsOn             bool                `yaml:"isOn" json:"isOn"`                         // 是否开启
	Name             string              `yaml:"name" json:"name"`                         // 名称
	Description      string              `yaml:"description" json:"description"`           // 描述
	AliasServerNames []string            `yaml:"aliasServerNames" json:"aliasServerNames"` // 关联的域名,比如CNAME之类的
	ServerNames      []*ServerNameConfig `yaml:"serverNames" json:"serverNames"`           // 域名
	CNameDomain      string              `yaml:"cnameDomain" json:"cnameDomain"`           // CNAME(末尾不带点(.))
	CNameAsDomain    bool                `yaml:"cnameAsDomain" json:"cnameAsDomain"`       // 启用CNAME域名访问
	SupportCNAME     bool                `yaml:"supportCNAME" json:"supportCNAME"`         // 是否支持CNAME

	// 前端协议
	HTTP  *HTTPProtocolConfig  `yaml:"http" json:"http"`   // HTTP配置
	HTTPS *HTTPSProtocolConfig `yaml:"https" json:"https"` // HTTPS配置
	TCP   *TCPProtocolConfig   `yaml:"tcp" json:"tcp"`     // TCP配置
	TLS   *TLSProtocolConfig   `yaml:"tls" json:"tls"`     // TLS配置
	Unix  *UnixProtocolConfig  `yaml:"unix" json:"unix"`   // Unix配置
	UDP   *UDPProtocolConfig   `yaml:"udp" json:"udp"`     // UDP配置

	// Web配置
	Web *HTTPWebConfig `yaml:"web" json:"web"`

	// 反向代理配置
	ReverseProxyRef *ReverseProxyRef    `yaml:"reverseProxyRef" json:"reverseProxyRef"`
	ReverseProxy    *ReverseProxyConfig `yaml:"reverseProxy" json:"reverseProxy"`

	// WAF策略
	HTTPFirewallPolicyId int64                               `yaml:"httpFirewallPolicyId" json:"httpFirewallPolicyId"`
	HTTPFirewallPolicy   *firewallconfigs.HTTPFirewallPolicy `yaml:"httpFirewallPolicy" json:"httpFirewallPolicy"` // 通过 HTTPFirewallPolicyId 获取

	// 缓存策略
	HTTPCachePolicyId int64            `yaml:"httpCachePolicyId" json:"httpCachePolicyId"`
	HTTPCachePolicy   *HTTPCachePolicy `yaml:"httpCachePolicy" json:"httpCachePolicy"` // 通过 HTTPCachePolicyId 获取

	// 流量限制
	TrafficLimit       *TrafficLimitConfig `yaml:"trafficLimit" json:"trafficLimit"`
	TrafficLimitStatus *TrafficLimitStatus `yaml:"trafficLimitStatus" json:"trafficLimitStatus"`

	// 套餐
	UserPlan *UserPlanConfig `yaml:"userPlan" json:"userPlan"`

	// 分组
	Group *ServerGroupConfig `yaml:"group" json:"group"`

	// UAM
	UAM *UAMConfig `yaml:"uam" json:"uam"`
	// contains filtered or unexported fields
}

func NewServerConfig

func NewServerConfig() *ServerConfig

func NewServerConfigFromJSON

func NewServerConfigFromJSON(data []byte) (*ServerConfig, error)

NewServerConfigFromJSON 从JSON中解析Server配置

func (*ServerConfig) AllFuzzyNames

func (this *ServerConfig) AllFuzzyNames() []string

AllFuzzyNames 所有模糊域名

func (*ServerConfig) AllStrictNames

func (this *ServerConfig) AllStrictNames() []string

AllStrictNames 所有严格域名

func (*ServerConfig) AsJSON

func (this *ServerConfig) AsJSON() ([]byte, error)

func (*ServerConfig) FindAndCheckReverseProxy

func (this *ServerConfig) FindAndCheckReverseProxy(dataType string) (*ReverseProxyConfig, error)

FindAndCheckReverseProxy 根据条件查找ReverseProxy

func (*ServerConfig) FullAddresses

func (this *ServerConfig) FullAddresses() []string

func (*ServerConfig) Init

func (this *ServerConfig) Init(ctx context.Context) (results []error)

func (*ServerConfig) IsHTTPFamily

func (this *ServerConfig) IsHTTPFamily() bool

func (*ServerConfig) IsInitialized added in v0.5.3

func (this *ServerConfig) IsInitialized() bool

func (*ServerConfig) IsOk

func (this *ServerConfig) IsOk() bool

IsOk 配置是否正确

func (*ServerConfig) IsTCPFamily

func (this *ServerConfig) IsTCPFamily() bool

func (*ServerConfig) IsUDPFamily

func (this *ServerConfig) IsUDPFamily() bool

func (*ServerConfig) IsUnixFamily

func (this *ServerConfig) IsUnixFamily() bool

func (*ServerConfig) Listen

func (this *ServerConfig) Listen() []*NetworkAddressConfig

func (*ServerConfig) PlanId

func (this *ServerConfig) PlanId() int64

PlanId 套餐ID

func (*ServerConfig) SSLPolicy

func (this *ServerConfig) SSLPolicy() *sslconfigs.SSLPolicy

SSLPolicy SSL信息

func (*ServerConfig) ShouldCheckTrafficLimit

func (this *ServerConfig) ShouldCheckTrafficLimit() bool

ShouldCheckTrafficLimit 检查是否需要检查流量限制

func (*ServerConfig) SupportsHTTP3 added in v1.2.0

func (this *ServerConfig) SupportsHTTP3() bool

SupportsHTTP3 是否支持HTTP/3

type ServerGroupConfig

type ServerGroupConfig struct {
	Id   int64  `yaml:"id" json:"id"`
	Name string `yaml:"name" json:"name"`
	IsOn bool   `yaml:"isOn" json:"isOn"`

	// 反向代理配置
	HTTPReverseProxyRef *ReverseProxyRef    `yaml:"httpReverseProxyRef" json:"httpReverseProxyRef"`
	HTTPReverseProxy    *ReverseProxyConfig `yaml:"httpReverseProxy" json:"httpReverseProxy"`
	TCPReverseProxyRef  *ReverseProxyRef    `yaml:"tcpReverseProxyRef" json:"tcpReverseProxyRef"`
	TCPReverseProxy     *ReverseProxyConfig `yaml:"tcpReverseProxy" json:"tcpReverseProxy"`
	UDPReverseProxyRef  *ReverseProxyRef    `yaml:"udpReverseProxyRef" json:"udpReverseProxyRef"`
	UDPReverseProxy     *ReverseProxyConfig `yaml:"udpReverseProxy" json:"udpReverseProxy"`

	Web *HTTPWebConfig `yaml:"web" json:"web"`
}

ServerGroupConfig 服务分组配置

type ServerNameConfig

type ServerNameConfig struct {
	Name     string   `yaml:"name" json:"name"`         // 名称
	Type     string   `yaml:"type" json:"type"`         // 类型
	SubNames []string `yaml:"subNames" json:"subNames"` // 子名称,用来支持大量的域名批量管理
}

ServerNameConfig 主机名(域名)配置

func (*ServerNameConfig) Count added in v0.5.6

func (this *ServerNameConfig) Count() int

Count 计算域名数量

func (*ServerNameConfig) FirstName

func (this *ServerNameConfig) FirstName() string

FirstName 获取第一个名称

func (*ServerNameConfig) Match

func (this *ServerNameConfig) Match(name string) bool

Match 判断主机名是否匹配

func (*ServerNameConfig) Normalize

func (this *ServerNameConfig) Normalize()

Normalize 格式化域名

type ServerNameType

type ServerNameType = string
const (
	ServerNameTypeFull   ServerNameType = "full"   // 完整的域名,包含通配符等
	ServerNameTypePrefix ServerNameType = "prefix" // 前缀
	ServerNameTypeSuffix ServerNameType = "suffix" // 后缀
	ServerNameTypeMatch  ServerNameType = "match"  // 正则匹配
)

type ServerType

type ServerType = string
const (
	ServerTypeHTTPProxy ServerType = "httpProxy"
	ServerTypeHTTPWeb   ServerType = "httpWeb"
	ServerTypeTCPProxy  ServerType = "tcpProxy"
	ServerTypeUnixProxy ServerType = "unixProxy"
	ServerTypeUDPProxy  ServerType = "udpProxy"
)

type TCPProtocolConfig

type TCPProtocolConfig struct {
	BaseProtocol `yaml:",inline"`
}

func NewTCPProtocolConfigFromJSON

func NewTCPProtocolConfigFromJSON(configJSON []byte) (*TCPProtocolConfig, error)

func (*TCPProtocolConfig) AsJSON

func (this *TCPProtocolConfig) AsJSON() ([]byte, error)

AsJSON 转换为JSON

func (*TCPProtocolConfig) Init

func (this *TCPProtocolConfig) Init() error

type TLSProtocolConfig

type TLSProtocolConfig struct {
	BaseProtocol `yaml:",inline"`

	SSLPolicyRef *sslconfigs.SSLPolicyRef `yaml:"sslPolicyRef" json:"sslPolicyRef"`
	SSLPolicy    *sslconfigs.SSLPolicy    `yaml:"sslPolicy" json:"sslPolicy"`
}

TLSProtocolConfig TLS协议配置

func NewTLSProtocolConfigFromJSON

func NewTLSProtocolConfigFromJSON(configJSON []byte) (*TLSProtocolConfig, error)

func (*TLSProtocolConfig) AsJSON

func (this *TLSProtocolConfig) AsJSON() ([]byte, error)

AsJSON 转换为JSON

func (*TLSProtocolConfig) Init

func (this *TLSProtocolConfig) Init(ctx context.Context) error

Init 初始化

type TrafficLimitConfig

type TrafficLimitConfig struct {
	IsOn bool `yaml:"isOn" json:"isOn"` // 是否启用

	DailySize   *shared.SizeCapacity `yaml:"dailySize" json:"dailySize"`     // 每日限制
	MonthlySize *shared.SizeCapacity `yaml:"monthlySize" json:"monthlySize"` // 每月限制
	TotalSize   *shared.SizeCapacity `yaml:"totalSize" json:"totalSize"`     // 总限制 TODO 需要实现

	NoticePageBody string `yaml:"noticePageBody" json:"noticePageBody"` // 超出限制时的提醒,支持请求变量
}

TrafficLimitConfig 流量限制

func (*TrafficLimitConfig) DailyBytes

func (this *TrafficLimitConfig) DailyBytes() int64

DailyBytes 每天限制 不使用Init()来初始化数据,是为了让其他地方不经过Init()也能得到计算值

func (*TrafficLimitConfig) IsEmpty

func (this *TrafficLimitConfig) IsEmpty() bool

IsEmpty 检查是否有限制值

func (*TrafficLimitConfig) MonthlyBytes

func (this *TrafficLimitConfig) MonthlyBytes() int64

MonthlyBytes 每月限制

func (*TrafficLimitConfig) TotalBytes

func (this *TrafficLimitConfig) TotalBytes() int64

TotalBytes 总限制

type TrafficLimitStatus

type TrafficLimitStatus struct {
	UntilDay string `yaml:"untilDay" json:"untilDay"` // 有效日期,格式YYYYMMDD
}

TrafficLimitStatus 流量限制状态

func (*TrafficLimitStatus) IsValid

func (this *TrafficLimitStatus) IsValid() bool

type UAMConfig

type UAMConfig struct {
	IsPrior bool `yaml:"isPrior" json:"isPrior"`
	IsOn    bool `yaml:"isOn" json:"isOn"`

	AddToWhiteList    bool                 `yaml:"addToWhiteList" json:"addToWhiteList"`       // 是否将IP加入到白名单
	OnlyURLPatterns   []*shared.URLPattern `yaml:"onlyURLPatterns" json:"onlyURLPatterns"`     // 仅限的URL
	ExceptURLPatterns []*shared.URLPattern `yaml:"exceptURLPatterns" json:"exceptURLPatterns"` // 排除的URL
	MinQPSPerIP       int                  `yaml:"minQPSPerIP" json:"minQPSPerIP"`             // 启用要求的单IP最低平均QPS
}

UAMConfig UAM配置

func NewUAMConfig added in v1.0.4

func NewUAMConfig() *UAMConfig

func (*UAMConfig) Init

func (this *UAMConfig) Init() error

func (*UAMConfig) MatchURL added in v0.6.4

func (this *UAMConfig) MatchURL(url string) bool

type UDPProtocolConfig

type UDPProtocolConfig struct {
	BaseProtocol `yaml:",inline"`
}

func NewUDPProtocolConfigFromJSON

func NewUDPProtocolConfigFromJSON(configJSON []byte) (*UDPProtocolConfig, error)

func (*UDPProtocolConfig) AsJSON

func (this *UDPProtocolConfig) AsJSON() ([]byte, error)

AsJSON 转换为JSON

func (*UDPProtocolConfig) Init

func (this *UDPProtocolConfig) Init() error

type UnixProtocolConfig

type UnixProtocolConfig struct {
	BaseProtocol `yaml:",inline"`
}

func (*UnixProtocolConfig) AsJSON

func (this *UnixProtocolConfig) AsJSON() ([]byte, error)

转换为JSON

func (*UnixProtocolConfig) Init

func (this *UnixProtocolConfig) Init() error

type UserAgentAction added in v0.6.0

type UserAgentAction = string
const (
	UserAgentActionAllow UserAgentAction = "allow"
	UserAgentActionDeny  UserAgentAction = "deny"
)

type UserAgentConfig added in v0.6.0

type UserAgentConfig struct {
	IsPrior bool               `yaml:"isPrior" json:"isPrior"`
	IsOn    bool               `yaml:"isOn" json:"isOn"`
	Filters []*UserAgentFilter `yaml:"filters" json:"filters"`
}

func NewUserAgentConfig added in v0.6.0

func NewUserAgentConfig() *UserAgentConfig

func (*UserAgentConfig) AllowRequest added in v0.6.0

func (this *UserAgentConfig) AllowRequest(req *http.Request) bool

func (*UserAgentConfig) Init added in v0.6.0

func (this *UserAgentConfig) Init() error

type UserAgentFilter added in v0.6.0

type UserAgentFilter struct {
	Keywords []string        `yaml:"keywords" json:"keywords"` // 关键词
	Action   UserAgentAction `yaml:"action" json:"action"`     // 动作
	// contains filtered or unexported fields
}

func (*UserAgentFilter) Init added in v0.6.0

func (this *UserAgentFilter) Init() error

func (*UserAgentFilter) Match added in v0.6.0

func (this *UserAgentFilter) Match(userAgent string) bool

type UserAgentKeyword added in v0.6.0

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

func NewUserAgentKeyword added in v0.6.0

func NewUserAgentKeyword(keyword string) *UserAgentKeyword

type UserPlanConfig

type UserPlanConfig struct {
	DayTo string `yaml:"dayTo" json:"dayTo"` // 有效期

	Plan *PlanConfig `yaml:"plan" json:"plan"`
}

UserPlanConfig 用户套餐配置

func (*UserPlanConfig) Init

func (this *UserPlanConfig) Init() error

Init 初始化

func (*UserPlanConfig) IsAvailable

func (this *UserPlanConfig) IsAvailable() bool

IsAvailable 是否有效

type WebPImageConfig

type WebPImageConfig struct {
	IsPrior bool `yaml:"isPrior" json:"isPrior"`
	IsOn    bool `yaml:"isOn" json:"isOn"`

	Quality int `yaml:"quality" json:"quality"` // 0-100

	MinLength  *shared.SizeCapacity           `yaml:"minLength" json:"minLength"`   // 最小压缩对象比如4m, 24k
	MaxLength  *shared.SizeCapacity           `yaml:"maxLength" json:"maxLength"`   // 最大压缩对象
	MimeTypes  []string                       `yaml:"mimeTypes" json:"mimeTypes"`   // 支持的MimeType,支持image/*这样的通配符使用
	Extensions []string                       `yaml:"extensions" json:"extensions"` // 文件扩展名,包含点符号,不区分大小写
	Conds      *shared.HTTPRequestCondsConfig `yaml:"conds" json:"conds"`           // 匹配条件
	// contains filtered or unexported fields
}

WebPImageConfig WebP配置

func (*WebPImageConfig) Init

func (this *WebPImageConfig) Init() error

func (*WebPImageConfig) MatchAccept

func (this *WebPImageConfig) MatchAccept(acceptContentTypes string) bool

MatchAccept 检查客户端是否能接受WebP

func (*WebPImageConfig) MatchRequest

func (this *WebPImageConfig) MatchRequest(requestExt string, formatter shared.Formatter) bool

MatchRequest 是否匹配请求

func (*WebPImageConfig) MatchResponse

func (this *WebPImageConfig) MatchResponse(mimeType string, contentLength int64, requestExt string, formatter shared.Formatter) bool

MatchResponse 是否匹配响应

type WildcardStatus

type WildcardStatus struct {
	StatusInt    int
	StatusRegexp *regexp.Regexp
}

可能含有x字母的状态码

func NewWildcardStatus

func NewWildcardStatus(status string) *WildcardStatus

获取新对象

func (*WildcardStatus) Match

func (this *WildcardStatus) Match(status int) bool

判断匹配

Source Files

Jump to

Keyboard shortcuts

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