diff --git a/pom.xml b/pom.xml
index 397a424..7ca2f3c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -151,19 +151,5 @@
-
-
-
- native
-
-
- native
-
-
-
- false
- true
-
-
-
+
diff --git a/src/main/java/de/rpr/ddnsclient/lookup/IpLookupProviders.java b/src/main/java/de/rpr/ddnsclient/lookup/IpLookupProviders.java
new file mode 100644
index 0000000..08f05a2
--- /dev/null
+++ b/src/main/java/de/rpr/ddnsclient/lookup/IpLookupProviders.java
@@ -0,0 +1,39 @@
+package de.rpr.ddnsclient.lookup;
+
+import org.jboss.logging.Logger;
+
+import java.security.SecureRandom;
+import java.util.Arrays;
+import java.util.NoSuchElementException;
+
+enum IpLookupProviders {
+ IFCONFIG_ME("ifconfig.me", "ifconfig.me"),
+ IPIFY_ORG("ipify.org", "api64.ipify.org"),
+ IDENT_ME("ident.me", "ident.me"),
+ NNEV_DE("nnev.de", "ip.nnev.de"),
+ I_CAN_HAZ_IP_COM("icanhazip.com", "icanhazip.com");
+
+ private static final Logger log = Logger.getLogger(PublicIpLookup.class);
+
+ final String url;
+ private final String tld;
+ private static final SecureRandom secureRandom = new SecureRandom();
+
+ IpLookupProviders(String tld, String url) {
+ this.tld = tld;
+ this.url = url;
+ }
+
+ public static IpLookupProviders get(String candidate) {
+ return Arrays.stream(values())
+ .filter(it -> it.tld.equals(candidate))
+ .findFirst()
+ .orElseThrow(() -> new NoSuchElementException("Unknown ip provider!"));
+ }
+
+ public static IpLookupProviders random() {
+ IpLookupProviders randomProvider = values()[secureRandom.nextInt(values().length)];
+ log.tracef("Choosing ip lookup provider %s", randomProvider);
+ return randomProvider;
+ }
+}
diff --git a/src/main/java/de/rpr/ddnsclient/lookup/PublicIpLookup.java b/src/main/java/de/rpr/ddnsclient/lookup/PublicIpLookup.java
index a05f693..cd3f23b 100644
--- a/src/main/java/de/rpr/ddnsclient/lookup/PublicIpLookup.java
+++ b/src/main/java/de/rpr/ddnsclient/lookup/PublicIpLookup.java
@@ -10,9 +10,6 @@ import org.jboss.logging.Logger;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.security.SecureRandom;
-import java.util.Arrays;
-import java.util.NoSuchElementException;
import java.util.Optional;
@ApplicationScoped
@@ -31,42 +28,13 @@ public class PublicIpLookup {
this.configuredProvider = configuredProvider;
}
- enum Providers {
- IFCONFIG_ME("ifconfig.me", "ifconfig.me"),
- IPIFY_ORG("ipify.org", "api64.ipify.org"),
- IDENT_ME("ident.me", "ident.me"),
- NNEV_DE("nnev.de", "ip.nnev.de"),
- I_CAN_HAZ_IP_COM("icanhazip.com", "icanhazip.com");
-
- final String url;
- private final String tld;
-
- Providers(String tld, String url) {
- this.tld = tld;
- this.url = url;
- }
-
- public static Providers get(String candidate) {
- return Arrays.stream(values())
- .filter(it -> it.tld.equals(candidate))
- .findFirst()
- .orElseThrow(() -> new NoSuchElementException("Unknown ip provider!"));
- }
-
- public static Providers random() {
- Providers randomProvider = values()[new SecureRandom().nextInt(values().length)];
- log.tracef("Choosing ip lookup provider %s", randomProvider);
- return randomProvider;
- }
- }
-
- private Optional provider = Optional.empty();
+ private Optional provider = Optional.empty();
void onStart(@Observes StartupEvent event) {
try {
configuredProvider.ifPresent(it -> {
log.tracef("Setting ip lookup provider %s", it);
- provider = Optional.of(Providers.get(it));
+ provider = Optional.of(IpLookupProviders.get(it));
}
);
} catch (Exception e) {
@@ -78,7 +46,7 @@ public class PublicIpLookup {
log.trace("Retrieving public ips.");
try {
- String provider = this.provider.map(it -> it.url).orElseGet(() -> Providers.random().url);
+ String provider = this.provider.map(it -> it.url).orElseGet(() -> IpLookupProviders.random().url);
String v4 = getIp(provider, CurlProcessFactory.IpClass.V4);
String v6 = getIp(provider, CurlProcessFactory.IpClass.V6);