統一匹配器 API (proto)
config.common.matcher.v3.Matcher
[config.common.matcher.v3.Matcher proto]
一個匹配器,可能會遍歷匹配樹,以便產生匹配動作。在匹配期間,將遍歷該樹,直到找到匹配項,或者如果未找到匹配項,則將評估最特定的 on_no_match 指定的動作。由於 on_no_match 可能會導致評估另一個匹配樹,因此此過程可能會重複多次,直到確定最終的 OnMatch(或不匹配)。
注意
請使用語法上等效的 匹配 API
{
"matcher_list": {...},
"matcher_tree": {...},
"on_no_match": {...}
}
- matcher_list
(config.common.matcher.v3.Matcher.MatcherList) 要評估的匹配器線性列表。
必須設定 matcher_list、matcher_tree 中的精確一個。
- matcher_tree
(config.common.matcher.v3.Matcher.MatcherTree) 要評估的匹配樹。
必須設定 matcher_list、matcher_tree 中的精確一個。
- on_no_match
(config.common.matcher.v3.Matcher.OnMatch) 如果匹配器失敗,則使用的可選 OnMatch。如果指定,則使用 OnMatch,並且認為匹配器已匹配。如果未指定,則認為匹配器未匹配。
config.common.matcher.v3.Matcher.OnMatch
[config.common.matcher.v3.Matcher.OnMatch proto]
如果匹配成功,則執行哪些動作。
{
"matcher": {...},
"action": {...}
}
- matcher
(config.common.matcher.v3.Matcher) 要評估的巢狀匹配器。如果巢狀匹配器不匹配並且未指定 on_no_match,則認為此匹配器未匹配,即使此層級或以上的謂詞傳回 true 也是如此。
- action
(config.core.v3.TypedExtensionConfig) 要採取的協定特定動作。
config.common.matcher.v3.Matcher.MatcherList
[config.common.matcher.v3.Matcher.MatcherList proto]
欄位匹配器的線性列表。欄位匹配器會依序評估,且第一個匹配項獲勝。
{
"matchers": []
}
- matchers
(repeated config.common.matcher.v3.Matcher.MatcherList.FieldMatcher,必要) 匹配器列表。第一個匹配項獲勝。
config.common.matcher.v3.Matcher.MatcherList.Predicate
[config.common.matcher.v3.Matcher.MatcherList.Predicate proto]
用於判斷匹配是否成功的謂詞。
{
"single_predicate": {...},
"or_matcher": {...},
"and_matcher": {...},
"not_matcher": {...}
}
- single_predicate
(config.common.matcher.v3.Matcher.MatcherList.Predicate.SinglePredicate) 要評估的單一謂詞。
必須設定 single_predicate、or_matcher、and_matcher、not_matcher 中的精確一個。
- or_matcher
(config.common.matcher.v3.Matcher.MatcherList.Predicate.PredicateList) 要進行 OR 運算的謂詞列表。
必須設定 single_predicate、or_matcher、and_matcher、not_matcher 中的精確一個。
- and_matcher
(config.common.matcher.v3.Matcher.MatcherList.Predicate.PredicateList) 要進行 AND 運算的謂詞列表。
必須設定 single_predicate、or_matcher、and_matcher、not_matcher 中的精確一個。
- not_matcher
(config.common.matcher.v3.Matcher.MatcherList.Predicate) 謂詞的反向
必須設定 single_predicate、or_matcher、and_matcher、not_matcher 中的精確一個。
config.common.matcher.v3.Matcher.MatcherList.Predicate.SinglePredicate
[config.common.matcher.v3.Matcher.MatcherList.Predicate.SinglePredicate proto]
單一輸入欄位的謂詞。
{
"input": {...},
"value_match": {...},
"custom_match": {...}
}
- input
(config.core.v3.TypedExtensionConfig,必要) 要匹配的輸入欄位的協定特定規範。
- value_match
(type.matcher.v3.StringMatcher) 內建字串匹配器。
必須設定 value_match、custom_match 中的精確一個。
- custom_match
(config.core.v3.TypedExtensionConfig) 用於自訂匹配邏輯的擴充功能。
必須設定 value_match、custom_match 中的精確一個。
config.common.matcher.v3.Matcher.MatcherList.Predicate.PredicateList
[config.common.matcher.v3.Matcher.MatcherList.Predicate.PredicateList proto]
兩個或多個匹配器的列表。用於允許在 oneof 中使用列表。
{
"predicate": []
}
- predicate
(repeated config.common.matcher.v3.Matcher.MatcherList.Predicate,必要)
config.common.matcher.v3.Matcher.MatcherList.FieldMatcher
[config.common.matcher.v3.Matcher.MatcherList.FieldMatcher proto]
單一匹配器。
{
"predicate": {...},
"on_match": {...}
}
- predicate
(config.common.matcher.v3.Matcher.MatcherList.Predicate,必要) 決定匹配是否成功。
- on_match
(config.common.matcher.v3.Matcher.OnMatch,必要) 如果匹配成功,則執行哪些動作。
config.common.matcher.v3.Matcher.MatcherTree
[config.common.matcher.v3.Matcher.MatcherTree proto]
{
"input": {...},
"exact_match_map": {...},
"prefix_match_map": {...},
"custom_match": {...}
}
- input
(config.core.v3.TypedExtensionConfig,必要) 要匹配的輸入欄位的協定特定規範。
- exact_match_map
(config.common.matcher.v3.Matcher.MatcherTree.MatchMap) 在其中查找輸入值的精確或前置詞匹配對應表。如果查找成功,則認為匹配成功,並且使用對應的 OnMatch。
必須設定 exact_match_map、prefix_match_map、custom_match 中的精確一個。
- prefix_match_map
(config.common.matcher.v3.Matcher.MatcherTree.MatchMap) 最長匹配的前置詞獲勝。
在其中查找輸入值的精確或前置詞匹配對應表。如果查找成功,則認為匹配成功,並且使用對應的 OnMatch。
必須設定 exact_match_map、prefix_match_map、custom_match 中的精確一個。
- custom_match
(config.core.v3.TypedExtensionConfig) 用於自訂匹配邏輯的擴充功能。
在其中查找輸入值的精確或前置詞匹配對應表。如果查找成功,則認為匹配成功,並且使用對應的 OnMatch。
必須設定 exact_match_map、prefix_match_map、custom_match 中的精確一個。
config.common.matcher.v3.Matcher.MatcherTree.MatchMap
[config.common.matcher.v3.Matcher.MatcherTree.MatchMap proto]
已組態匹配器的對應表。用於允許在 oneof 中使用對應表。
{
"map": {...}
}
- map
(repeated map<string, config.common.matcher.v3.Matcher.OnMatch>)
config.common.matcher.v3.MatchPredicate
[config.common.matcher.v3.MatchPredicate proto]
匹配組態。這是一個遞迴結構,允許使用各種邏輯運算子建構複雜的巢狀匹配組態。
{
"or_match": {...},
"and_match": {...},
"not_match": {...},
"any_match": ...,
"http_request_headers_match": {...},
"http_request_trailers_match": {...},
"http_response_headers_match": {...},
"http_response_trailers_match": {...},
"http_request_generic_body_match": {...},
"http_response_generic_body_match": {...}
}
- or_match
(config.common.matcher.v3.MatchPredicate.MatchSet) 描述邏輯 OR 的集合。如果集合中的任何成員匹配,則匹配組態匹配。
必須設定 or_match、 and_match、 not_match、 any_match、 http_request_headers_match、 http_request_trailers_match、 http_response_headers_match、 http_response_trailers_match、 http_request_generic_body_match 或 http_response_generic_body_match 其中之一。
- and_match
(config.common.matcher.v3.MatchPredicate.MatchSet) 描述邏輯 AND 的集合。如果集合中的所有成員都匹配,則匹配配置會匹配。
必須設定 or_match、 and_match、 not_match、 any_match、 http_request_headers_match、 http_request_trailers_match、 http_response_headers_match、 http_response_trailers_match、 http_request_generic_body_match 或 http_response_generic_body_match 其中之一。
- not_match
(config.common.matcher.v3.MatchPredicate) 否定匹配。如果被否定的匹配條件匹配,則匹配配置會匹配。
必須設定 or_match、 and_match、 not_match、 any_match、 http_request_headers_match、 http_request_trailers_match、 http_response_headers_match、 http_response_trailers_match、 http_request_generic_body_match 或 http_response_generic_body_match 其中之一。
- any_match
(bool) 匹配配置將永遠匹配。
必須設定 or_match、 and_match、 not_match、 any_match、 http_request_headers_match、 http_request_trailers_match、 http_response_headers_match、 http_response_trailers_match、 http_request_generic_body_match 或 http_response_generic_body_match 其中之一。
- http_request_headers_match
(config.common.matcher.v3.HttpHeadersMatch) HTTP 請求標頭匹配配置。
必須設定 or_match、 and_match、 not_match、 any_match、 http_request_headers_match、 http_request_trailers_match、 http_response_headers_match、 http_response_trailers_match、 http_request_generic_body_match 或 http_response_generic_body_match 其中之一。
- http_request_trailers_match
(config.common.matcher.v3.HttpHeadersMatch) HTTP 請求尾部匹配配置。
必須設定 or_match、 and_match、 not_match、 any_match、 http_request_headers_match、 http_request_trailers_match、 http_response_headers_match、 http_response_trailers_match、 http_request_generic_body_match 或 http_response_generic_body_match 其中之一。
- http_response_headers_match
(config.common.matcher.v3.HttpHeadersMatch) HTTP 回應標頭匹配配置。
必須設定 or_match、 and_match、 not_match、 any_match、 http_request_headers_match、 http_request_trailers_match、 http_response_headers_match、 http_response_trailers_match、 http_request_generic_body_match 或 http_response_generic_body_match 其中之一。
- http_response_trailers_match
(config.common.matcher.v3.HttpHeadersMatch) HTTP 回應尾部匹配配置。
必須設定 or_match、 and_match、 not_match、 any_match、 http_request_headers_match、 http_request_trailers_match、 http_response_headers_match、 http_response_trailers_match、 http_request_generic_body_match 或 http_response_generic_body_match 其中之一。
- http_request_generic_body_match
(config.common.matcher.v3.HttpGenericBodyMatch) HTTP 請求通用主體匹配配置。
必須設定 or_match、 and_match、 not_match、 any_match、 http_request_headers_match、 http_request_trailers_match、 http_response_headers_match、 http_response_trailers_match、 http_request_generic_body_match 或 http_response_generic_body_match 其中之一。
- http_response_generic_body_match
(config.common.matcher.v3.HttpGenericBodyMatch) HTTP 回應通用主體匹配配置。
必須設定 or_match、 and_match、 not_match、 any_match、 http_request_headers_match、 http_request_trailers_match、 http_response_headers_match、 http_response_trailers_match、 http_request_generic_body_match 或 http_response_generic_body_match 其中之一。
config.common.matcher.v3.MatchPredicate.MatchSet
[config.common.matcher.v3.MatchPredicate.MatchSet proto]
用於邏輯操作的一組匹配配置。
{
"rules": []
}
- rules
(repeated config.common.matcher.v3.MatchPredicate,REQUIRED) 組成此集合的規則列表。
config.common.matcher.v3.HttpHeadersMatch
[config.common.matcher.v3.HttpHeadersMatch proto]
HTTP 標頭匹配配置。
{
"headers": []
}
- headers
(repeated config.route.v3.HeaderMatcher) 要匹配的 HTTP 標頭。
config.common.matcher.v3.HttpGenericBodyMatch
[config.common.matcher.v3.HttpGenericBodyMatch proto]
HTTP 通用主體匹配配置。要在 HTTP 主體中尋找的文字字串和十六進位字串列表。必須在 HTTP 主體中找到所有指定的字串,才能算是正向匹配。搜尋範圍可能會限制在從主體開頭算起指定數量的位元組內。
注意
在 HTTP 主體中搜尋模式可能會消耗大量 CPU 資源。對於每個指定的模式,HTTP 主體會逐位元組掃描以尋找匹配項。如果指定了多個模式,則會針對每個模式重複此過程。如果已知模式的位置,則應指定 bytes_limit
以僅掃描 HTTP 主體的一部分。
{
"bytes_limit": ...,
"patterns": []
}
- bytes_limit
(uint32) 將搜尋範圍限制在指定數量的位元組內 - 預設為零(無限制 - 匹配整個捕獲的緩衝區)。
- patterns
(repeated config.common.matcher.v3.HttpGenericBodyMatch.GenericTextMatch,REQUIRED) 要匹配的模式列表。
config.common.matcher.v3.HttpGenericBodyMatch.GenericTextMatch
[config.common.matcher.v3.HttpGenericBodyMatch.GenericTextMatch proto]
{
"string_match": ...,
"binary_match": ...
}
- string_match
(string) 要在 HTTP 主體中尋找的文字字串。
必須設定 string_match 或 binary_match 其中之一。
- binary_match
(bytes) 要在 HTTP 主體中尋找的位元組序列。
必須設定 string_match 或 binary_match 其中之一。