Documentation
¶
Overview ¶
action_variable.go - variable name legality check and variable handlers
action_variable_inner.go - built-in variable value fetchers (header/ssl/client info)
Index ¶
- Constants
- Variables
- func ActionFileCheck(conf ActionFile) error
- func EvalFormatStr(req *bfe_basic.Request, params []string) string
- func GetReqQueryKey(req *bfe_basic.Request, key string) string
- func IsLegalVarName(varName string) bool
- func ParamType(param string) int
- func PreprocessFormatStr(param string) ([]string, error)
- func PreprocessSetUsrVarParams(params []string) ([]string, error)
- func ReqHostSet(req *bfe_basic.Request, hostname string)
- func ReqHostSetFromFirstPathSegment(req *bfe_basic.Request)
- func ReqHostSuffixReplace(req *bfe_basic.Request, originSuffix, newSuffix string)
- func ReqPathPrefixAdd(req *bfe_basic.Request, prefix string)
- func ReqPathPrefixTrim(req *bfe_basic.Request, prefix string)
- func ReqPathSet(req *bfe_basic.Request, path string)
- func ReqQueryAdd(req *bfe_basic.Request, params []string)
- func ReqQueryDel(req *bfe_basic.Request, keys []string)
- func ReqQueryDelAllExcept(req *bfe_basic.Request, keys []string)
- func ReqQueryRename(req *bfe_basic.Request, oldName string, newName string)
- func SetExprParamCompiler(c ExprParamCompiler)
- func SetUsrVariable(req *bfe_basic.Request, varName string, params []string)
- type Action
- type ActionFile
- type ExprParamCompiler
- type HeaderValueHandler
- type VarEvaluator
Constants ¶
const ( // connection actions ActionClose = "CLOSE" // close, close the connection directly ActionPass = "PASS" // pass, do nothing ActionFinish = "FINISH" // finish, close connection after reply // header actions ActionReqHeaderAdd = "REQ_HEADER_ADD" // add request header ActionReqHeaderSet = "REQ_HEADER_SET" // set request header ActionReqHeaderDel = "REQ_HEADER_DEL" // del request header // host actions ActionHostSetFromPathPrefix = "HOST_SET_FROM_PATH_PREFIX" // set host from path prefix ActionHostSet = "HOST_SET" // set host ActionHostSuffixReplace = "HOST_SUFFIX_REPLACE" // set host replaced suffx // path actions ActionPathSet = "PATH_SET" // set path ActionPathPrefixAdd = "PATH_PREFIX_ADD" // add path prefix ActionPathPrefixTrim = "PATH_PREFIX_TRIM" // trim path prefix // query actions ActionQueryAdd = "QUERY_ADD" // add query ActionQueryDel = "QUERY_DEL" // del query ActionQueryRename = "QUERY_RENAME" // rename query ActionQueryDelAllExcept = "QUERY_DEL_ALL_EXCEPT" // del query except given query key )
const ( ParamTypeLiteral = iota ParamTypeVarLegacy ParamTypeVarNew )
const HeaderPrefix = "X-BFE-"
const (
UNKNOWN = "unknown"
)
Variables ¶
var (
VariableHandlers = map[string]HeaderValueHandler{
"bfe_clientip": getClientIp,
"bfe_clientport": getClientPort,
"bfe_clientip_location": getClientIpLocationName,
"bfe_cip": getClientIp,
"bfe_vip": getBfeVip,
"bfe_bip": getBfeBip,
"bfe_rip": getBfeRip,
"bfe_domain_auto": getBfeDomainAuto,
"session_id": getSessionId,
"bfe_logid": getBfeLogId,
"bfe_server_name": getBfeServerName,
"bfe_cluster": getBfeCluster,
"bfe_backend_info": getBfeBackendInfo,
"bfe_ssl_info": getBfeSslInfo,
"bfe_ssl_resume": getBfeSslResume,
"bfe_ssl_cipher": getBfeSslCipher,
"bfe_ssl_version": getBfeSslVersion,
"bfe_protocol": getBfeProtocol,
"client_cert_serial_number": getClientCertSerialNumber,
"client_cert_subject_title": getClientCertSubjectTitle,
"client_cert_subject_common_name": getClientCertSubjectCommonName,
"client_cert_subject_organization": getClientCertSubjectOrganization,
"client_cert_subject_organization_unit": getClientCertSubjectOrganizationalUnit,
"client_cert_subject_province": getClientCertSubjectProvince,
"client_cert_subject_country": getClientCertSubjectCountry,
"client_cert_subject_locality": getClientCertSubjectLocality,
"client_cert_adu_car_role": getClientCertAduCarRole,
"client_cert_adu_reserve": getClientCertAduReserve,
"client_cert_pem": getClientCertPEM,
"client_cert_subject_string": getClientCertSubjectString,
"client_cert_issuer_string": getClientCertIssuerString,
"client_cert_pub_key_algo": getClientCertPublicKeyAlgorithm,
"client_cert_sig_algo": getClientCertSignatureAlgorithm,
"req_uri": getReqUrI,
"req_path": getReqPath,
}
)
Functions ¶
func ActionFileCheck ¶
func ActionFileCheck(conf ActionFile) error
func EvalFormatStr ¶ added in v1.9.0
func GetReqQueryKey ¶ added in v1.9.0
GetReqQueryKey returns the value of given query key.
func IsLegalVarName ¶ added in v1.9.0
func ParamType ¶ added in v1.9.0
format string contains the following style substring: ParamTypeVarLegacy: eg:%bfe_cluster ParamTypeVarNew: --new not-param var: eg:%{bfe_cluster}, --new param var: eg:%{bfe_req_header::headername}, %{usr_variable::rname} ParamTypeLiteral:
func PreprocessFormatStr ¶ added in v1.9.0
func PreprocessSetUsrVarParams ¶ added in v1.9.0
func ReqHostSet ¶
ReqHostSet sets hostname to request.
func ReqHostSetFromFirstPathSegment ¶
ReqHostSetFromFirstPathSegment set hostname from first path segment.
example: if uri path pattern is /x.baidu.com/xxxx,
set host x.baidu.com set uri path /xxx
if do not match this pattern, do noting
func ReqHostSuffixReplace ¶
ReqHostSuffixReplace replaces suffix of hostname.
func ReqPathPrefixAdd ¶
ReqPathPrefixAdd adds prefix to path. e.g., path "/(.*)" => "/link?$1",
func ReqPathPrefixTrim ¶
ReqPathPrefixTrim trims prefix of path e.g., path "/service/shortcut/(.*)" => "/$1",
func ReqPathSet ¶
ReqPathSet sets path to request.
func ReqQueryAdd ¶
ReqQueryAdd adds some number of (key, value) to query.
func ReqQueryDel ¶
ReqQueryDel deletes some keys from query
func ReqQueryDelAllExcept ¶
ReqQueryDelAllExcept deletes all keys from query, except some keys
func ReqQueryRename ¶
ReqQueryRename renames query key from old name to new name.
func SetExprParamCompiler ¶ added in v1.9.0
func SetExprParamCompiler(c ExprParamCompiler)
SetExprParamCompiler 注入动作参数表达式编译器。 由 bfe_expr 包在 init 中调用,避免 bfe_basic/action 反向依赖 bfe_expr(依赖环)。 未注入时表达式参数按字面量处理,保持旧行为。
Types ¶
type Action ¶
type Action struct {
Cmd string // command of action
Params []string // params of action
// contains filtered or unexported fields
}
func (*Action) UnmarshalJSON ¶
UnmarshalJSON decodes given data in json format
type ActionFile ¶
type ExprParamCompiler ¶ added in v1.9.0
type ExprParamCompiler func(params []string, indexes []int) (func(req *bfe_basic.Request) []string, error)
ExprParamCompiler 动作参数表达式编译器签名: 入参为参数列表与「可作为表达式的下标集合」,返回运行期求值闭包与加载期错误。
type HeaderValueHandler ¶ added in v1.9.0
type VarEvaluator ¶ added in v1.9.0
type VarEvaluator interface {
// contains filtered or unexported methods
}