diff --git a/src/main/java/io/github/danthe1st/httpsintercept/handler/ServerHandlersInit.java b/src/main/java/io/github/danthe1st/httpsintercept/handler/ServerHandlersInit.java index 4b8f1d8..304597d 100644 --- a/src/main/java/io/github/danthe1st/httpsintercept/handler/ServerHandlersInit.java +++ b/src/main/java/io/github/danthe1st/httpsintercept/handler/ServerHandlersInit.java @@ -44,7 +44,7 @@ public ServerHandlersInit(Bootstrap clientBootstrap, Config config) throws KeySt preForwardMatcher = createMatcherFromRules(config.preForwardRules()); postForwardMatcher = createMatcherFromRules(config.postForwardRules()); - ignoredHostMatcher = new IterativeHostMatcher<>(List.of(Map.entry(config.ignoredHosts(), new Object()))); + ignoredHostMatcher = new IterativeHostMatcher<>(List.of(Map.entry(config.ignoredHosts(), new Object())), false); } private IterativeHostMatcher createMatcherFromRules(List ruleList) { @@ -56,7 +56,7 @@ private IterativeHostMatcher createMatcherFromRule } rules.add(Map.entry(hostMatcher, rule)); } - return new IterativeHostMatcher<>(rules); + return new IterativeHostMatcher<>(rules, true); } @Override diff --git a/src/main/java/io/github/danthe1st/httpsintercept/matcher/IterativeHostMatcher.java b/src/main/java/io/github/danthe1st/httpsintercept/matcher/IterativeHostMatcher.java index 4815f2e..d5d1446 100644 --- a/src/main/java/io/github/danthe1st/httpsintercept/matcher/IterativeHostMatcher.java +++ b/src/main/java/io/github/danthe1st/httpsintercept/matcher/IterativeHostMatcher.java @@ -21,7 +21,7 @@ public final class IterativeHostMatcher { private final Map> hostRegexes; private final List wildcards; - public IterativeHostMatcher(List> configs) { + public IterativeHostMatcher(List> configs, boolean allowWildcard) { Map> hosts = new HashMap<>(); Map> parts = new HashMap<>(); Map> regexes = new HashMap<>(); @@ -29,7 +29,7 @@ public IterativeHostMatcher(List> configs) { for(Map.Entry entry : configs){ HostMatcherConfig config = entry.getKey(); T value = entry.getValue(); - if(config.exact().isEmpty() && config.partial().isEmpty() && config.regex().isEmpty()){ + if(allowWildcard && config.exact().isEmpty() && config.partial().isEmpty() && config.regex().isEmpty()){ wildcardElements.add(value); }else{ addToMap(hosts, value, config.exact(), Function.identity()); diff --git a/src/test/java/io/github/danthe1st/httpsintercept/matcher/HostMatcherTests.java b/src/test/java/io/github/danthe1st/httpsintercept/matcher/HostMatcherTests.java index 1b52ff3..ece47f6 100644 --- a/src/test/java/io/github/danthe1st/httpsintercept/matcher/HostMatcherTests.java +++ b/src/test/java/io/github/danthe1st/httpsintercept/matcher/HostMatcherTests.java @@ -14,7 +14,7 @@ class HostMatcherTests { private IterativeHostMatcher createMatcher(Set exactHosts, Set hostParts, Set hostRegexes) { - return new IterativeHostMatcher<>(List.of(Map.entry(new HostMatcherConfig(exactHosts, hostParts, hostRegexes), new Object()))); + return new IterativeHostMatcher<>(List.of(Map.entry(new HostMatcherConfig(exactHosts, hostParts, hostRegexes), new Object())), false); } @Test