teaconfigs

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2020 License: MIT, MIT Imports: 52 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventBackendDown teaevents.EventType = "EventBackendDown"
	EventBackendUp   teaevents.EventType = "EventBackendUp"
)
View Source
const (
	LocationPatternTypePrefix = 1
	LocationPatternTypeExact  = 2
	LocationPatternTypeRegexp = 3
)

内置的匹配类型定义

View Source
const (
	NodeRoleMaster = "MASTER"
	NodeRoleSlave  = "SLAVE"
)
View Source
const (
	RewriteTargetProxy = 1
	RewriteTargetURL   = 2
)
View Source
const (
	RewriteFlagRedirect = "r" // 跳转,TODO: 实现 302, 305
	RewriteFlagProxy    = "p" // 代理
)
View Source
const (
	WebsocketForwardModeWebsocket = "websocket"
	WebsocketForwardModeHttp      = "http"
)

Variables

View Source
var AllTLSCipherSuites = []TLSCipherSuite{
	"TLS_RSA_WITH_RC4_128_SHA",
	"TLS_RSA_WITH_3DES_EDE_CBC_SHA",
	"TLS_RSA_WITH_AES_128_CBC_SHA",
	"TLS_RSA_WITH_AES_256_CBC_SHA",
	"TLS_RSA_WITH_AES_128_CBC_SHA256",
	"TLS_RSA_WITH_AES_128_GCM_SHA256",
	"TLS_RSA_WITH_AES_256_GCM_SHA384",
	"TLS_ECDHE_ECDSA_WITH_RC4_128_SHA",
	"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA",
	"TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA",
	"TLS_ECDHE_RSA_WITH_RC4_128_SHA",
	"TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
	"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA",
	"TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA",
	"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",
	"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
	"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
	"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
	"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
	"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
	"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
	"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
	"TLS_AES_128_GCM_SHA256",
	"TLS_AES_256_GCM_SHA384",
	"TLS_CHACHA20_POLY1305_SHA256",
}
View Source
var AllTlsVersions = []TLSVersion{"SSL 3.0", "TLS 1.0", "TLS 1.1", "TLS 1.2", "TLS 1.3"}
View Source
var (
	DefaultGzipMimeTypes = []string{"text/html", "application/json"}
)

默认的文件类型

View Source
var TLSIntermediateCipherSuites = []string{
	"TLS_AES_128_GCM_SHA256",
	"TLS_CHACHA20_POLY1305_SHA256",
	"TLS_AES_256_GCM_SHA384",

	"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
	"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
	"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
	"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
	"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
	"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
	"TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
	"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256",

	"TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA",
	"TLS_RSA_WITH_3DES_EDE_CBC_SHA",
}
View Source
var TLSModernCipherSuites = []string{
	"TLS_AES_128_GCM_SHA256",
	"TLS_CHACHA20_POLY1305_SHA256",
	"TLS_AES_256_GCM_SHA384",

	"TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
	"TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
	"TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256",
	"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256",
	"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384",
	"TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384",
}

Functions

func AllLocationPatternTypes

func AllLocationPatternTypes() []maps.Map

取得所有的匹配类型信息

func AllNodeRoles

func AllNodeRoles() []string

所有角色

func AllSSLClientAuthTypes

func AllSSLClientAuthTypes() []maps.Map

所有的客户端认证类型

func AllTimePasts

func AllTimePasts() []maps.Map

func AllWebsocketForwardModes

func AllWebsocketForwardModes() []maps.Map

所有的转发方式

func ExistNodeRole

func ExistNodeRole(role NodeRole) bool

判断某个角色是否存在

func FindLocationPatternType

func FindLocationPatternType(patternType int) maps.Map

查找单个匹配类型信息

func FindLocationPatternTypeName

func FindLocationPatternTypeName(patternType int) string

查找单个匹配类型名称

func FindSSLClientAuthTypeName

func FindSSLClientAuthTypeName(authType SSLClientAuthType) string

查找单个认证方式的名称

func GoSSLClientAuthType

func GoSSLClientAuthType(authType SSLClientAuthType) tls.ClientAuthType

认证类型和tls包内类型的映射

func TimePastUnixTime

func TimePastUnixTime(past TimePast) (timestamp int64)

func TimePastUnixTimeWithUnit

func TimePastUnixTimeWithUnit(number int64, unit TimeUnit) int64

Types

type ACMEDNSProvider

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

自定义ACME DNS解析

func NewACMEDNSProvider

func NewACMEDNSProvider(apiAuthToken string) *ACMEDNSProvider

func (*ACMEDNSProvider) CleanUp

func (this *ACMEDNSProvider) CleanUp(domain, token, keyAuth string) error

func (*ACMEDNSProvider) Present

func (this *ACMEDNSProvider) Present(domain, token, keyAuth string) error

type ACMEDNSRecord

type ACMEDNSRecord struct {
	FQDN  string `yaml:"fqdn" json:"fqdn"`
	Value string `yaml:"value" json:"value"`
}

ACME DNS记录

type ACMELocalUser

type ACMELocalUser struct {
	Id    string `yaml:"id" json:"id"`
	Name  string `yaml:"name" json:"name"`
	On    bool   `yaml:"on" json:"on"`
	Email string `yaml:"email" json:"email"`
	Key   string `yaml:"key" json:"key"` // base64
	URI   string `yaml:"uri" json:"uri"`
}

本地用户信息

func NewACMELocalUser

func NewACMELocalUser() *ACMELocalUser

获取新对象

type ACMELocalUserList

type ACMELocalUserList struct {
	Users []*ACMELocalUser `yaml:"users" json:"users"`
}

本地用户列表

func SharedACMELocalUserList

func SharedACMELocalUserList() *ACMELocalUserList

取得共享的本地用户列表

func (*ACMELocalUserList) AddUser

func (this *ACMELocalUserList) AddUser(user *ACMELocalUser)

添加用户

func (*ACMELocalUserList) FindUser

func (this *ACMELocalUserList) FindUser(userId string) *ACMELocalUser

查找用户

func (*ACMELocalUserList) RemoveUser

func (this *ACMELocalUserList) RemoveUser(userId string)

删除用户

func (*ACMELocalUserList) Save

func (this *ACMELocalUserList) Save() error

保存

type ACMERequest

type ACMERequest struct {
	User *ACMELocalUser `yaml:"user" json:"user"`

	Domains    []string         `yaml:"domains" json:"domains"`
	DNSRecords []*ACMEDNSRecord `yaml:"dnsRecords" json:"dnsRecords"`

	CertURL string `yaml:"certURL" json:"certURL"`
	Cert    string `yaml:"cert" json:"cert"`
	Key     string `yaml:"key" json:"key"`
}

ACME DNS Request

func NewACMERequest

func NewACMERequest() *ACMERequest

获取新对象

func (*ACMERequest) CertDate

func (this *ACMERequest) CertDate() [2]string

获取证书时间

func (*ACMERequest) CertObject

func (this *ACMERequest) CertObject() (*tls.Certificate, error)

获取证书对象

func (*ACMERequest) Client

func (this *ACMERequest) Client() (client *lego.Client, err error)

获取连接客户端

func (*ACMERequest) Renew

func (this *ACMERequest) Renew(client *lego.Client) error

更新

func (*ACMERequest) Retrieve

func (this *ACMERequest) Retrieve(client *lego.Client) error

获取证书信息

func (*ACMERequest) RetrieveDNSRecords

func (this *ACMERequest) RetrieveDNSRecords(client *lego.Client) (records []*ACMEDNSRecord, err error)

获取要设置的DNS记录

func (*ACMERequest) WriteCertFile

func (this *ACMERequest) WriteCertFile(path string) error

写入证书文件

func (*ACMERequest) WriteKeyFile

func (this *ACMERequest) WriteKeyFile(path string) error

写入密钥文件

type ACMEUser

type ACMEUser struct {
	Email        string
	Registration *registration.Resource
	Key          crypto.PrivateKey
}

ACME用户账号定义

func (*ACMEUser) GetEmail

func (this *ACMEUser) GetEmail() string

func (*ACMEUser) GetPrivateKey

func (this *ACMEUser) GetPrivateKey() crypto.PrivateKey

func (*ACMEUser) GetRegistration

func (this *ACMEUser) GetRegistration() *registration.Resource

type AccessLogConfig

type AccessLogConfig struct {
	Id string `yaml:"id" json:"id"`
	On bool   `yaml:"on" json:"on"`

	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

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

代理访问日志配置

func NewAccessLogConfig

func NewAccessLogConfig() *AccessLogConfig

获取新对象

func (*AccessLogConfig) ContainsStoragePolicy

func (this *AccessLogConfig) ContainsStoragePolicy(storagePolicyId string) bool

是否包含某个存储策略

func (*AccessLogConfig) Match

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

判断是否应该记录

func (*AccessLogConfig) Validate

func (this *AccessLogConfig) Validate() error

校验

type AccessLogStoragePolicy

type AccessLogStoragePolicy struct {
	Id      string                 `yaml:"id" json:"id"`
	Name    string                 `yaml:"name" json:"name"`
	On      bool                   `yaml:"bool" json:"on"`
	Type    string                 `yaml:"type" json:"type"`       // 存储类型
	Options map[string]interface{} `yaml:"options" json:"options"` // 存储选项
	Cond    []*shared.RequestCond  `yaml:"cond" json:"cond"`       // 请求条件
}

日志存储策略 存储在configs/accesslog.storage.$id.conf

func NewAccessLogStoragePolicy

func NewAccessLogStoragePolicy() *AccessLogStoragePolicy

创建新策略

func NewAccessLogStoragePolicyFromId

func NewAccessLogStoragePolicyFromId(id string) *AccessLogStoragePolicy

从文件中加载策略

func (*AccessLogStoragePolicy) Delete

func (this *AccessLogStoragePolicy) Delete() error

删除

func (*AccessLogStoragePolicy) MatchConds

func (this *AccessLogStoragePolicy) MatchConds(formatter func(string) string) bool

匹配条件

func (*AccessLogStoragePolicy) MatchKeyword

func (this *AccessLogStoragePolicy) MatchKeyword(keyword string) (matched bool, name string, tags []string)

匹配关键词

func (*AccessLogStoragePolicy) Save

func (this *AccessLogStoragePolicy) Save() error

保存

func (*AccessLogStoragePolicy) Validate

func (this *AccessLogStoragePolicy) Validate() error

校验

type AccessLogStoragePolicyList

type AccessLogStoragePolicyList struct {
	Ids []string `yaml:"id" json:"id"`
}

存储策略列表

func SharedAccessLogStoragePolicyList

func SharedAccessLogStoragePolicyList() *AccessLogStoragePolicyList

获取共享的存储策略列表

func (*AccessLogStoragePolicyList) AddId

func (this *AccessLogStoragePolicyList) AddId(id string)

添加策略ID

func (*AccessLogStoragePolicyList) FindAllPolicies

func (this *AccessLogStoragePolicyList) FindAllPolicies() []*AccessLogStoragePolicy

查找所有的策略列表

func (*AccessLogStoragePolicyList) RemoveId

func (this *AccessLogStoragePolicyList) RemoveId(id string)

删除策略ID

func (*AccessLogStoragePolicyList) Save

func (this *AccessLogStoragePolicyList) Save() error

保存

type BackendConfig

type BackendConfig struct {
	shared.HeaderList `yaml:",inline"`

	TeaVersion string `yaml:"teaVersion" json:"teaVersion"`

	On           bool   `yaml:"on" json:"on"`                     // 是否启用
	Id           string `yaml:"id" json:"id"`                     // ID
	Version      int    `yaml:"version" json:"version"`           // 版本号
	Code         string `yaml:"code" json:"code"`                 // 代号
	Address      string `yaml:"address" json:"address"`           // 地址
	Scheme       string `yaml:"scheme" json:"scheme"`             // 协议,http、https、tcp、tcp+tls、ftp
	Weight       uint   `yaml:"weight" json:"weight"`             // 权重
	IsBackup     bool   `yaml:"backup" json:"isBackup"`           // 是否为备份
	FailTimeout  string `yaml:"failTimeout" json:"failTimeout"`   // 连接失败超时
	ReadTimeout  string `yaml:"readTimeout" json:"readTimeout"`   // 读取超时时间
	IdleTimeout  string `yaml:"idleTimeout" json:"idleTimeout"`   // 空闲连接超时时间
	MaxFails     int32  `yaml:"maxFails" json:"maxFails"`         // 最多失败次数
	CurrentFails int32  `yaml:"currentFails" json:"currentFails"` // 当前已失败次数
	MaxConns     int32  `yaml:"maxConns" json:"maxConns"`         // 最大并发连接数
	CurrentConns int32  `yaml:"currentConns" json:"currentConns"` // 当前连接数
	IdleConns    int32  `yaml:"idleConns" json:"idleConns"`       // 最大空闲连接数

	IsDown   bool      `yaml:"down" json:"isDown"`                           // 是否下线
	DownTime time.Time `yaml:"downTime,omitempty" json:"downTime,omitempty"` // 下线时间

	RequestGroupIds []string               `yaml:"requestGroupIds" json:"requestGroupIds"` // 所属请求分组
	RequestURI      string                 `yaml:"requestURI" json:"requestURI"`           // 转发后的请求URI
	ResponseHeaders []*shared.HeaderConfig `yaml:"responseHeaders" json:"responseHeaders"` // 响应Header
	Host            string                 `yaml:"host" json:"host"`                       // 自定义主机名

	// 健康检查URL,目前支持:
	// - http|https 返回2xx-3xx认为成功
	CheckOn       bool   `yaml:"checkOn" json:"checkOn"` // 是否开启
	CheckURL      string `yaml:"checkURL" json:"checkURL"`
	CheckInterval int    `yaml:"checkInterval" json:"checkInterval"`
	CheckTimeout  string `yaml:"checkTimeout" json:"checkTimeout"` // 超时时间

	Cert *SSLCertConfig `yaml:"cert" json:"cert"` // 请求源服务器用的证书

	// ftp
	FTP *FTPBackendConfig `yaml:"ftp" json:"ftp"`
	// contains filtered or unexported fields
}

服务后端配置

func NewBackendConfig

func NewBackendConfig() *BackendConfig

获取新对象

func (*BackendConfig) AddRequestGroupId

func (this *BackendConfig) AddRequestGroupId(requestGroupId string)

添加请求分组

func (*BackendConfig) AddResponseHeader

func (this *BackendConfig) AddResponseHeader(header *shared.HeaderConfig)

添加响应Header

func (*BackendConfig) CandidateCodes

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

候选对象代号

func (*BackendConfig) CandidateWeight

func (this *BackendConfig) CandidateWeight() uint

候选对象权重

func (*BackendConfig) CheckHealth

func (this *BackendConfig) CheckHealth() bool

健康检查

func (*BackendConfig) CloneState

func (this *BackendConfig) CloneState(oldBackend *BackendConfig)

克隆状态

func (*BackendConfig) Compatible

func (this *BackendConfig) Compatible()

处理兼容性

func (*BackendConfig) DecreaseConn

func (this *BackendConfig) DecreaseConn() int32

减少连接数,并返回减少之后的数字

func (*BackendConfig) DownCallback

func (this *BackendConfig) DownCallback(callback func(backend *BackendConfig))

增加下线回调

func (*BackendConfig) FailTimeoutDuration

func (this *BackendConfig) FailTimeoutDuration() time.Duration

连接超时时间

func (*BackendConfig) HasAddrVariables

func (this *BackendConfig) HasAddrVariables() bool

地址中是否含有变量

func (*BackendConfig) HasCheckURL

func (this *BackendConfig) HasCheckURL() bool

判断是否有URL Check

func (*BackendConfig) HasHost

func (this *BackendConfig) HasHost() bool

判断是否有自定义主机名

func (*BackendConfig) HasRequestGroupId

func (this *BackendConfig) HasRequestGroupId(requestGroupId string) bool

判断是否有某个情趣分组ID

func (*BackendConfig) HasRequestURI

func (this *BackendConfig) HasRequestURI() bool

判断是否设置RequestURI

func (*BackendConfig) HasResponseHeaders

func (this *BackendConfig) HasResponseHeaders() bool

判断是否有响应Header

func (*BackendConfig) IdleTimeoutDuration

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

保持空闲连接时间

func (*BackendConfig) IncreaseConn

func (this *BackendConfig) IncreaseConn() int32

增加连接数,并返回增加之后的数字

func (*BackendConfig) IncreaseFails

func (this *BackendConfig) IncreaseFails() int32

增加错误次数

func (*BackendConfig) IsFTP

func (this *BackendConfig) IsFTP() bool

是否为FTP

func (*BackendConfig) IsHTTP

func (this *BackendConfig) IsHTTP() bool

是否为HTTP

func (*BackendConfig) IsTCP

func (this *BackendConfig) IsTCP() bool

是否为TCP

func (*BackendConfig) OnAttach

func (this *BackendConfig) OnAttach()

装载事件

func (*BackendConfig) OnDetach

func (this *BackendConfig) OnDetach()

卸载事件

func (*BackendConfig) OnDown

func (this *BackendConfig) OnDown()

下线事件

func (*BackendConfig) OnUp

func (this *BackendConfig) OnUp()

上线事件

func (*BackendConfig) ReadTimeoutDuration

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

读取超时时间

func (*BackendConfig) RemoveRequestGroupId

func (this *BackendConfig) RemoveRequestGroupId(requestGroupId string)

删除某个请求分组

func (*BackendConfig) RequestArgs

func (this *BackendConfig) RequestArgs() string

获取转发后的附加参数

func (*BackendConfig) RequestPath

func (this *BackendConfig) RequestPath() string

获取转发后的Path

func (*BackendConfig) RestartChecking

func (this *BackendConfig) RestartChecking()

重启检查

func (*BackendConfig) StopChecking

func (this *BackendConfig) StopChecking()

停止Checking

func (*BackendConfig) Touch

func (this *BackendConfig) Touch()

更新

func (*BackendConfig) UniqueKey

func (this *BackendConfig) UniqueKey() string

获取唯一ID

func (*BackendConfig) UpCallback

func (this *BackendConfig) UpCallback(callback func(backend *BackendConfig))

增加上线回调

func (*BackendConfig) Validate

func (this *BackendConfig) Validate() error

校验

type BackendDownEvent

type BackendDownEvent struct {
	Server    *ServerConfig
	Backend   *BackendConfig
	Location  *LocationConfig
	Websocket *WebsocketConfig
}

后端服务器下线事件

func (*BackendDownEvent) Type

func (this *BackendDownEvent) Type() string

type BackendList

type BackendList struct {
	Backends   []*BackendConfig  `yaml:"backends" json:"backends"`
	Scheduling *SchedulingConfig `yaml:"scheduling" json:"scheduling"` // 调度算法选项
	// contains filtered or unexported fields
}

BackendList定义

func (*BackendList) AddBackend

func (this *BackendList) AddBackend(backend *BackendConfig)

添加Backend

func (*BackendList) AllBackends

func (this *BackendList) AllBackends() []*BackendConfig

所有的Backends

func (*BackendList) CloneBackendList

func (this *BackendList) CloneBackendList() *BackendList

克隆

func (*BackendList) DeleteBackend

func (this *BackendList) DeleteBackend(backendId string)

删除后端服务器

func (*BackendList) DeleteBackends

func (this *BackendList) DeleteBackends(backendIds []string)

删除一组后端服务器

func (*BackendList) FindBackend

func (this *BackendList) FindBackend(backendId string) *BackendConfig

根据ID查找后端服务器

func (*BackendList) HasBackends

func (this *BackendList) HasBackends() bool

判断是否有后端服务器

func (*BackendList) NextBackend

func (this *BackendList) NextBackend(call *shared.RequestCall) *BackendConfig

取得下一个可用的后端服务

func (*BackendList) SchedulingConfig

func (this *BackendList) SchedulingConfig() *SchedulingConfig

调度算法

func (*BackendList) SetSchedulingConfig

func (this *BackendList) SetSchedulingConfig(scheduling *SchedulingConfig)

设置调度算法

func (*BackendList) SetupScheduling

func (this *BackendList) SetupScheduling(isBackup bool)

设置调度算法

func (*BackendList) ValidateBackends

func (this *BackendList) ValidateBackends() error

校验

type BackendListInterface

type BackendListInterface interface {
	// 校验
	ValidateBackends() error

	// 添加Backend
	AddBackend(backend *BackendConfig)

	// 所有的Backends
	AllBackends() []*BackendConfig

	// 删除后端服务器
	DeleteBackend(backendId string)

	// 查找后端服务器
	FindBackend(backendId string) *BackendConfig

	// 调度算法
	SchedulingConfig() *SchedulingConfig

	// 设置调度算法
	SetSchedulingConfig(scheduling *SchedulingConfig)

	// 重新建立调度
	SetupScheduling(isBackup bool)
}

BackendList接口定义

type BackendUpEvent

type BackendUpEvent struct {
	Server    *ServerConfig
	Backend   *BackendConfig
	Location  *LocationConfig
	Websocket *WebsocketConfig
}

后端服务器上线事件

func (*BackendUpEvent) Type

func (this *BackendUpEvent) Type() string

type Board

type Board struct {
	Charts []*BoardChart `yaml:"charts" json:"charts"`
}

看板

func NewBoard

func NewBoard() *Board

获取新对象

func (*Board) AddChart

func (this *Board) AddChart(widgetId string, chartId string)

添加Chart

func (*Board) HasChart

func (this *Board) HasChart(chartId string) bool

判断是否在使用某个Chart

func (*Board) MoveChart

func (this *Board) MoveChart(fromIndex int, toIndex int)

移动Chart

func (*Board) RemoveChart

func (this *Board) RemoveChart(chartId string)

移除某个Chart

type BoardChart

type BoardChart struct {
	WidgetId string `yaml:"widgetId" json:"widgetId"`
	ChartId  string `yaml:"chartId" json:"chartId"`
}

看板图表

func (*BoardChart) FindChart

func (this *BoardChart) FindChart() (widget *widgets.Widget, chart *widgets.Chart)

查找Chart实例

type CacheConfig

type CacheConfig struct {
	Filename    string   `yaml:"filename" json:"filename"`       // 文件名
	PolicyFiles []string `yaml:"policyFiles" json:"policyFiles"` // 策略文件
}

缓存管理

func NewCacheConfig

func NewCacheConfig() *CacheConfig

获取新对象

func SharedCacheConfig

func SharedCacheConfig() (*CacheConfig, error)

加载对象,无论如何都会返回一个对象

func (*CacheConfig) AddPolicy

func (this *CacheConfig) AddPolicy(file string)

添加缓存策略

func (*CacheConfig) DeletePolicy

func (this *CacheConfig) DeletePolicy(file string)

删除缓存策略

func (*CacheConfig) FindAllPolicies

func (this *CacheConfig) FindAllPolicies() []*shared.CachePolicy

查找所有的缓存策略

func (*CacheConfig) Save

func (this *CacheConfig) Save() error

保存

type FTPBackendConfig

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

backend

type FastcgiConfig

type FastcgiConfig struct {
	shared.HeaderList `yaml:",inline"`

	On bool   `yaml:"on" json:"on"`
	Id string `yaml:"id" json:"id"`

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

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

Fastcgi配置

func NewFastcgiConfig

func NewFastcgiConfig() *FastcgiConfig

获取新对象

func (*FastcgiConfig) Address

func (this *FastcgiConfig) Address() string

网络地址

func (*FastcgiConfig) FilterParams

func (this *FastcgiConfig) FilterParams(req *http.Request) maps.Map

过滤参数

func (*FastcgiConfig) Network

func (this *FastcgiConfig) Network() string

网络协议

func (*FastcgiConfig) Param

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

读取参数

func (*FastcgiConfig) PathInfoRegexp

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

PATH_INFO正则

func (*FastcgiConfig) ReadTimeoutDuration

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

超时时间

func (*FastcgiConfig) Validate

func (this *FastcgiConfig) Validate() error

校验配置

type FastcgiList

type FastcgiList struct {
	Fastcgi []*FastcgiConfig `yaml:"fastcgi" json:"fastcgi"`
}

FastcgiList定义

func (*FastcgiList) AddFastcgi

func (this *FastcgiList) AddFastcgi(fastcgi *FastcgiConfig)

添加Fastcgi

func (*FastcgiList) AllFastcgi

func (this *FastcgiList) AllFastcgi() []*FastcgiConfig

取得所有的Fastcgi

func (*FastcgiList) FindFastcgi

func (this *FastcgiList) FindFastcgi(fastcgiId string) *FastcgiConfig

根据ID查找Fastcgi

func (*FastcgiList) NextFastcgi

func (this *FastcgiList) NextFastcgi() *FastcgiConfig

查找下一个可用的Fastcgi

func (*FastcgiList) RemoveFastcgi

func (this *FastcgiList) RemoveFastcgi(fastcgiId string)

删除Fastcgi

func (*FastcgiList) ValidateFastcgi

func (this *FastcgiList) ValidateFastcgi() error

校验

type FastcgiListInterface

type FastcgiListInterface interface {
	// 校验
	ValidateFastcgi() error

	// 取得所有的Fastcgi
	AllFastcgi() []*FastcgiConfig

	// 根据ID查找Fastcgi
	FindFastcgi(fastcgiId string) *FastcgiConfig

	// 添加Fastcgi
	AddFastcgi(fastcgi *FastcgiConfig)

	// 删除Fastcgi
	RemoveFastcgi(fastcgiId string)

	// 查找下一个可用的Fastcgi
	NextFastcgi() *FastcgiConfig
}

FastcgiList接口定义

type ForwardHTTPConfig

type ForwardHTTPConfig struct {
	EnableMITM bool `yaml:"enableMITM" json:"enableMITM"`
}

正向代理设置

func NewForwardHTTPConfig

func NewForwardHTTPConfig() *ForwardHTTPConfig

获取新对象

type GzipConfig

type GzipConfig struct {
	Level     int8     `yaml:"level" json:"level"`         // 1-9
	MinLength string   `yaml:"minLength" json:"minLength"` // 比如4m, 24k
	MimeTypes []string `yaml:"mimeTypes" json:"mimeTypes"` // 比如text/html, text/*
	// contains filtered or unexported fields
}

gzip配置

func (*GzipConfig) MatchContentType

func (this *GzipConfig) MatchContentType(contentType string) bool

检查是否匹配Content-Type

func (*GzipConfig) MinBytes

func (this *GzipConfig) MinBytes() int64

可压缩最小尺寸

func (*GzipConfig) Validate

func (this *GzipConfig) Validate() error

校验

type HSTSConfig

type HSTSConfig struct {
	On                bool     `yaml:"on" json:"on"`
	MaxAge            int      `yaml:"maxAge" json:"maxAge"` // 单位秒
	IncludeSubDomains bool     `yaml:"includeSubDomains" json:"includeSubDomains"`
	Preload           bool     `yaml:"preload" json:"preload"`
	Domains           []string `yaml:"domains" json:"domains"`
	// contains filtered or unexported fields
}

HSTS设置 参考: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Strict-Transport-Security

func (*HSTSConfig) HeaderKey

func (this *HSTSConfig) HeaderKey() string

Header Key

func (*HSTSConfig) HeaderValue

func (this *HSTSConfig) HeaderValue() string

取得当前的Header值

func (*HSTSConfig) Match

func (this *HSTSConfig) Match(domain string) bool

判断是否匹配域名

func (*HSTSConfig) Validate

func (this *HSTSConfig) Validate() error

校验

type IPRangeList

type IPRangeList struct {
	IPRanges []*shared.IPRangeConfig
}

IP Range列表

func (*IPRangeList) AddIPRange

func (this *IPRangeList) AddIPRange(ipRange *shared.IPRangeConfig)

添加

func (*IPRangeList) RemoveIPRange

func (this *IPRangeList) RemoveIPRange(ipRangeId string)

删除

func (*IPRangeList) Validate

func (this *IPRangeList) Validate() error

校验

type LocationConfig

type LocationConfig struct {
	shared.HeaderList `yaml:",inline"`
	FastcgiList       `yaml:",inline"`
	RewriteList       `yaml:",inline"`
	BackendList       `yaml:",inline"`

	On      bool   `yaml:"on" json:"on"`           // 是否开启
	Id      string `yaml:"id" json:"id"`           // ID
	Name    string `yaml:"name" json:"name"`       // 名称
	Pattern string `yaml:"pattern" json:"pattern"` // 匹配规则

	Async       bool          `yaml:"async" json:"async"`             // 是否异步请求 @TODO
	Notify      []interface{} `yaml:"notify" json:"notify"`           // 转发请求,可以配置转发策略 @TODO
	LogOnly     bool          `yaml:"logOnly" json:"logOnly"`         // 是否只记录日志 @TODO
	URLPrefix   string        `yaml:"urlPrefix" json:"urlPrefix"`     // 实际的URL前缀,目前和资源根目录配合使用
	Root        string        `yaml:"root" json:"root"`               // 资源根目录
	Index       []string      `yaml:"index" json:"index"`             // 默认文件
	Charset     string        `yaml:"charset" json:"charset"`         // 字符集设置
	MaxBodySize string        `yaml:"maxBodySize" json:"maxBodySize"` // 请求body最大尺寸

	GzipLevel1     int8        `yaml:"gzipLevel" json:"gzipLevel"`         // deprecated v0.1.8 Gzip压缩级别
	GzipMinLength1 string      `yaml:"gzipMinLength" json:"gzipMinLength"` // deprecated v0.1.8 需要压缩的最小内容尺寸
	Gzip           *GzipConfig `yaml:"gzip" json:"gzip"`

	AccessPolicy    *shared.AccessPolicy `yaml:"accessPolicy" json:"accessPolicy"`       // 访问控制
	RedirectToHttps bool                 `yaml:"redirectToHttps" json:"redirectToHttps"` // 是否自动跳转到Https

	// 日志
	AccessLog []*AccessLogConfig `yaml:"accessLog" json:"accessLog"` // 访问日志设置,如果为空表示继承上一级设置

	DisableAccessLog1 bool  `yaml:"disableAccessLog" json:"disableAccessLog"` // deprecated: 是否禁用访问日志
	AccessLogFields1  []int `yaml:"accessLogFields" json:"accessLogFields"`   // deprecated: 访问日志保留的字段,如果为nil,则表示没有设置
	DisableStat       bool  `yaml:"disableStat" json:"disableStat"`           // 是否禁用统计

	// 参考:http://nginx.org/en/docs/http/ngx_http_access_module.html
	Allow []string `yaml:"allow" json:"allow"` // 允许的终端地址 @TODO
	Deny  []string `yaml:"deny" json:"deny"`   // 禁止的终端地址 @TODO

	Proxy string `yaml:"proxy" json:"proxy"` //  代理配置 @TODO

	CachePolicy string `yaml:"cachePolicy" json:"cachePolicy"` // 缓存策略
	CacheOn     bool   `yaml:"cacheOn" json:"cacheOn"`         // 缓存是否打开

	WAFOn bool   `yaml:"wafOn" json:"wafOn"` // 是否启用
	WafId string `yaml:"wafId" json:"wafId"` // WAF ID

	// websocket设置
	Websocket *WebsocketConfig `yaml:"websocket" json:"websocket"`

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

	// 禁止访问的条件
	DenyCond []*shared.RequestCond `yaml:"denyCond" json:"denyCond"`
	DenyAll  bool                  `yaml:"denyAll" json:"denyAll"`

	IsBreak bool `yaml:"isBreak" json:"isBreak"` // 终止向下解析

	Pages           []*PageConfig   `yaml:"pages" json:"pages"`                   // 特殊页
	Shutdown        *ShutdownConfig `yaml:"shutdown" json:"shutdown"`             // 关闭页
	ShutdownPageOn1 bool            `yaml:"shutdownPageOn" json:"shutdownPageOn"` // deprecated: v0.1.8, 是否开启临时关闭页面
	ShutdownPage1   string          `yaml:"shutdownPage" json:"shutdownPage"`     // deprecated: v0.1.8, 临时关闭页面
	// contains filtered or unexported fields
}

路径配置

func NewLocation

func NewLocation() *LocationConfig

获取新对象

func (*LocationConfig) AddCond

func (this *LocationConfig) AddCond(cond *shared.RequestCond)

添加过滤条件

func (*LocationConfig) AddPage

func (this *LocationConfig) AddPage(page *PageConfig)

添加Page

func (*LocationConfig) AddRequestGroup

func (this *LocationConfig) AddRequestGroup(group *RequestGroup)

添加请求分组

func (*LocationConfig) CachePolicyObject

func (this *LocationConfig) CachePolicyObject() *shared.CachePolicy

缓存策略

func (*LocationConfig) CloneState

func (this *LocationConfig) CloneState(oldLocation *LocationConfig)

克隆运行时状态

func (*LocationConfig) Compatible

func (this *LocationConfig) Compatible(version string)

兼容性设置

func (*LocationConfig) IsCaseInsensitive

func (this *LocationConfig) IsCaseInsensitive() bool

是否大小写非敏感

func (*LocationConfig) IsDenied

func (this *LocationConfig) IsDenied(formatter func(source string) string) bool

判断是否屏蔽

func (*LocationConfig) IsReverse

func (this *LocationConfig) IsReverse() bool

是否翻转

func (*LocationConfig) Match

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

判断是否匹配路径

func (*LocationConfig) MatchKeyword

func (this *LocationConfig) MatchKeyword(keyword string) (matched bool, name string, tags []string)

匹配关键词

func (*LocationConfig) MatchRequestGroup

func (this *LocationConfig) MatchRequestGroup(formatter func(source string) string) *RequestGroup

使用请求匹配分组

func (*LocationConfig) MaxBodyBytes

func (this *LocationConfig) MaxBodyBytes() int64

最大Body尺寸

func (*LocationConfig) NextBackend

func (this *LocationConfig) NextBackend(call *shared.RequestCall) *BackendConfig

取得下一个可用的后端服务

func (*LocationConfig) OnAttach

func (this *LocationConfig) OnAttach()

装载事件

func (*LocationConfig) OnDetach

func (this *LocationConfig) OnDetach()

卸载事件

func (*LocationConfig) PatternString

func (this *LocationConfig) PatternString() string

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

func (*LocationConfig) PatternType

func (this *LocationConfig) PatternType() int

模式类型

func (*LocationConfig) RefersProxy

func (this *LocationConfig) RefersProxy(proxyId string) bool

是否在引用某个代理

func (*LocationConfig) SetPattern

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

组合参数为一个字符串

func (*LocationConfig) SetupScheduling

func (this *LocationConfig) SetupScheduling(isBackup bool)

设置调度算法

func (*LocationConfig) Validate

func (this *LocationConfig) Validate() error

校验

func (*LocationConfig) WAF

func (this *LocationConfig) WAF() *teawaf.WAF

WAF

type LocationPatternType

type LocationPatternType = int

匹配类型

type MimeTypeRule

type MimeTypeRule struct {
	Value  string
	Regexp *regexp.Regexp
}

mime type

type NodeConfig

type NodeConfig struct {
	Id            string   `yaml:"id" json:"id"`                       // ID
	On            bool     `yaml:"on" json:"on"`                       // 是否启用
	Name          string   `yaml:"name" json:"name"`                   // 名称
	ClusterId     string   `yaml:"clusterId" json:"clusterId"`         // 集群ID
	ClusterSecret string   `yaml:"clusterSecret" json:"clusterSecret"` // 集群秘钥
	ClusterAddr   string   `yaml:"clusterAddr" json:"clusterAddr"`     // 集群通讯地址
	Role          NodeRole `yaml:"role" json:"role"`                   // 角色
}

节点配置

func SharedNodeConfig

func SharedNodeConfig() *NodeConfig

取得当前节点配置 如果为nil,表示尚未配置集群

func (*NodeConfig) IsMaster

func (this *NodeConfig) IsMaster() bool

是否为Master

func (*NodeConfig) Save

func (this *NodeConfig) Save() error

保存到文件

type NodeRole

type NodeRole = string

角色定义

type PageConfig

type PageConfig struct {
	On        bool     `yaml:"on" json:"on"`               // TODO
	Status    []string `yaml:"status" json:"status"`       // 响应支持40x, 50x, 3x2
	URL       string   `yaml:"url" json:"url"`             // URL
	NewStatus int      `yaml:"newStatus" json:"newStatus"` // 新状态码
	// contains filtered or unexported fields
}

特殊页面配置

func NewPageConfig

func NewPageConfig() *PageConfig

获取新对象

func (*PageConfig) Match

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

检查是否匹配

func (*PageConfig) Validate

func (this *PageConfig) Validate() error

校验

type ProxySetting

type ProxySetting struct {
	MatchDomainStrictly bool `yaml:"matchDomainStrictly" json:"matchDomainStrictly"` // 是否严格匹配域名

}

代理全局设置

func LoadProxySetting

func LoadProxySetting() *ProxySetting

从配置文件中加载配置

func SharedProxySetting

func SharedProxySetting() *ProxySetting

取得共享的代理设置

func (*ProxySetting) Save

func (this *ProxySetting) Save() error

保存

type RequestGroup

type RequestGroup struct {
	BackendList `yaml:",inline"`

	Id              string                  `yaml:"id" json:"id"`                           // ID
	Name            string                  `yaml:"name" json:"name"`                       // 名称
	Cond            []*shared.RequestCond   `yaml:"conds" json:"conds"`                     // 匹配条件
	IPRanges        []*shared.IPRangeConfig `yaml:"ipRanges" json:"ipRanges"`               // IP范围
	IsDefault       bool                    `yaml:"isDefault" json:"isDefault"`             // 是否为默认分组
	RequestHeaders  []*shared.HeaderConfig  `yaml:"requestHeaders" json:"requestHeaders"`   // 请求Header
	ResponseHeaders []*shared.HeaderConfig  `yaml:"responseHeaders" json:"responseHeaders"` // 响应Header
	// contains filtered or unexported fields
}

请求条件分组

func NewRequestGroup

func NewRequestGroup() *RequestGroup

获取新对象

func (*RequestGroup) AddCond

func (this *RequestGroup) AddCond(cond *shared.RequestCond)

添加匹配条件

func (*RequestGroup) AddIPRange

func (this *RequestGroup) AddIPRange(ipRange *shared.IPRangeConfig)

添加IP范围

func (*RequestGroup) AddRequestHeader

func (this *RequestGroup) AddRequestHeader(header *shared.HeaderConfig)

添加请求Header

func (*RequestGroup) AddResponseHeader

func (this *RequestGroup) AddResponseHeader(header *shared.HeaderConfig)

添加响应Header

func (*RequestGroup) Copy

func (this *RequestGroup) Copy() *RequestGroup

复制

func (*RequestGroup) HasFilters

func (this *RequestGroup) HasFilters() bool

判断是否有过滤条件

func (*RequestGroup) HasRequestHeaders

func (this *RequestGroup) HasRequestHeaders() bool

判断是否有请求Header

func (*RequestGroup) HasResponseHeaders

func (this *RequestGroup) HasResponseHeaders() bool

判断是否有响应Header

func (*RequestGroup) Match

func (this *RequestGroup) Match(formatter func(source string) string) bool

判断匹配

func (*RequestGroup) Validate

func (this *RequestGroup) Validate() error

校验

type RewriteList

type RewriteList struct {
	Rewrite []*RewriteRule `yaml:"rewrite" json:"rewrite"`
}

RewriteList定义

func (*RewriteList) AddRewriteRule

func (this *RewriteList) AddRewriteRule(rewrite *RewriteRule)

添加Rewrite

func (*RewriteList) AllRewriteRules

func (this *RewriteList) AllRewriteRules() []*RewriteRule

取得所有的Rewrite

func (*RewriteList) FindRewriteRule

func (this *RewriteList) FindRewriteRule(rewriteId string) *RewriteRule

根据ID查找Rewrite

func (*RewriteList) RemoveRewriteRule

func (this *RewriteList) RemoveRewriteRule(rewriteId string)

删除Rewrite

func (*RewriteList) ValidateRewriteRules

func (this *RewriteList) ValidateRewriteRules() error

校验

type RewriteListInterface

type RewriteListInterface interface {
	// 校验
	ValidateRewriteRules() error

	// 取得所有的Rewrite
	AllRewriteRules() []*RewriteRule

	// 根据ID查找Rewrite
	FindRewriteRule(rewriteId string) *RewriteRule

	// 添加Rewrite
	AddRewriteRule(rewrite *RewriteRule)

	// 删除Rewrite
	RemoveRewriteRule(rewriteId string)
}

RewriteList接口

type RewriteRule

type RewriteRule struct {
	shared.HeaderList `yaml:",inline"`

	On bool   `yaml:"on" json:"on"` // 是否开启
	Id string `yaml:"id" json:"id"` // ID

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

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

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

	// 选项
	// @TODO 使用具体的语义化的字段代替
	Flags       []string `yaml:"flags" json:"flags"`
	FlagOptions maps.Map `yaml:"flagOptions" json:"flagOptions"` // flag => options map

	IsBreak     bool   `yaml:"isBreak" json:"isBreak"`         // 终止向下解析
	IsPermanent bool   `yaml:"isPermanent" json:"isPermanent"` // 是否持久性跳转
	ProxyHost   string `yaml:"host" json:"host"`               // 代理模式下重写后的Host
	// contains filtered or unexported fields
}

重写规则定义

参考 - http://nginx.org/en/docs/http/ngx_http_rewrite_module.html - https://httpd.apache.org/docs/current/mod/mod_rewrite.html - https://httpd.apache.org/docs/2.4/rewrite/flags.html

func NewRewriteRule

func NewRewriteRule() *RewriteRule

获取新对象

func (*RewriteRule) AddCond

func (this *RewriteRule) AddCond(cond *shared.RequestCond)

添加过滤条件

func (*RewriteRule) AddFlag

func (this *RewriteRule) AddFlag(flag string, options maps.Map)

添加Flag

func (*RewriteRule) IsExternalURL

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

判断是否是外部URL

func (*RewriteRule) Match

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

对某个请求执行规则

func (*RewriteRule) RedirectMode

func (this *RewriteRule) RedirectMode() string

跳转模式

func (*RewriteRule) RefersProxy

func (this *RewriteRule) RefersProxy(proxyId string) bool

是否在引用某个代理

func (*RewriteRule) ResetFlags

func (this *RewriteRule) ResetFlags()

重置模式

func (*RewriteRule) TargetProxy

func (this *RewriteRule) TargetProxy() string

获取目标类型

func (*RewriteRule) TargetType

func (this *RewriteRule) TargetType() int

获取目标类型

func (*RewriteRule) TargetURL

func (this *RewriteRule) TargetURL() string

获取目标URL

func (*RewriteRule) Validate

func (this *RewriteRule) Validate() error

校验

type SSLCertConfig

type SSLCertConfig struct {
	Id          string `yaml:"id" json:"id"`
	On          bool   `yaml:"on" json:"on"`
	Description string `yaml:"description" json:"description"` // 说明
	CertFile    string `yaml:"certFile" json:"certFile"`
	KeyFile     string `yaml:"keyFile" json:"keyFile"`
	IsLocal     bool   `yaml:"isLocal" json:"isLocal"`       // 是否为本地文件
	TaskId      string `yaml:"taskId" json:"taskId"`         // 生成证书任务ID
	IsShared    bool   `yaml:"isShared" json:"isShared"`     // 是否为公用组件
	ServerName  string `yaml:"serverName" json:"serverName"` // 证书使用的主机名,在请求TLS服务器时需要
	IsCA        bool   `yaml:"isCA" json:"isCA"`             // 是否为CA证书
	// contains filtered or unexported fields
}

SSL证书

func NewSSLCertConfig

func NewSSLCertConfig(certFile string, keyFile string) *SSLCertConfig

获取新的SSL证书

func (*SSLCertConfig) CertObject

func (this *SSLCertConfig) CertObject() *tls.Certificate

获取证书对象

func (*SSLCertConfig) DNSNames

func (this *SSLCertConfig) DNSNames() []string

证书中的域名

func (*SSLCertConfig) DeleteFiles

func (this *SSLCertConfig) DeleteFiles() error

删除文件

func (*SSLCertConfig) FindShared

func (this *SSLCertConfig) FindShared() *SSLCertConfig

查找共享的证书

func (*SSLCertConfig) FullCertPath

func (this *SSLCertConfig) FullCertPath() string

证书文件路径

func (*SSLCertConfig) FullKeyPath

func (this *SSLCertConfig) FullKeyPath() string

密钥文件路径

func (*SSLCertConfig) Issuer

func (this *SSLCertConfig) Issuer() pkix.Name

发行信息

func (*SSLCertConfig) MatchDomain

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

校验是否匹配某个域名

func (*SSLCertConfig) MatchKeyword

func (this *SSLCertConfig) MatchKeyword(keyword string) (matched bool, name string, tags []string)

匹配关键词

func (*SSLCertConfig) ReadCert

func (this *SSLCertConfig) ReadCert() ([]byte, error)

读取证书文件

func (*SSLCertConfig) ReadKey

func (this *SSLCertConfig) ReadKey() ([]byte, error)

读取密钥文件

func (*SSLCertConfig) TimeAfter

func (this *SSLCertConfig) TimeAfter() time.Time

结束时间

func (*SSLCertConfig) TimeBefore

func (this *SSLCertConfig) TimeBefore() time.Time

开始时间

func (*SSLCertConfig) Validate

func (this *SSLCertConfig) Validate() error

校验

type SSLCertList

type SSLCertList struct {
	Certs []*SSLCertConfig `yaml:"certs" json:"certs"` // 证书
	Tasks []*SSLCertTask   `yaml:"tasks" json:"tasks"` // 任务
}

公共的SSL证书列表

func NewSSLCertList

func NewSSLCertList() *SSLCertList

获取新对象

func SharedSSLCertList

func SharedSSLCertList() *SSLCertList

获取证书列表实例 一定会返回不为nil的值

func (*SSLCertList) AddCert

func (this *SSLCertList) AddCert(cert *SSLCertConfig)

添加证书

func (*SSLCertList) AddTask

func (this *SSLCertList) AddTask(task *SSLCertTask)

添加任务

func (*SSLCertList) FindCert

func (this *SSLCertList) FindCert(certId string) *SSLCertConfig

查找证书

func (*SSLCertList) FindTask

func (this *SSLCertList) FindTask(taskId string) *SSLCertTask

查找任务

func (*SSLCertList) RemoveCert

func (this *SSLCertList) RemoveCert(certId string)

删除证书

func (*SSLCertList) RemoveTask

func (this *SSLCertList) RemoveTask(taskId string)

删除任务

func (*SSLCertList) Save

func (this *SSLCertList) Save() error

保存

type SSLCertTask

type SSLCertTask struct {
	Id       string `yaml:"id" json:"id"`             // ID
	On       bool   `yaml:"on" json:"on"`             // 是否启用
	RunAt    int64  `yaml:"runAt" json:"runAt"`       // 运行时间
	RunError string `yaml:"runError" json:"runError"` // 运行错误

	Request *ACMERequest `yaml:"request" json:"request"` // ACME信息
}

证书生成任务

func NewSSLCertTask

func NewSSLCertTask() *SSLCertTask

获取新对象

type SSLClientAuthType

type SSLClientAuthType = int

认证类型

const (
	SSLClientAuthTypeNoClientCert               SSLClientAuthType = 0
	SSLClientAuthTypeRequestClientCert          SSLClientAuthType = 1
	SSLClientAuthTypeRequireAnyClientCert       SSLClientAuthType = 2
	SSLClientAuthTypeVerifyClientCertIfGiven    SSLClientAuthType = 3
	SSLClientAuthTypeRequireAndVerifyClientCert SSLClientAuthType = 4
)

type SSLConfig

type SSLConfig struct {
	On bool `yaml:"on" json:"on"` // 是否开启

	Certificate    string `yaml:"certificate" json:"certificate"`       // 证书文件, deprecated in v0.1.4
	CertificateKey string `yaml:"certificateKey" json:"certificateKey"` // 密钥, deprecated in v0.1.4

	Certs           []*SSLCertConfig  `yaml:"certs" json:"certs"`
	CertTasks       []*SSLCertTask    `yaml:"certTasks" json:"certTasks"`
	ClientAuthType  SSLClientAuthType `yaml:"clientAuthType" json:"clientAuthType"`   // 客户端认证类型
	ClientCACertIds []string          `yaml:"clientCACertIds" json:"clientCACertIds"` // 客户端认证CA

	Listen       []string         `yaml:"listen" json:"listen"`             // 网络地址
	MinVersion   TLSVersion       `yaml:"minVersion" json:"minVersion"`     // 支持的最小版本
	CipherSuites []TLSCipherSuite `yaml:"cipherSuites" json:"cipherSuites"` // 加密算法套件

	HSTS          *HSTSConfig `yaml:"hsts2" json:"hsts"`                  // HSTS配置,yaml之所以使用hsts2,是因为要和以前的版本分开
	HTTP2Disabled bool        `yaml:"http2Disabled" json:"http2Disabled"` // 是否禁用HTTP2
	// contains filtered or unexported fields
}

SSL配置

func NewSSLConfig

func NewSSLConfig() *SSLConfig

获取新对象

func (*SSLConfig) AddCert

func (this *SSLConfig) AddCert(cert *SSLCertConfig)

添加证书

func (*SSLConfig) AddCertTask

func (this *SSLConfig) AddCertTask(certTask *SSLCertTask)

添加证书任务

func (*SSLConfig) CAPool

func (this *SSLConfig) CAPool() *x509.CertPool

CA证书Pool,用于TLS对客户端进行认证

func (*SSLConfig) ContainsFile

func (this *SSLConfig) ContainsFile(file string) bool

是否包含某个证书或密钥路径

func (*SSLConfig) DeleteFiles

func (this *SSLConfig) DeleteFiles() error

删除证书文件

func (*SSLConfig) FindCert

func (this *SSLConfig) FindCert(certId string) *SSLCertConfig

查找单个证书配置

func (*SSLConfig) FindCertTask

func (this *SSLConfig) FindCertTask(certTaskId string) *SSLCertTask

查找证书任务

func (*SSLConfig) FirstCert

func (this *SSLConfig) FirstCert() *tls.Certificate

取得第一个证书

func (*SSLConfig) MatchDomain

func (this *SSLConfig) MatchDomain(domain string) (cert *tls.Certificate, ok bool)

校验是否匹配某个域名

func (*SSLConfig) ParseListenAddresses

func (this *SSLConfig) ParseListenAddresses() []string

分解所有监听地址

func (*SSLConfig) RemoveCertTask

func (this *SSLConfig) RemoveCertTask(certTaskId string)

删除证书任务

func (*SSLConfig) TLSCipherSuites

func (this *SSLConfig) TLSCipherSuites() []uint16

套件

func (*SSLConfig) TLSMinVersion

func (this *SSLConfig) TLSMinVersion() uint16

取得最小版本

func (*SSLConfig) Validate

func (this *SSLConfig) Validate() error

校验配置

type SchedulingConfig

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

调度算法配置

func NewSchedulingConfig

func NewSchedulingConfig() *SchedulingConfig

获取新对象

type ServerConfig

type ServerConfig struct {
	shared.HeaderList `yaml:",inline"`
	FastcgiList       `yaml:",inline"`
	RewriteList       `yaml:",inline"`
	BackendList       `yaml:",inline"`

	On bool `yaml:"on" json:"on"`

	Id              string   `yaml:"id" json:"id"`                           // ID
	TeaVersion      string   `yaml:"teaVersion" json:"teaVersion"`           // Tea版本
	Description     string   `yaml:"description" json:"description"`         // 描述
	Name            []string `yaml:"name" json:"name"`                       // 域名
	Http            bool     `yaml:"http" json:"http"`                       // 是否支持HTTP
	RedirectToHttps bool     `yaml:"redirectToHttps" json:"redirectToHttps"` // 是否自动跳转到Https
	IsDefault       bool     `yaml:"isDefault" json:"isDefault"`             // 是否默认的服务,找不到匹配域名时有限使用此配置

	// 监听地址
	Listen []string `yaml:"listen" json:"listen"`

	Root        string            `yaml:"root" json:"root"`               // 资源根目录
	Index       []string          `yaml:"index" json:"index"`             // 默认文件
	Charset     string            `yaml:"charset" json:"charset"`         // 字符集
	Locations   []*LocationConfig `yaml:"locations" json:"locations"`     // 地址配置
	MaxBodySize string            `yaml:"maxBodySize" json:"maxBodySize"` // 请求body最大尺寸

	GzipLevel1     uint8       `yaml:"gzipLevel" json:"gzipLevel"`         // deprecated in v0.1.8: Gzip压缩级别
	GzipMinLength1 string      `yaml:"gzipMinLength" json:"gzipMinLength"` // deprecated in v0.1.8: 需要压缩的最小内容尺寸
	Gzip           *GzipConfig `yaml:"gzip" json:"gzip"`

	// 访问日志
	AccessLog []*AccessLogConfig `yaml:"accessLog" json:"accessLog"` // 访问日志配置

	DisableAccessLog1 bool  `yaml:"disableAccessLog" json:"disableAccessLog"` // deprecated: 是否禁用访问日志
	AccessLogFields1  []int `yaml:"accessLogFields" json:"accessLogFields"`   // deprecated: 访问日志保留的字段,如果为nil,则表示没有设置

	// 统计
	DisableStat bool `yaml:"disableStat" json:"disableStat"` // 是否禁用统计

	// SSL
	SSL *SSLConfig `yaml:"ssl" json:"ssl"`

	// TCP,如果有此配置的说明为TCP代理
	TCP *TCPConfig `yaml:"tcp" json:"tcp"`

	// ForwardHTTP,如果有此配置的说明为正向HTTP代理
	ForwardHTTP *ForwardHTTPConfig `yaml:"forwardHTTP" json:"forwardHTTP"`

	// 参考:http://nginx.org/en/docs/http/ngx_http_access_module.html
	Allow []string `yaml:"allow" json:"allow"` //TODO
	Deny  []string `yaml:"deny" json:"deny"`   //TODO

	Filename string `yaml:"filename" json:"filename"` // 配置文件名

	Proxy string `yaml:"proxy" json:"proxy"` //  代理配置 TODO

	CachePolicy string `yaml:"cachePolicy" json:"cachePolicy"` // 缓存策略
	CacheOn     bool   `yaml:"cacheOn" json:"cacheOn"`         // 缓存是否打开

	WAFOn bool   `yaml:"wafOn" json:"wafOn"` // 是否启用
	WafId string `yaml:"wafId" json:"wafId"` // WAF ID

	// API相关
	API *api.APIConfig `yaml:"api" json:"api"` // API配置

	// 看板
	RealtimeBoard *Board   `yaml:"realtimeBoard" json:"realtimeBoard"` // 即时看板
	StatBoard     *Board   `yaml:"statBoard" json:"statBoard"`         // 统计看板
	StatItems     []string `yaml:"statItems" json:"statItems"`         // 统计指标

	// 是否开启静态文件加速
	CacheStatic bool `yaml:"cacheStatic" json:"cacheStatic"`

	// 请求分组
	RequestGroups []*RequestGroup `yaml:"requestGroups" json:"requestGroups"` // 请求条件分组

	Pages           []*PageConfig   `yaml:"pages" json:"pages"`                   // 特殊页,更高级的需求应该通过Location来设置
	Shutdown        *ShutdownConfig `yaml:"shutdown" json:"shutdown"`             // 关闭页
	ShutdownPageOn1 bool            `yaml:"shutdownPageOn" json:"shutdownPageOn"` // deprecated: v0.1.8, 是否开启临时关闭页面
	ShutdownPage1   string          `yaml:"shutdownPage" json:"shutdownPage"`     // deprecated: v0.1.8, 临时关闭页面

	Version int `yaml:"version" json:"version"` // 版本

	// 隧道相关
	Tunnel *TunnelConfig `yaml:"tunnel" json:"tunnel"`

	// 通知设置
	NoticeSetting map[notices.NoticeLevel][]*notices.NoticeReceiver `yaml:"noticeSetting" json:"noticeSetting"`

	// 通知条目设置
	NoticeItems struct {
		BackendDown *notices.Item `yaml:"backendDown" json:"backendDown"`
		BackendUp   *notices.Item `yaml:"backendUp" json:"backendUp"`
	} `yaml:"noticeItems" json:"noticeItems"`
	// contains filtered or unexported fields
}

服务配置

func LoadServerConfigsFromDir

func LoadServerConfigsFromDir(dirPath string) []*ServerConfig

从目录中加载配置

func NewServerConfig

func NewServerConfig() *ServerConfig

取得一个新的服务配置

func NewServerConfigFromFile

func NewServerConfigFromFile(filename string) (*ServerConfig, error)

从配置文件中读取配置信息

func NewServerConfigFromId

func NewServerConfigFromId(serverId string) *ServerConfig

通过ID读取配置信息

func (*ServerConfig) AddListen

func (this *ServerConfig) AddListen(address string)

添加监听地址

func (*ServerConfig) AddLocation

func (this *ServerConfig) AddLocation(location *LocationConfig)

添加路径规则

func (*ServerConfig) AddName

func (this *ServerConfig) AddName(name ...string)

添加域名

func (*ServerConfig) AddNoticeReceiver

func (this *ServerConfig) AddNoticeReceiver(level notices.NoticeLevel, receiver *notices.NoticeReceiver)

添加通知接收者

func (*ServerConfig) AddPage

func (this *ServerConfig) AddPage(page *PageConfig)

添加Page

func (*ServerConfig) AddRequestGroup

func (this *ServerConfig) AddRequestGroup(group *RequestGroup)

添加请求分组

func (*ServerConfig) AddStatItem

func (this *ServerConfig) AddStatItem(item string)

统计指标

func (*ServerConfig) CachePolicyObject

func (this *ServerConfig) CachePolicyObject() *shared.CachePolicy

缓存策略

func (*ServerConfig) CloneState

func (this *ServerConfig) CloneState(oldServer *ServerConfig)

克隆运行时状态

func (*ServerConfig) Delete

func (this *ServerConfig) Delete() error

删除

func (*ServerConfig) FindAllNoticeReceivers

func (this *ServerConfig) FindAllNoticeReceivers(level ...notices.NoticeLevel) []*notices.NoticeReceiver

查找一个或多个级别对应的接收者,并合并相同的接收者

func (*ServerConfig) FindBackendList

func (this *ServerConfig) FindBackendList(locationId string, websocket bool) (backendList BackendListInterface, err error)

查找后端服务器列表

func (*ServerConfig) FindCerts

func (this *ServerConfig) FindCerts(certId string) (result []*SSLCertConfig)

查找证书

func (*ServerConfig) FindFastcgiList

func (this *ServerConfig) FindFastcgiList(locationId string) (fastcgiList FastcgiListInterface, err error)

查找FastcgiList

func (*ServerConfig) FindHeaderList

func (this *ServerConfig) FindHeaderList(locationId string, backendId string, rewriteId string, fastcgiId string) (headerList shared.HeaderListInterface, err error)

查找HeaderList

func (*ServerConfig) FindLocation

func (this *ServerConfig) FindLocation(locationId string) *LocationConfig

根据Id查找Location

func (*ServerConfig) FindRequestGroup

func (this *ServerConfig) FindRequestGroup(groupId string) *RequestGroup

查找请求分组

func (*ServerConfig) FindRewriteList

func (this *ServerConfig) FindRewriteList(locationId string) (rewriteList RewriteListInterface, err error)

查找重写规则

func (*ServerConfig) FirstName

func (this *ServerConfig) FirstName() string

取得第一个非泛解析的域名

func (*ServerConfig) IsForwardHTTP

func (this *ServerConfig) IsForwardHTTP() bool

是否为正向代理

func (*ServerConfig) IsHTTP

func (this *ServerConfig) IsHTTP() bool

判断是否为HTTP

func (*ServerConfig) IsTCP

func (this *ServerConfig) IsTCP() bool

判断是否为TCP

func (*ServerConfig) LocationAtIndex

func (this *ServerConfig) LocationAtIndex(index int) *LocationConfig

获取某个位置上的配置

func (*ServerConfig) MatchKeyword

func (this *ServerConfig) MatchKeyword(keyword string) (matched bool, name string, tags []string)

检查是否匹配关键词

func (*ServerConfig) MatchName

func (this *ServerConfig) MatchName(name string) (matchedName string, matched bool)

判断是否和域名匹配

func (*ServerConfig) MatchRequestGroup

func (this *ServerConfig) MatchRequestGroup(formatter func(source string) string) *RequestGroup

使用请求匹配分组

func (*ServerConfig) MaxBodyBytes

func (this *ServerConfig) MaxBodyBytes() int64

最大Body尺寸

func (*ServerConfig) MoveLocation

func (this *ServerConfig) MoveLocation(fromIndex int, toIndex int)

移动位置

func (*ServerConfig) NextBackend

func (this *ServerConfig) NextBackend(call *shared.RequestCall) *BackendConfig

取得下一个可用的后端服务

func (*ServerConfig) NextBackendIgnore

func (this *ServerConfig) NextBackendIgnore(call *shared.RequestCall, backendIds []string) *BackendConfig

取得下一个可用的后端服务,并排除某个后端

func (*ServerConfig) OnAttach

func (this *ServerConfig) OnAttach()

装载事件

func (*ServerConfig) OnDetach

func (this *ServerConfig) OnDetach()

卸载事件

func (*ServerConfig) ParseListenAddresses

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

分解所有监听地址

func (*ServerConfig) RefersProxy

func (this *ServerConfig) RefersProxy(proxyId string) (description string, referred bool)

是否在引用某个代理

func (*ServerConfig) RemoveLocation

func (this *ServerConfig) RemoveLocation(locationId string)

删除Location

func (*ServerConfig) RemoveNoticeReceiver

func (this *ServerConfig) RemoveNoticeReceiver(level notices.NoticeLevel, receiverId string)

删除通知接收者

func (*ServerConfig) RemoveRequestGroup

func (this *ServerConfig) RemoveRequestGroup(groupId string)

删除请求分组

func (*ServerConfig) RemoveStatItem

func (this *ServerConfig) RemoveStatItem(item string)

删除统计指标

func (*ServerConfig) Save

func (this *ServerConfig) Save() error

保存

func (*ServerConfig) SetupNoticeItems

func (this *ServerConfig) SetupNoticeItems()

设置通知

func (*ServerConfig) SetupNoticeItemsFromRequest

func (this *ServerConfig) SetupNoticeItemsFromRequest(req *http.Request)

从请求中构建通知设置

func (*ServerConfig) SetupScheduling

func (this *ServerConfig) SetupScheduling(isBackup bool)

设置调度算法

func (*ServerConfig) Validate

func (this *ServerConfig) Validate() error

校验配置

func (*ServerConfig) WAF

func (this *ServerConfig) WAF() *teawaf.WAF

WAF策略

type ServerGroup

type ServerGroup struct {
	Id        string   `yaml:"id" json:"id"`
	IsOn      bool     `yaml:"isOn" json:"isOn"`
	Name      string   `yaml:"name" json:"name"`
	ServerIds []string `yaml:"serverIds" json:"serverIds"`
}

func NewServerGroup

func NewServerGroup() *ServerGroup

func (*ServerGroup) Add

func (this *ServerGroup) Add(serverId ...string)

func (*ServerGroup) Contains

func (this *ServerGroup) Contains(serverId string) bool

func (*ServerGroup) Remove

func (this *ServerGroup) Remove(serverId string)

type ServerGroupList

type ServerGroupList struct {
	Groups []*ServerGroup `yaml:"groups" json:"groups"`
}

func SharedServerGroupList

func SharedServerGroupList() *ServerGroupList

func (*ServerGroupList) Add

func (this *ServerGroupList) Add(group *ServerGroup)

func (*ServerGroupList) ContainsServer

func (this *ServerGroupList) ContainsServer(serverId string) bool

检查是否包含某个代理服务ID

func (*ServerGroupList) Find

func (this *ServerGroupList) Find(id string) *ServerGroup

查找分组

func (*ServerGroupList) Remove

func (this *ServerGroupList) Remove(id string)

func (*ServerGroupList) Save

func (this *ServerGroupList) Save() error

保存

type ServerList

type ServerList struct {
	Files []string `yaml:"files" json:"files"`
}

Server列表

func SharedServerList

func SharedServerList() (*ServerList, error)

取得Server列表

func (*ServerList) AddServer

func (this *ServerList) AddServer(serverFile string)

添加Server

func (*ServerList) FindAllServers

func (this *ServerList) FindAllServers() []*ServerConfig

查找所有Servers

func (*ServerList) MoveServer

func (this *ServerList) MoveServer(fromIndex int, toIndex int)

移动位置

func (*ServerList) RemoveServer

func (this *ServerList) RemoveServer(serverFile string)

删除Server

func (*ServerList) Save

func (this *ServerList) Save() error

保存

type ShutdownConfig

type ShutdownConfig struct {
	On     bool   `yaml:"on" json:"on"`
	URL    string `yaml:"url" json:"url"`
	Status int    `yaml:"status" json:"status"`
}

关闭页面配置

func NewShutdownConfig

func NewShutdownConfig() *ShutdownConfig

获取新对象

func (*ShutdownConfig) Validate

func (this *ShutdownConfig) Validate() error

校验

type TCPConfig

type TCPConfig struct {
	TCPOn           bool `yaml:"tcpOn" json:"tcpOn"`                     // 是否开启TCP
	ReadBufferSize  int  `yaml:"readBufferSize" json:"readBufferSize"`   // 读缓冲区尺寸,默认4K
	WriteBufferSize int  `yaml:"writeBufferSize" json:"writeBufferSize"` // 写缓冲区尺寸,默认4K
}

TCP代理配置

func NewTCPConfig

func NewTCPConfig() *TCPConfig

获取新对象

func (*TCPConfig) Validate

func (this *TCPConfig) Validate() error

校验

type TLSCipherSuite

type TLSCipherSuite = string

Cipher Suites

type TLSVersion

type TLSVersion = string

TLS Version

type TimePast

type TimePast = string

常用时间范围

const (
	TimePast5m  TimePast = "past5m"
	TimePast15m TimePast = "past15m"
	TimePast1h  TimePast = "past1h"
	TimePast6h  TimePast = "past6h"
	TimePast12h TimePast = "past12h"
	TimePast24h TimePast = "past24h"
	TimePast1d  TimePast = "past1d"
	TimePast2d  TimePast = "past2d"
	TimePast7d  TimePast = "past7d"
	TimePast30d TimePast = "past30d"
)

type TimeUnit

type TimeUnit = string

时间单位

const (
	TimeUnitSecond TimeUnit = "SECOND"
	TimeUnitMinute TimeUnit = "MINUTE"
	TimeUnitHour   TimeUnit = "HOUR"
	TimeUnitDay    TimeUnit = "DAY"
	TimeUnitMonth  TimeUnit = "MONTH"
	TimeUnitYear   TimeUnit = "YEAR"
)

func TimePastUnit

func TimePastUnit(past TimePast) TimeUnit

type TunnelConfig

type TunnelConfig struct {
	Id       string           `yaml:"id" json:"id"`             // ID
	On       bool             `yaml:"on" json:"on"`             // 是否启用
	Endpoint string           `yaml:"endpoint" json:"endpoint"` // 终端地址
	Secret   string           `yaml:"secret" json:"secret"`     // 连接用的密钥
	TLS      bool             `yaml:"tls" json:"tls"`           // 是否支持TLS TODO 暂时没有实现
	Certs    []*SSLCertConfig `yaml:"certs" json:"certs"`       // TLS证书 TODO 暂时没有实现
	// contains filtered or unexported fields
}

网络隧道定义

func NewTunnelConfig

func NewTunnelConfig() *TunnelConfig

隧道设置

func (*TunnelConfig) AddError

func (this *TunnelConfig) AddError(err string)

设置错误信息

func (*TunnelConfig) Errors

func (this *TunnelConfig) Errors() []string

获取错误信息

func (*TunnelConfig) IsActive

func (this *TunnelConfig) IsActive() bool

判断是否已启动

func (*TunnelConfig) SetIsActive

func (this *TunnelConfig) SetIsActive(isActive bool)

设置是否已启动

func (*TunnelConfig) Validate

func (this *TunnelConfig) Validate() error

校验

type WAFList

type WAFList struct {
	Files []string `yaml:"files" json:"files"`
}

WAF列表

func SharedWAFList

func SharedWAFList() *WAFList

获取共享的WAF列表

func (*WAFList) AddFile

func (this *WAFList) AddFile(filename string)

添加文件名

func (*WAFList) FindAllConfigs

func (this *WAFList) FindAllConfigs() []*teawaf.WAF

查找所有WAF配置

func (*WAFList) FindWAF

func (this *WAFList) FindWAF(wafId string) *teawaf.WAF

查找单个WAF配置

func (*WAFList) RemoveFile

func (this *WAFList) RemoveFile(filename string)

删除文件

func (*WAFList) Save

func (this *WAFList) Save() error

保存文件

func (*WAFList) SaveWAF

func (this *WAFList) SaveWAF(waf *teawaf.WAF) error

保存单个WAF配置

type WebConfig

type WebConfig struct {
	TeaGo.ServerConfig `yaml:",inline"`

	CertId string `yaml:"certId" json:"certId"` // 代理全局中的证书
}

Web 配置

func LoadWebConfig

func LoadWebConfig() (*WebConfig, error)

加载配置

func (*WebConfig) Save

func (this *WebConfig) Save() error

保存

type WebsocketConfig

type WebsocketConfig struct {
	// 后端服务器列表
	BackendList `yaml:",inline"`

	On bool `yaml:"on" json:"on"` // 是否开启

	// 握手超时时间
	HandshakeTimeout string `yaml:"handshakeTimeout" json:"handshakeTimeout"`

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

	// 转发方式
	ForwardMode WebsocketForwardMode `yaml:"forwardMode" json:"forwardMode"`
	// contains filtered or unexported fields
}

websocket设置

func NewWebsocketConfig

func NewWebsocketConfig() *WebsocketConfig

获取新对象

func (*WebsocketConfig) AddRequestGroup

func (this *WebsocketConfig) AddRequestGroup(group *RequestGroup)

添加请求分组

func (*WebsocketConfig) CloneState

func (this *WebsocketConfig) CloneState(oldWebsocket *WebsocketConfig)

克隆运行时状态

func (*WebsocketConfig) ForwardModeSummary

func (this *WebsocketConfig) ForwardModeSummary() maps.Map

转发模式名称

func (*WebsocketConfig) HandshakeTimeoutDuration

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

获取握手超时时间

func (*WebsocketConfig) MatchOrigin

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

匹配域名

func (*WebsocketConfig) MatchRequestGroup

func (this *WebsocketConfig) MatchRequestGroup(formatter func(source string) string) *RequestGroup

使用请求匹配分组

func (*WebsocketConfig) NextBackend

func (this *WebsocketConfig) NextBackend(call *shared.RequestCall) *BackendConfig

取得下一个可用的后端服务

func (*WebsocketConfig) OnDetach

func (this *WebsocketConfig) OnDetach()

卸载方法

func (*WebsocketConfig) SetupScheduling

func (this *WebsocketConfig) SetupScheduling(isBackup bool)

设置调度算法

func (*WebsocketConfig) Validate

func (this *WebsocketConfig) Validate() error

校验

type WebsocketForwardMode

type WebsocketForwardMode = string

Websocket转发类型

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

判断匹配

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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