-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
317 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
syntax = "proto3"; | ||
|
||
package envoy.type.matcher.v3; | ||
|
||
import "xds/core/v3/cidr.proto"; | ||
|
||
import "udpa/annotations/status.proto"; | ||
|
||
option java_package = "io.envoyproxy.envoy.type.matcher.v3"; | ||
option java_outer_classname = "AddressProto"; | ||
option java_multiple_files = true; | ||
option go_package = "github.com/envoyproxy/go-control-plane/envoy/type/matcher/v3;matcherv3"; | ||
option (udpa.annotations.file_status).package_version_status = ACTIVE; | ||
|
||
message AddressMatcher { | ||
repeated xds.core.v3.CidrRange ranges = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include "source/common/common/filter_state_object_matchers.h" | ||
|
||
#include "envoy/common/exception.h" | ||
#include "envoy/network/address.h" | ||
#include "envoy/stream_info/filter_state.h" | ||
|
||
#include "source/common/network/cidr_range.h" | ||
|
||
#include "absl/status/statusor.h" | ||
#include "xds/core/v3/cidr.pb.h" | ||
|
||
namespace Envoy { | ||
namespace Matchers { | ||
|
||
FilterStateIpRangeMatcher::FilterStateIpRangeMatcher( | ||
std::unique_ptr<Network::Address::IpList>&& ip_list) | ||
: ip_list_(std::move(ip_list)) {} | ||
|
||
bool FilterStateIpRangeMatcher::match(const StreamInfo::FilterState::Object& object) const { | ||
const Network::Address::InstanceConstSharedPtrAccessor* ip = | ||
dynamic_cast<const Network::Address::InstanceConstSharedPtrAccessor*>(&object); | ||
if (ip == nullptr) { | ||
return false; | ||
} | ||
return ip_list_->contains(*ip->getIp()); | ||
} | ||
|
||
FilterStateStringMatcher::FilterStateStringMatcher(StringMatcherPtr&& string_matcher) | ||
: string_matcher_(std::move(string_matcher)) {} | ||
|
||
bool FilterStateStringMatcher::match(const StreamInfo::FilterState::Object& object) const { | ||
const auto string_value = object.serializeAsString(); | ||
return string_value && string_matcher_->match(*string_value); | ||
} | ||
|
||
} // namespace Matchers | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
|
||
#include "envoy/common/matchers.h" | ||
#include "envoy/common/pure.h" | ||
#include "envoy/stream_info/filter_state.h" | ||
|
||
#include "source/common/network/cidr_range.h" | ||
|
||
namespace Envoy { | ||
namespace Matchers { | ||
|
||
class FilterStateObjectMatcher { | ||
public: | ||
virtual bool match(const StreamInfo::FilterState::Object& object) const PURE; | ||
virtual ~FilterStateObjectMatcher(){}; | ||
}; | ||
|
||
using FilterStateObjectMatcherPtr = std::unique_ptr<FilterStateObjectMatcher>; | ||
|
||
class FilterStateIpRangeMatcher : public FilterStateObjectMatcher { | ||
public: | ||
FilterStateIpRangeMatcher(std::unique_ptr<Network::Address::IpList>&& ip_list); | ||
bool match(const StreamInfo::FilterState::Object& object) const override; | ||
|
||
private: | ||
std::unique_ptr<Envoy::Network::Address::IpList> ip_list_; | ||
}; | ||
|
||
class FilterStateStringMatcher : public FilterStateObjectMatcher { | ||
public: | ||
FilterStateStringMatcher(StringMatcherPtr&& string_matcher); | ||
bool match(const StreamInfo::FilterState::Object& object) const override; | ||
|
||
private: | ||
const StringMatcherPtr string_matcher_; | ||
}; | ||
|
||
} // namespace Matchers | ||
} // namespace Envoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.