Skip to content

Commit ca6fa81

Browse files
shawkinsmanusa
authored andcommitted
fix: allowing no_proxy to use ipv6 values
closes: fabric8io#6781 Signed-off-by: Steve Hawkins <[email protected]> Signed-off-by: Marc Nuri <[email protected]>
1 parent 6ee190c commit ca6fa81

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## CHANGELOG
22

3+
### 6.13.5 (2025-01-18)
4+
5+
#### Bugs
6+
* Fix #6781: Allowing ipv6 entries to work in NO_PROXY
7+
38
### 6.13.4 (2024-09-25)
49

510
#### Bugs

kubernetes-client-api/src/main/java/io/fabric8/kubernetes/client/utils/HttpClientUtils.java

+5-4
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,9 @@ public void before(BasicBuilder builder, HttpRequest request, RequestTags tags)
7373
private static final String HEADER_INTERCEPTOR = "HEADER";
7474
private static final String KUBERNETES_BACKWARDS_COMPATIBILITY_INTERCEPTOR_DISABLE = "kubernetes.backwardsCompatibilityInterceptor.disable";
7575
private static final String BACKWARDS_COMPATIBILITY_DISABLE_DEFAULT = "true";
76-
private static final Pattern IPV4_PATTERN = Pattern.compile(
77-
"(http://|https://)?(?<ipAddressOrSubnet>(([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.){3}([01]?\\d\\d?|2[0-4]\\d|25[0-5])(\\/([1-2]\\d|3[0-2]|\\d))?)(\\D+|$)");
76+
private static final Pattern IP_PATTERN = Pattern.compile(
77+
"(http(s?)://)?(?<ipAddressOrSubnet>((\\d{1,3}(.\\d{1,3}){3})|([a-f\\d]{1,4}(\\:[a-f\\d]{0,4}){2,7}))(/\\d+)?)",
78+
Pattern.CASE_INSENSITIVE);
7879
private static final Pattern INVALID_HOST_PATTERN = Pattern.compile("[^\\da-zA-Z.\\-/:]+");
7980

8081
private HttpClientUtils() {
@@ -296,8 +297,8 @@ static boolean isHostMatchedByNoProxy(String host, String[] noProxies) throws Ma
296297
}
297298

298299
private static Optional<String> extractIpAddressOrSubnet(String ipAddressOrSubnet) {
299-
final Matcher ipMatcher = IPV4_PATTERN.matcher(ipAddressOrSubnet);
300-
if (ipMatcher.find()) {
300+
final Matcher ipMatcher = IP_PATTERN.matcher(ipAddressOrSubnet);
301+
if (ipMatcher.matches()) {
301302
return Optional.of(ipMatcher.group("ipAddressOrSubnet"));
302303
}
303304
return Optional.empty();

kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/HttpClientUtilsTest.java

+1
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ Stream<Arguments> masterHostnameDoesMatchNoProxyInput() {
189189
arguments("192.168.1.110", new String[] { "192.168.1.0/24" }),
190190
arguments("192.168.1.110", new String[] { "http://192.168.1.0/24" }),
191191
arguments("192.168.1.110", new String[] { "192.0.0.0/8" }),
192+
arguments("2620:52:0:9c:0:0:0:1", new String[] { "2620:52:0:9c::/64" }),
192193
arguments("192.168.1.110", new String[] { "http://192.0.0.0/8" }));
193194
}
194195

kubernetes-client-api/src/test/java/io/fabric8/kubernetes/client/utils/IpAddressMatcherTest.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ static Stream<Arguments> matchesTrueInput() {
4040
arguments("192.168.10.110", "192.168.10.110"),
4141
arguments("192.168.1.0/8", "192.168.10.110"),
4242
arguments("192.168.1.0/24", "192.168.1.100"),
43+
arguments("10.96.0.1", "0:0:0:0:0:ffff:0a60:0001"),
44+
arguments("2620:52:0:9c::/64", "2620:52:0:9c:0:0:0:1"),
4345
arguments("0.0.0.0/0", "123.4.5.6"),
4446
arguments("0.0.0.0/0", "192.168.0.159"),
4547
arguments("192.168.0.159/0", "123.4.5.6"),
@@ -59,7 +61,6 @@ static Stream<Arguments> matchesFalseInput() {
5961
arguments("192.168.1.0/24", "193.168.1.10"),
6062
arguments("192.168.1.0/24", "192.168.2.10"),
6163
arguments("192.168.1.0/8", "193.168.1.10"),
62-
arguments("192.168.1.128/25", "192.168.1.104"),
63-
arguments("kubernetes.default.svc", "kubernetes.default.svc"));
64+
arguments("192.168.1.128/25", "192.168.1.104"));
6465
}
6566
}

0 commit comments

Comments
 (0)