Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,7 @@ public boolean match(DiscoveryNode node) {
}
} else if ("_host".equals(attr)) {
for (String value : values) {
if (Regex.simpleMatch(value, node.getHostName())) {
if (opType == OpType.OR) {
return true;
}
} else {
if (opType == OpType.AND) {
return false;
}
}
if (Regex.simpleMatch(value, node.getHostAddress())) {
if (Regex.simpleMatch(value, node.getHostName()) || Regex.simpleMatch(value, node.getHostAddress())) {
if (opType == OpType.OR) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,26 @@ public void testIpPublishFilteringMatchingOr() {
assertThat(filters.match(node), equalTo(true));
}

public void testHostNameFilteringMatchingAnd() {
Settings settings = shuffleSettings(Settings.builder()
.put("xxx._host", "A")
.build());
DiscoveryNodeFilters filters = buildFromSettings(AND, "xxx.", settings);

DiscoveryNode node = new DiscoveryNode("", "", "", "A", "192.1.1.54", localAddress, emptyMap(), emptySet(), null);
assertThat(filters.match(node), equalTo(true));
}

public void testHostAddressFilteringMatchingAnd() {
Settings settings = shuffleSettings(Settings.builder()
.put("xxx._host", "192.1.1.54")
.build());
DiscoveryNodeFilters filters = buildFromSettings(AND, "xxx.", settings);

DiscoveryNode node = new DiscoveryNode("", "", "", "A", "192.1.1.54", localAddress, emptyMap(), emptySet(), null);
assertThat(filters.match(node), equalTo(true));
}

public void testIpPublishFilteringNotMatchingOr() {
Settings settings = shuffleSettings(Settings.builder()
.put("xxx.tag", "A")
Expand Down