Documentation ¶
Index ¶
- Constants
- Variables
- func GetRealClientIP(ctx *fasthttp.RequestCtx) string
- type AccessFilter
- type AnalysisFilter
- type BlackListFilter
- type CircuitBreakeFilter
- type Filter
- type HeadersFilter
- type Manager
- type Proxy
- type RateLimitingFilter
- type ValidationFilter
- type WhiteListFilter
- type XForwardForFilter
Constants ¶
const ( // FilterHTTPAccess access log filter FilterHTTPAccess = "HTTP-ACCESS" // FilterHeader header filter FilterHeader = "HEAD" // process header fiter // FilterXForward xforward fiter FilterXForward = "XFORWARD" // FilterBlackList blacklist filter FilterBlackList = "BLACKLIST" // FilterWhiteList whitelist filter FilterWhiteList = "WHITELIST" // FilterAnalysis analysis filter FilterAnalysis = "ANALYSIS" // FilterRateLimiting limit filter FilterRateLimiting = "RATE-LIMITING" // FilterCircuitBreake circuit breake filter FilterCircuitBreake = "CIRCUIT-BREAKE" // FilterValidation validation request filter FilterValidation = "VALIDATION" )
const (
// RateBase base rate
RateBase = 100
)
const (
// TimerPrefix timer prefix
TimerPrefix = "Circuit-"
)
Variables ¶
var ( // ErrCircuitClose server is in circuit close ErrCircuitClose = errors.New("server is in circuit close") // ErrCircuitHalf server is in circuit half ErrCircuitHalf = errors.New("server is in circuit half") // ErrCircuitHalfLimited server is in circuit half, traffic limit ErrCircuitHalfLimited = errors.New("server is in circuit half, traffic limit") )
var ( // ErrPrefixRequestCancel user cancel request error ErrPrefixRequestCancel = "request canceled" // ErrNoServer no server ErrNoServer = errors.New("has no server") // ErrRewriteNotMatch rewrite not match request url ErrRewriteNotMatch = errors.New("rewrite not match request url") )
var ( // MergeContentType merge operation using content-type MergeContentType = "application/json; charset=utf-8" // MergeRemoveHeaders merge operation need to remove headers MergeRemoveHeaders = []string{ "Content-Length", "Content-Type", "Date", } )
var ( // ErrBlacklist target ip in black list ErrBlacklist = errors.New("Err, target ip in black list") )
var ( // ErrKnownFilter known filter error ErrKnownFilter = errors.New("unknow filter") )
var ( // ErrTraffixLimited traffic limit ErrTraffixLimited = errors.New("traffic limit") )
var ( // ErrValidationFailure validation failure ErrValidationFailure = errors.New("request validation failure") )
var ( // ErrWhitelist target ip not in in white list ErrWhitelist = errors.New("Err, target ip not in in white list") )
Functions ¶
func GetRealClientIP ¶
func GetRealClientIP(ctx *fasthttp.RequestCtx) string
GetRealClientIP get read client ip
Types ¶
type AccessFilter ¶
type AccessFilter struct {
// contains filtered or unexported fields
}
AccessFilter record the http access log log format: $remoteip "$method $path" $code "$agent" $svr $cost
func (AccessFilter) Post ¶
func (f AccessFilter) Post(c *filterContext) (statusCode int, err error)
Post execute after proxy
type AnalysisFilter ¶
type AnalysisFilter struct {
// contains filtered or unexported fields
}
AnalysisFilter analysis filter
func (AnalysisFilter) Post ¶
func (f AnalysisFilter) Post(c *filterContext) (statusCode int, err error)
Post execute after proxy
func (AnalysisFilter) PostErr ¶
func (f AnalysisFilter) PostErr(c *filterContext)
PostErr execute proxy has errors
func (AnalysisFilter) Pre ¶
func (f AnalysisFilter) Pre(c *filterContext) (statusCode int, err error)
Pre execute before proxy
type BlackListFilter ¶
type BlackListFilter struct {
// contains filtered or unexported fields
}
BlackListFilter blacklist filter
func (BlackListFilter) Name ¶
func (f BlackListFilter) Name() string
Name return name of this filter
func (BlackListFilter) PostErr ¶
func (f BlackListFilter) PostErr(c *filterContext)
PostErr execute proxy has errors
func (BlackListFilter) Pre ¶
func (f BlackListFilter) Pre(c *filterContext) (statusCode int, err error)
Pre execute before proxy
type CircuitBreakeFilter ¶
type CircuitBreakeFilter struct {
// contains filtered or unexported fields
}
CircuitBreakeFilter CircuitBreakeFilter
func (CircuitBreakeFilter) Name ¶
func (f CircuitBreakeFilter) Name() string
Name return name of this filter
func (CircuitBreakeFilter) Post ¶
func (f CircuitBreakeFilter) Post(c *filterContext) (statusCode int, err error)
Post execute after proxy
func (CircuitBreakeFilter) PostErr ¶
func (f CircuitBreakeFilter) PostErr(c *filterContext)
PostErr execute proxy has errors
func (CircuitBreakeFilter) Pre ¶
func (f CircuitBreakeFilter) Pre(c *filterContext) (statusCode int, err error)
Pre execute before proxy
type Filter ¶
type Filter interface { Name() string Pre(c *filterContext) (statusCode int, err error) Post(c *filterContext) (statusCode int, err error) PostErr(c *filterContext) }
Filter filter interface
type HeadersFilter ¶
type HeadersFilter struct {
// contains filtered or unexported fields
}
HeadersFilter HeadersFilter
func (HeadersFilter) Post ¶
func (f HeadersFilter) Post(c *filterContext) (statusCode int, err error)
Post execute after proxy
func (HeadersFilter) PostErr ¶
func (f HeadersFilter) PostErr(c *filterContext)
PostErr execute proxy has errors
func (HeadersFilter) Pre ¶
func (f HeadersFilter) Pre(c *filterContext) (statusCode int, err error)
Pre execute before proxy
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager support runtime remote interface
func (*Manager) AddAnalysisPoint ¶
func (m *Manager) AddAnalysisPoint(req model.AddAnalysisPointReq, rsp *model.AddAnalysisPointRsp) error
AddAnalysisPoint add a point to analysis
func (*Manager) GetAnalysisPoint ¶
func (m *Manager) GetAnalysisPoint(req model.GetAnalysisPointReq, rsp *model.GetAnalysisPointRsp) error
GetAnalysisPoint return analysis point data
type Proxy ¶
type Proxy struct {
// contains filtered or unexported fields
}
Proxy Proxy
func (*Proxy) ReverseProxyHandler ¶
func (p *Proxy) ReverseProxyHandler(ctx *fasthttp.RequestCtx)
ReverseProxyHandler http reverse handler
type RateLimitingFilter ¶
type RateLimitingFilter struct {
// contains filtered or unexported fields
}
RateLimitingFilter RateLimitingFilter
func (RateLimitingFilter) Name ¶
func (f RateLimitingFilter) Name() string
Name return name of this filter
func (RateLimitingFilter) PostErr ¶
func (f RateLimitingFilter) PostErr(c *filterContext)
PostErr execute proxy has errors
func (RateLimitingFilter) Pre ¶
func (f RateLimitingFilter) Pre(c *filterContext) (statusCode int, err error)
Pre execute before proxy
type ValidationFilter ¶
type ValidationFilter struct {
// contains filtered or unexported fields
}
ValidationFilter validation request
func (ValidationFilter) Name ¶
func (v ValidationFilter) Name() string
Name return name of this filter
func (ValidationFilter) PostErr ¶
func (f ValidationFilter) PostErr(c *filterContext)
PostErr execute proxy has errors
func (ValidationFilter) Pre ¶
func (v ValidationFilter) Pre(c *filterContext) (statusCode int, err error)
Pre pre filter, before proxy reuqest
type WhiteListFilter ¶
type WhiteListFilter struct {
// contains filtered or unexported fields
}
WhiteListFilter whitelist filter
func (WhiteListFilter) Name ¶
func (f WhiteListFilter) Name() string
Name return name of this filter
func (WhiteListFilter) PostErr ¶
func (f WhiteListFilter) PostErr(c *filterContext)
PostErr execute proxy has errors
func (WhiteListFilter) Pre ¶
func (f WhiteListFilter) Pre(c *filterContext) (statusCode int, err error)
Pre execute before proxy
type XForwardForFilter ¶
type XForwardForFilter struct {
// contains filtered or unexported fields
}
XForwardForFilter XForwardForFilter
func (XForwardForFilter) Name ¶
func (f XForwardForFilter) Name() string
Name return name of this filter
func (XForwardForFilter) PostErr ¶
func (f XForwardForFilter) PostErr(c *filterContext)
PostErr execute proxy has errors
func (XForwardForFilter) Pre ¶
func (f XForwardForFilter) Pre(c *filterContext) (statusCode int, err error)
Pre execute before proxy