teaconfigs

package
v0.1.72 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2019 License: MIT Imports: 49 Imported by: 40

Documentation

Index

Constants

View Source
const (
	IPRangeTypeRange = IPRangeType(1)
	IPRangeTypeCIDR  = IPRangeType(2)
)
View Source
const (
	LocationPatternTypePrefix = 1
	LocationPatternTypeExact  = 2
	LocationPatternTypeRegexp = 3
)

内置的匹配类型定义

View Source
const (
	NodeRoleMaster = "MASTER"
	NodeRoleSlave  = "SLAVE"
)
View Source
const (
	RequestCondOperatorRegexp      = "regexp"
	RequestCondOperatorNotRegexp   = "not regexp"
	RequestCondOperatorGt          = "gt"
	RequestCondOperatorGte         = "gte"
	RequestCondOperatorLt          = "lt"
	RequestCondOperatorLte         = "lte"
	RequestCondOperatorEq          = "eq"
	RequestCondOperatorNot         = "not"
	RequestCondOperatorPrefix      = "prefix"
	RequestCondOperatorSuffix      = "suffix"
	RequestCondOperatorContains    = "contains"
	RequestCondOperatorNotContains = "not contains"
)
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 RegexpDigitNumber = regexp.MustCompile("^\\d+$")
View Source
var RegexpDigitVariable = regexp.MustCompile("\\${\\d+}")
View Source
var RegexpExternalURL = regexp.MustCompile("(?i)^(http|https|ftp)://")
View Source
var RegexpNamedVariable = regexp.MustCompile("\\${[\\w.-]+}")
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 added in v0.1.4

func AllNodeRoles() []string

所有角色

func AllRequestOperators added in v0.1.2

func AllRequestOperators() []maps.Map

所有的运算符

func AllSSLClientAuthTypes added in v0.1.7

func AllSSLClientAuthTypes() []maps.Map

所有的客户端认证类型

func AllTimePasts added in v0.1.7

func AllTimePasts() []maps.Map

func AllWebsocketForwardModes

func AllWebsocketForwardModes() []maps.Map

所有的转发方式

func ExistNodeRole added in v0.1.4

func ExistNodeRole(role NodeRole) bool

判断某个角色是否存在

func FindLocationPatternType

func FindLocationPatternType(patternType int) maps.Map

查找单个匹配类型信息

func FindLocationPatternTypeName

func FindLocationPatternTypeName(patternType int) string

查找单个匹配类型名称

func FindRequestCondOperator added in v0.1.2

func FindRequestCondOperator(op string) maps.Map

查找某个运算符信息

func FindSSLClientAuthTypeName added in v0.1.7

func FindSSLClientAuthTypeName(authType SSLClientAuthType) string

查找单个认证方式的名称

func GoSSLClientAuthType added in v0.1.7

func GoSSLClientAuthType(authType SSLClientAuthType) tls.ClientAuthType

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

func TimePastUnixTime added in v0.1.7

func TimePastUnixTime(past TimePast) (timestamp int64)

func TimePastUnixTimeWithUnit added in v0.1.7

func TimePastUnixTimeWithUnit(number int64, unit TimeUnit) int64

Types

type ACMEDNSProvider added in v0.1.5

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

自定义ACME DNS解析

func NewACMEDNSProvider added in v0.1.5

func NewACMEDNSProvider(apiAuthToken string) *ACMEDNSProvider

func (*ACMEDNSProvider) CleanUp added in v0.1.5

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

func (*ACMEDNSProvider) Present added in v0.1.5

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

type ACMEDNSRecord added in v0.1.5

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

ACME DNS记录

type ACMELocalUser added in v0.1.5

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 added in v0.1.5

func NewACMELocalUser() *ACMELocalUser

获取新对象

type ACMELocalUserList added in v0.1.5

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

本地用户列表

func SharedACMELocalUserList added in v0.1.5

func SharedACMELocalUserList() *ACMELocalUserList

取得共享的本地用户列表

func (*ACMELocalUserList) AddUser added in v0.1.5

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

添加用户

func (*ACMELocalUserList) FindUser added in v0.1.5

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

查找用户

func (*ACMELocalUserList) RemoveUser added in v0.1.5

func (this *ACMELocalUserList) RemoveUser(userId string)

删除用户

func (*ACMELocalUserList) Save added in v0.1.5

func (this *ACMELocalUserList) Save() error

保存

type ACMERequest added in v0.1.5

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 added in v0.1.5

func NewACMERequest() *ACMERequest

获取新对象

func (*ACMERequest) CertDate added in v0.1.5

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

获取证书时间

func (*ACMERequest) CertObject added in v0.1.5

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

获取证书对象

func (*ACMERequest) Client added in v0.1.5

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

获取连接客户端

func (*ACMERequest) Renew added in v0.1.5

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

更新

func (*ACMERequest) Retrieve added in v0.1.5

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

获取证书信息

func (*ACMERequest) RetrieveDNSRecords added in v0.1.5

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

获取要设置的DNS记录

func (*ACMERequest) WriteCertFile added in v0.1.5

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

写入证书文件

func (*ACMERequest) WriteKeyFile added in v0.1.5

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

写入密钥文件

type ACMEUser added in v0.1.5

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

ACME用户账号定义

func (*ACMEUser) GetEmail added in v0.1.5

func (this *ACMEUser) GetEmail() string

func (*ACMEUser) GetPrivateKey added in v0.1.5

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

func (*ACMEUser) GetRegistration added in v0.1.5

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 added in v0.1.5

func NewAccessLogConfig() *AccessLogConfig

获取新对象

func (*AccessLogConfig) ContainsStoragePolicy added in v0.1.6

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

是否包含某个存储策略

func (*AccessLogConfig) Match added in v0.1.5

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

判断是否应该记录

func (*AccessLogConfig) Validate

func (this *AccessLogConfig) Validate() error

校验

type AccessLogStoragePolicy added in v0.1.6

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"` // 存储选项
}

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

func NewAccessLogStoragePolicy added in v0.1.6

func NewAccessLogStoragePolicy() *AccessLogStoragePolicy

创建新策略

func NewAccessLogStoragePolicyFromId added in v0.1.6

func NewAccessLogStoragePolicyFromId(id string) *AccessLogStoragePolicy

从文件中加载策略

func (*AccessLogStoragePolicy) Delete added in v0.1.6

func (this *AccessLogStoragePolicy) Delete() error

删除

func (*AccessLogStoragePolicy) MatchKeyword added in v0.1.7

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

匹配关键词

func (*AccessLogStoragePolicy) Save added in v0.1.6

func (this *AccessLogStoragePolicy) Save() error

保存

type AccessLogStoragePolicyList added in v0.1.6

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

存储策略列表

func SharedAccessLogStoragePolicyList added in v0.1.6

func SharedAccessLogStoragePolicyList() *AccessLogStoragePolicyList

获取共享的存储策略列表

func (*AccessLogStoragePolicyList) AddId added in v0.1.6

func (this *AccessLogStoragePolicyList) AddId(id string)

添加策略ID

func (*AccessLogStoragePolicyList) FindAllPolicies added in v0.1.6

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

查找所有的策略列表

func (*AccessLogStoragePolicyList) RemoveId added in v0.1.6

func (this *AccessLogStoragePolicyList) RemoveId(id string)

删除策略ID

func (*AccessLogStoragePolicyList) Save added in v0.1.6

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
	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"` // 请求源服务器用的证书
	// contains filtered or unexported fields
}

服务后端配置

func NewBackendConfig

func NewBackendConfig() *BackendConfig

获取新对象

func (*BackendConfig) AddRequestGroupId added in v0.1.2

func (this *BackendConfig) AddRequestGroupId(requestGroupId string)

添加请求分组

func (*BackendConfig) AddResponseHeader added in v0.1.2

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 added in v0.1.2

func (this *BackendConfig) CheckHealth() bool

健康检查

func (*BackendConfig) CloneState added in v0.1.6

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

克隆状态

func (*BackendConfig) Compatible added in v0.1.7

func (this *BackendConfig) Compatible()

处理兼容性

func (*BackendConfig) DecreaseConn

func (this *BackendConfig) DecreaseConn() int32

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

func (*BackendConfig) DownCallback added in v0.1.2

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

增加下线回调

func (*BackendConfig) FailTimeoutDuration

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

连接超时时间

func (*BackendConfig) HasCheckURL added in v0.1.2

func (this *BackendConfig) HasCheckURL() bool

判断是否有URL Check

func (*BackendConfig) HasHost added in v0.1.3

func (this *BackendConfig) HasHost() bool

判断是否有自定义主机名

func (*BackendConfig) HasRequestGroupId added in v0.1.2

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

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

func (*BackendConfig) HasRequestURI added in v0.1.2

func (this *BackendConfig) HasRequestURI() bool

判断是否设置RequestURI

func (*BackendConfig) HasResponseHeaders added in v0.1.2

func (this *BackendConfig) HasResponseHeaders() bool

判断是否有响应Header

func (*BackendConfig) IdleTimeoutDuration added in v0.1.7

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

保持空闲连接时间

func (*BackendConfig) IncreaseConn

func (this *BackendConfig) IncreaseConn() int32

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

func (*BackendConfig) IncreaseFails

func (this *BackendConfig) IncreaseFails() int32

增加错误次数

func (*BackendConfig) IsHTTP added in v0.1.7

func (this *BackendConfig) IsHTTP() bool

是否为HTTP

func (*BackendConfig) IsTCP added in v0.1.7

func (this *BackendConfig) IsTCP() bool

是否为TCP

func (*BackendConfig) OnAttach added in v0.1.2

func (this *BackendConfig) OnAttach()

装载事件

func (*BackendConfig) OnDetach added in v0.1.2

func (this *BackendConfig) OnDetach()

卸载事件

func (*BackendConfig) OnDown added in v0.1.2

func (this *BackendConfig) OnDown()

下线事件

func (*BackendConfig) OnUp added in v0.1.2

func (this *BackendConfig) OnUp()

上线事件

func (*BackendConfig) ReadTimeoutDuration

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

读取超时时间

func (*BackendConfig) RemoveRequestGroupId added in v0.1.2

func (this *BackendConfig) RemoveRequestGroupId(requestGroupId string)

删除某个请求分组

func (*BackendConfig) RequestArgs added in v0.1.2

func (this *BackendConfig) RequestArgs() string

获取转发后的附加参数

func (*BackendConfig) RequestPath added in v0.1.2

func (this *BackendConfig) RequestPath() string

获取转发后的Path

func (*BackendConfig) RestartChecking added in v0.1.2

func (this *BackendConfig) RestartChecking()

重启检查

func (*BackendConfig) StopChecking added in v0.1.2

func (this *BackendConfig) StopChecking()

停止Checking

func (*BackendConfig) Touch added in v0.1.7

func (this *BackendConfig) Touch()

更新

func (*BackendConfig) UniqueKey added in v0.1.7

func (this *BackendConfig) UniqueKey() string

获取唯一ID

func (*BackendConfig) UpCallback added in v0.1.2

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

增加上线回调

func (*BackendConfig) Validate

func (this *BackendConfig) Validate() error

校验

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 added in v0.1.6

func (this *BackendList) CloneBackendList() *BackendList

克隆

func (*BackendList) DeleteBackend

func (this *BackendList) DeleteBackend(backendId string)

删除后端服务器

func (*BackendList) DeleteBackends added in v0.1.6

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

删除一组后端服务器

func (*BackendList) FindBackend

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

根据ID查找后端服务器

func (*BackendList) HasBackends added in v0.1.2

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

BackendList接口定义

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 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 added in v0.1.2

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 HSTSConfig added in v0.1.5

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 added in v0.1.5

func (this *HSTSConfig) HeaderKey() string

Header Key

func (*HSTSConfig) HeaderValue added in v0.1.5

func (this *HSTSConfig) HeaderValue() string

取得当前的Header值

func (*HSTSConfig) Match added in v0.1.5

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

判断是否匹配域名

func (*HSTSConfig) Validate added in v0.1.5

func (this *HSTSConfig) Validate() error

校验

type IPRangeConfig added in v0.1.2

type IPRangeConfig struct {
	Id string `yaml:"id" json:"id"`

	Type IPRangeType `yaml:"type" json:"type"`

	Param  string `yaml:"param" json:"param"`
	CIDR   string `yaml:"cidr" json:"cidr"`
	IPFrom string `yaml:"ipFrom" json:"ipFrom"`
	IPTo   string `yaml:"ipTo" json:"ipTo"`
	// contains filtered or unexported fields
}

IP Range

func NewIPRangeConfig added in v0.1.2

func NewIPRangeConfig() *IPRangeConfig

获取新对象

func (*IPRangeConfig) Contains added in v0.1.2

func (this *IPRangeConfig) Contains(ipString string) bool

是否包含某个IP

func (*IPRangeConfig) Validate added in v0.1.2

func (this *IPRangeConfig) Validate() error

校验

type IPRangeList added in v0.1.2

type IPRangeList struct {
	IPRanges []*IPRangeConfig
}

IP Range列表

func (*IPRangeList) AddIPRange added in v0.1.2

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

添加

func (*IPRangeList) RemoveIPRange added in v0.1.2

func (this *IPRangeList) RemoveIPRange(ipRangeId string)

删除

func (*IPRangeList) Validate added in v0.1.2

func (this *IPRangeList) Validate() error

校验

type IPRangeType added in v0.1.2

type IPRangeType = int

IP Range类型

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
	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最大尺寸
	GzipLevel       int8                 `yaml:"gzipLevel" json:"gzipLevel"`             // Gzip压缩级别
	GzipMinLength   string               `yaml:"gzipMinLength" json:"gzipMinLength"`     // 需要压缩的最小内容尺寸
	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 []*RequestCond `yaml:"cond" json:"cond"`

	Pages          []*PageConfig `yaml:"pages" json:"pages"`                   // 特殊页
	ShutdownPageOn bool          `yaml:"shutdownPageOn" json:"shutdownPageOn"` // 是否开启临时关闭页面
	ShutdownPage   string        `yaml:"shutdownPage" json:"shutdownPage"`     // 临时关闭页面
	// contains filtered or unexported fields
}

路径配置

func NewLocation

func NewLocation() *LocationConfig

获取新对象

func (*LocationConfig) AddCond added in v0.1.2

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

添加过滤条件

func (*LocationConfig) AddPage added in v0.1.7

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

添加Page

func (*LocationConfig) AddRequestGroup added in v0.1.2

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

添加请求分组

func (*LocationConfig) CachePolicyObject

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

缓存策略

func (*LocationConfig) CloneState added in v0.1.6

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

克隆运行时状态

func (*LocationConfig) Compatible added in v0.1.5

func (this *LocationConfig) Compatible(version string)

兼容性设置

func (*LocationConfig) GzipMinBytes

func (this *LocationConfig) GzipMinBytes() int64

可压缩最小尺寸

func (*LocationConfig) IsCaseInsensitive

func (this *LocationConfig) IsCaseInsensitive() bool

是否大小写非敏感

func (*LocationConfig) IsReverse

func (this *LocationConfig) IsReverse() bool

是否翻转

func (*LocationConfig) Match

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

判断是否匹配路径

func (*LocationConfig) MatchKeyword added in v0.1.7

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

匹配关键词

func (*LocationConfig) MatchRequestGroup added in v0.1.2

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

使用请求匹配分组

func (*LocationConfig) MaxBodyBytes

func (this *LocationConfig) MaxBodyBytes() int64

最大Body尺寸

func (*LocationConfig) NextBackend added in v0.1.2

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

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

func (*LocationConfig) OnAttach added in v0.1.3

func (this *LocationConfig) OnAttach()

装载事件

func (*LocationConfig) OnDetach added in v0.1.3

func (this *LocationConfig) OnDetach()

卸载事件

func (*LocationConfig) PatternString

func (this *LocationConfig) PatternString() string

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

func (*LocationConfig) PatternType

func (this *LocationConfig) PatternType() int

模式类型

func (*LocationConfig) RefersProxy added in v0.1.2

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 added in v0.1.2

func (this *LocationConfig) SetupScheduling(isBackup bool)

设置调度算法

func (*LocationConfig) Validate

func (this *LocationConfig) Validate() error

校验

func (*LocationConfig) WAF added in v0.1.3

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

WAF

type LocationPatternType

type LocationPatternType = int

匹配类型

type NodeConfig added in v0.1.4

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 added in v0.1.4

func SharedNodeConfig() *NodeConfig

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

func (*NodeConfig) IsMaster added in v0.1.4

func (this *NodeConfig) IsMaster() bool

是否为Master

func (*NodeConfig) Save added in v0.1.4

func (this *NodeConfig) Save() error

保存到文件

type NodeRole added in v0.1.4

type NodeRole = string

角色定义

type PageConfig added in v0.1.2

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"`
	// contains filtered or unexported fields
}

特殊页面配置

func NewPageConfig added in v0.1.2

func NewPageConfig() *PageConfig

获取新对象

func (*PageConfig) Match added in v0.1.2

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

检查是否匹配

func (*PageConfig) Validate added in v0.1.2

func (this *PageConfig) Validate() error

校验

type RequestCond added in v0.1.2

type RequestCond struct {
	Id string `yaml:"id" json:"id"` // ID

	// 要测试的字符串
	// 其中可以使用跟请求相关的参数,比如:
	// ${arg.name}, ${requestPath}
	Param string `yaml:"param" json:"param"`

	// 运算符
	Operator RequestCondOperator `yaml:"operator" json:"operator"`

	// 对比
	Value string `yaml:"value" json:"value"`
	// contains filtered or unexported fields
}

重写条件定义

func NewRequestCond added in v0.1.2

func NewRequestCond() *RequestCond

取得新对象

func (*RequestCond) Match added in v0.1.2

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

将此条件应用于请求,检查是否匹配

func (*RequestCond) Validate added in v0.1.2

func (this *RequestCond) Validate() error

校验配置

type RequestCondOperator added in v0.1.2

type RequestCondOperator = string

运算符定义

type RequestGroup added in v0.1.2

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

	Id              string                 `yaml:"id" json:"id"`                           // ID
	Name            string                 `yaml:"name" json:"name"`                       // 名称
	Cond            []*RequestCond         `yaml:"conds" json:"conds"`                     // 匹配条件
	IPRanges        []*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 added in v0.1.2

func NewRequestGroup() *RequestGroup

获取新对象

func (*RequestGroup) AddCond added in v0.1.2

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

添加匹配条件

func (*RequestGroup) AddIPRange added in v0.1.2

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

添加IP范围

func (*RequestGroup) AddRequestHeader added in v0.1.2

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

添加请求Header

func (*RequestGroup) AddResponseHeader added in v0.1.2

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

添加响应Header

func (*RequestGroup) Copy added in v0.1.2

func (this *RequestGroup) Copy() *RequestGroup

复制

func (*RequestGroup) HasFilters added in v0.1.2

func (this *RequestGroup) HasFilters() bool

判断是否有过滤条件

func (*RequestGroup) HasRequestHeaders added in v0.1.2

func (this *RequestGroup) HasRequestHeaders() bool

判断是否有请求Header

func (*RequestGroup) HasResponseHeaders added in v0.1.2

func (this *RequestGroup) HasResponseHeaders() bool

判断是否有响应Header

func (*RequestGroup) Match added in v0.1.2

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

判断匹配

func (*RequestGroup) Validate added in v0.1.2

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 []*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"`

	// 选项
	Flags       []string `yaml:"flags" json:"flags"`
	FlagOptions maps.Map `yaml:"flagOptions" json:"flagOptions"` // flag => options map
	// 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 *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 added in v0.1.2

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 added in v0.1.4

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 added in v0.1.4

func NewSSLCertConfig(certFile string, keyFile string) *SSLCertConfig

获取新的SSL证书

func (*SSLCertConfig) CertObject added in v0.1.4

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

获取证书对象

func (*SSLCertConfig) DNSNames added in v0.1.7

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

证书中的域名

func (*SSLCertConfig) DeleteFiles added in v0.1.4

func (this *SSLCertConfig) DeleteFiles() error

删除文件

func (*SSLCertConfig) FindShared added in v0.1.7

func (this *SSLCertConfig) FindShared() *SSLCertConfig

查找共享的证书

func (*SSLCertConfig) FullCertPath added in v0.1.4

func (this *SSLCertConfig) FullCertPath() string

证书文件路径

func (*SSLCertConfig) FullKeyPath added in v0.1.4

func (this *SSLCertConfig) FullKeyPath() string

密钥文件路径

func (*SSLCertConfig) Issuer added in v0.1.7

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

发行信息

func (*SSLCertConfig) MatchDomain added in v0.1.4

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

校验是否匹配某个域名

func (*SSLCertConfig) MatchKeyword added in v0.1.7

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

匹配关键词

func (*SSLCertConfig) ReadCert added in v0.1.7

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

读取证书文件

func (*SSLCertConfig) ReadKey added in v0.1.7

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

读取密钥文件

func (*SSLCertConfig) TimeAfter added in v0.1.7

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

结束时间

func (*SSLCertConfig) TimeBefore added in v0.1.7

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

开始时间

func (*SSLCertConfig) Validate added in v0.1.4

func (this *SSLCertConfig) Validate() error

校验

type SSLCertList added in v0.1.7

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

公共的SSL证书列表

func NewSSLCertList added in v0.1.7

func NewSSLCertList() *SSLCertList

获取新对象

func SharedSSLCertList added in v0.1.7

func SharedSSLCertList() *SSLCertList

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

func (*SSLCertList) AddCert added in v0.1.7

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

添加证书

func (*SSLCertList) AddTask added in v0.1.7

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

添加任务

func (*SSLCertList) FindCert added in v0.1.7

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

查找证书

func (*SSLCertList) FindTask added in v0.1.7

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

查找任务

func (*SSLCertList) RemoveCert added in v0.1.7

func (this *SSLCertList) RemoveCert(certId string)

删除证书

func (*SSLCertList) RemoveTask added in v0.1.7

func (this *SSLCertList) RemoveTask(taskId string)

删除任务

func (*SSLCertList) Save added in v0.1.7

func (this *SSLCertList) Save() error

保存

type SSLCertTask added in v0.1.5

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 added in v0.1.5

func NewSSLCertTask() *SSLCertTask

获取新对象

type SSLClientAuthType added in v0.1.7

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,是因为要和以前的版本分开
	// contains filtered or unexported fields
}

SSL配置

func NewSSLConfig

func NewSSLConfig() *SSLConfig

获取新对象

func (*SSLConfig) AddCert added in v0.1.5

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

添加证书

func (*SSLConfig) AddCertTask added in v0.1.5

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

添加证书任务

func (*SSLConfig) CAPool added in v0.1.7

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

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

func (*SSLConfig) ContainsFile added in v0.1.4

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

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

func (*SSLConfig) DeleteFiles added in v0.1.4

func (this *SSLConfig) DeleteFiles() error

删除证书文件

func (*SSLConfig) FindCert added in v0.1.4

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

查找单个证书配置

func (*SSLConfig) FindCertTask added in v0.1.5

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

查找证书任务

func (*SSLConfig) FirstCert added in v0.1.4

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

取得第一个证书

func (*SSLConfig) MatchDomain added in v0.1.3

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

校验是否匹配某个域名

func (*SSLConfig) RemoveCertTask added in v0.1.5

func (this *SSLConfig) RemoveCertTask(certTaskId string)

删除证书任务

func (*SSLConfig) TLSCipherSuites added in v0.1.3

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

套件

func (*SSLConfig) TLSMinVersion added in v0.1.3

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最大尺寸
	GzipLevel     uint8             `yaml:"gzipLevel" json:"gzipLevel"`         // Gzip压缩级别
	GzipMinLength string            `yaml:"gzipMinLength" json:"gzipMinLength"` // 需要压缩的最小内容尺寸

	// 访问日志
	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"`

	// 参考: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"`         // 统计看板

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

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

	Pages          []*PageConfig `yaml:"pages" json:"pages"`                   // 特殊页,更高级的需求应该通过Location来设置
	ShutdownPageOn bool          `yaml:"shutdownPageOn" json:"shutdownPageOn"` // 是否开启临时关闭页面
	ShutdownPage   string        `yaml:"shutdownPage" json:"shutdownPage"`     // 临时关闭页面

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

	// 隧道相关
	Tunnel *TunnelConfig `yaml:"tunnel" json:"tunnel"`
	// 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) AddPage added in v0.1.2

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

添加Page

func (*ServerConfig) AddRequestGroup added in v0.1.2

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

添加请求分组

func (*ServerConfig) CachePolicyObject

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

缓存策略

func (*ServerConfig) CloneState added in v0.1.6

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

克隆运行时状态

func (*ServerConfig) Delete

func (this *ServerConfig) Delete() error

删除

func (*ServerConfig) FindBackendList

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

查找后端服务器列表

func (*ServerConfig) FindCerts added in v0.1.7

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 added in v0.1.2

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

func (this *ServerConfig) GzipMinBytes() int64

可压缩最小尺寸

func (*ServerConfig) IsHTTP added in v0.1.6

func (this *ServerConfig) IsHTTP() bool

判断是否为HTTP

func (*ServerConfig) IsTCP added in v0.1.6

func (this *ServerConfig) IsTCP() bool

判断是否为TCP

func (*ServerConfig) LocationAtIndex

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

获取某个位置上的配置

func (*ServerConfig) MatchKeyword added in v0.1.7

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 added in v0.1.2

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

使用请求匹配分组

func (*ServerConfig) MaxBodyBytes

func (this *ServerConfig) MaxBodyBytes() int64

最大Body尺寸

func (*ServerConfig) MoveLocation added in v0.1.2

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

移动位置

func (*ServerConfig) NextBackend added in v0.1.2

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

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

func (*ServerConfig) NextBackendIgnore added in v0.1.6

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

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

func (*ServerConfig) OnAttach added in v0.1.2

func (this *ServerConfig) OnAttach()

装载事件

func (*ServerConfig) OnDetach added in v0.1.2

func (this *ServerConfig) OnDetach()

卸载事件

func (*ServerConfig) RefersProxy added in v0.1.2

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

是否在引用某个代理

func (*ServerConfig) RemoveLocation

func (this *ServerConfig) RemoveLocation(locationId string)

删除Location

func (*ServerConfig) RemoveRequestGroup added in v0.1.2

func (this *ServerConfig) RemoveRequestGroup(groupId string)

删除请求分组

func (*ServerConfig) Save

func (this *ServerConfig) Save() error

保存

func (*ServerConfig) SetupScheduling added in v0.1.2

func (this *ServerConfig) SetupScheduling(isBackup bool)

设置调度算法

func (*ServerConfig) Validate

func (this *ServerConfig) Validate() error

校验配置

func (*ServerConfig) WAF added in v0.1.3

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

WAF策略

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 ServerNoticeConfig added in v0.1.3

type ServerNoticeConfig struct {
}

代理服务通知设置

type ServerNoticeItem added in v0.1.3

type ServerNoticeItem struct {
	Name string
	Code string
}

通知项

type TCPConfig added in v0.1.6

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 added in v0.1.6

func NewTCPConfig() *TCPConfig

获取新对象

func (*TCPConfig) Validate added in v0.1.6

func (this *TCPConfig) Validate() error

校验

type TLSCipherSuite added in v0.1.3

type TLSCipherSuite = string

Cipher Suites

type TLSVersion added in v0.1.3

type TLSVersion = string

TLS Version

type TimePast added in v0.1.7

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 added in v0.1.7

type TimeUnit = string

时间单位

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

func TimePastUnit added in v0.1.7

func TimePastUnit(past TimePast) TimeUnit

type TunnelConfig added in v0.1.5

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 added in v0.1.5

func NewTunnelConfig() *TunnelConfig

隧道设置

func (*TunnelConfig) AddError added in v0.1.5

func (this *TunnelConfig) AddError(err string)

设置错误信息

func (*TunnelConfig) Errors added in v0.1.5

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

获取错误信息

func (*TunnelConfig) IsActive added in v0.1.5

func (this *TunnelConfig) IsActive() bool

判断是否已启动

func (*TunnelConfig) SetIsActive added in v0.1.5

func (this *TunnelConfig) SetIsActive(isActive bool)

设置是否已启动

func (*TunnelConfig) Validate added in v0.1.5

func (this *TunnelConfig) Validate() error

校验

type WAFList added in v0.1.3

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

WAF列表

func SharedWAFList added in v0.1.3

func SharedWAFList() *WAFList

获取共享的WAF列表

func (*WAFList) AddFile added in v0.1.3

func (this *WAFList) AddFile(filename string)

添加文件名

func (*WAFList) FindAllConfigs added in v0.1.3

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

查找所有WAF配置

func (*WAFList) FindWAF added in v0.1.3

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

查找单个WAF配置

func (*WAFList) RemoveFile added in v0.1.3

func (this *WAFList) RemoveFile(filename string)

删除文件

func (*WAFList) Save added in v0.1.3

func (this *WAFList) Save() error

保存文件

func (*WAFList) SaveWAF added in v0.1.3

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

保存单个WAF配置

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 added in v0.1.2

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

添加请求分组

func (*WebsocketConfig) CloneState added in v0.1.6

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 added in v0.1.2

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

使用请求匹配分组

func (*WebsocketConfig) NextBackend added in v0.1.2

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

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

func (*WebsocketConfig) OnDetach added in v0.1.7

func (this *WebsocketConfig) OnDetach()

卸载方法

func (*WebsocketConfig) SetupScheduling added in v0.1.2

func (this *WebsocketConfig) SetupScheduling(isBackup bool)

设置调度算法

func (*WebsocketConfig) Validate

func (this *WebsocketConfig) Validate() error

校验

type WebsocketForwardMode

type WebsocketForwardMode = string

Websocket转发类型

type WildcardStatus added in v0.1.2

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

可能含有x字母的状态码

func NewWildcardStatus added in v0.1.2

func NewWildcardStatus(status string) *WildcardStatus

获取新对象

func (*WildcardStatus) Match added in v0.1.2

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