@Test public void shouldRecognizeLocalIps() { assertThat(testee.isUriToBeIgnoredByProxy("localhost"), is(true)); assertThat(testee.isUriToBeIgnoredByProxy("127.0.0.1"), is(true)); assertThat(testee.isUriToBeIgnoredByProxy("192.168.1.1"), is(true)); assertThat(testee.isUriToBeIgnoredByProxy("192.168.240.3"), is(true)); assertThat(testee.isUriToBeIgnoredByProxy("10.0.240.3"), is(true)); assertThat(testee.isUriToBeIgnoredByProxy("8.8.8.8"), is(false)); }
protected boolean isUriToBeIgnoredByProxy(String host) { MainConfig mainConfig = configProvider.getBaseConfig().getMain(); if (mainConfig.isProxyIgnoreLocal()) { Boolean ipToLong = isHostInLocalNetwork(host); if (ipToLong != null) { return ipToLong; } } if (mainConfig.getProxyIgnoreDomains() == null || mainConfig.getProxyIgnoreDomains().isEmpty()) { return false; } return mainConfig.getProxyIgnoreDomains().stream().anyMatch(x -> isSameHost(x, host)); }
HydraOkHttp3ClientHttpRequestFactory implements ClientHttpRequestFactory, AsyncClientHttpRequestFactory { protected boolean isUriToBeIgnoredByProxy(String host) { MainConfig mainConfig = configProvider.getBaseConfig().getMain(); if (mainConfig.isProxyIgnoreLocal()) { Boolean ipToLong = isHostInLocalNetwork(host); if (ipToLong != null) { return ipToLong; } } if (mainConfig.getProxyIgnoreDomains() == null || mainConfig.getProxyIgnoreDomains().isEmpty()) { return false; } return mainConfig.getProxyIgnoreDomains().stream().anyMatch(x -> isSameHost(x, host)); } }
HydraOkHttp3ClientHttpRequestFactory implements ClientHttpRequestFactory, AsyncClientHttpRequestFactory { protected boolean isUriToBeIgnoredByProxy(String host) { MainConfig mainConfig = configProvider.getBaseConfig().getMain(); if (mainConfig.isProxyIgnoreLocal()) { Boolean ipToLong = isHostInLocalNetwork(host); if (ipToLong != null) { return ipToLong; } } if (mainConfig.getProxyIgnoreDomains() == null || mainConfig.getProxyIgnoreDomains().isEmpty()) { return false; } return mainConfig.getProxyIgnoreDomains().stream().anyMatch(x -> isSameHost(x, host)); }  }
HydraOkHttp3ClientHttpRequestFactory implements ClientHttpRequestFactory, AsyncClientHttpRequestFactory { protected boolean isUriToBeIgnoredByProxy(String host) { MainConfig mainConfig = configProvider.getBaseConfig().getMain(); if (mainConfig.isProxyIgnoreLocal()) { Boolean ipToLong = isHostInLocalNetwork(host); if (ipToLong != null) { return ipToLong; } } if (mainConfig.getProxyIgnoreDomains() == null || mainConfig.getProxyIgnoreDomains().isEmpty()) { return false; } return mainConfig.getProxyIgnoreDomains().stream().anyMatch(x -> isSameHost(x, host)); }  @PostConstruct void init(); @EventListener void handleConfigChangedEvent(ConfigChangedEvent event); @Override ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod); @Override AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod); Builder getOkHttpClientBuilder(URI requestUri); static long ipToLong(InetAddress ip); }
HydraOkHttp3ClientHttpRequestFactory implements ClientHttpRequestFactory, AsyncClientHttpRequestFactory { protected boolean isUriToBeIgnoredByProxy(String host) { MainConfig mainConfig = configProvider.getBaseConfig().getMain(); if (mainConfig.isProxyIgnoreLocal()) { Boolean ipToLong = isHostInLocalNetwork(host); if (ipToLong != null) { return ipToLong; } } if (mainConfig.getProxyIgnoreDomains() == null || mainConfig.getProxyIgnoreDomains().isEmpty()) { return false; } return mainConfig.getProxyIgnoreDomains().stream().anyMatch(x -> isSameHost(x, host)); }  @PostConstruct void init(); @EventListener void handleConfigChangedEvent(ConfigChangedEvent event); @Override ClientHttpRequest createRequest(URI uri, HttpMethod httpMethod); @Override AsyncClientHttpRequest createAsyncRequest(URI uri, HttpMethod httpMethod); Builder getOkHttpClientBuilder(URI requestUri); static long ipToLong(InetAddress ip);  }