diff --git a/util/.gitignore b/util/.gitignore
index 3deeadc..21d4321 100644
--- a/util/.gitignore
+++ b/util/.gitignore
@@ -1,3 +1,7 @@
/build
/target
/bin
+.classpath
+.project
+.settings/
+
diff --git a/util/pom.xml b/util/pom.xml
index 1c6672c..fa80fc1 100644
--- a/util/pom.xml
+++ b/util/pom.xml
@@ -4,7 +4,7 @@
4.0.0
de.hsadmin.core
hsadmin-util
- 4.0.4-SNAPSHOT
+ 4.0.5
UTF-8
1.8
diff --git a/util/src/main/java/de/hsadmin/core/util/IPv6Trick.java b/util/src/main/java/de/hsadmin/core/util/IPv6Trick.java
index bab3fff..760ccd7 100644
--- a/util/src/main/java/de/hsadmin/core/util/IPv6Trick.java
+++ b/util/src/main/java/de/hsadmin/core/util/IPv6Trick.java
@@ -44,6 +44,46 @@ public class IPv6Trick {
throw new HSAdminException("unknown IPv4 address given");
}
+ public static String IPv4Gateway (final String ipv4address) throws HSAdminException {
+ if (ipv4address == null || ipv4address.length() == 0) {
+ throw new HSAdminException("no IPv4 address given");
+ }
+ try {
+ final InetAddress inetV4Address = InetAddress.getByName(ipv4address);
+ final String inetV4AddressString = inetV4Address.getHostAddress();
+ if (inetV4AddressString.startsWith(IPv4_83_223_78)) return IPv4_83_223_78 + ".1";
+ if (inetV4AddressString.startsWith(IPv4_83_223_79)) return IPv4_83_223_79 + ".1";
+ if (inetV4AddressString.startsWith(IPv4_83_223_91)) return IPv4_83_223_91 + ".1";
+ if (inetV4AddressString.startsWith(IPv4_83_223_94)) return IPv4_83_223_94 + ".1";
+ if (inetV4AddressString.startsWith(IPv4_83_223_95)) return IPv4_83_223_95 + ".1";
+ throw new HSAdminException("unknown IPv4 address given");
+ } catch (UnknownHostException e) {
+ throw new HSAdminException(e);
+ }
+ }
+
+ public static String IPv6Gateway (final String ipv4address) throws HSAdminException {
+ if (ipv4address == null || ipv4address.length() == 0) {
+ throw new HSAdminException("no IPv4 address given");
+ }
+ try {
+ final InetAddress inetV4Address = InetAddress.getByName(ipv4address);
+ final String inetV4AddressString = inetV4Address.getHostAddress();
+ if (inetV4AddressString.startsWith(IPv4_83_223_79) // Alboin-Kontor Berlin
+ || inetV4AddressString.startsWith(IPv4_83_223_91)
+ || inetV4AddressString.startsWith(IPv4_83_223_95) ) {
+ return IPv6_PREFIX_AK;
+ }
+ if (inetV4AddressString.startsWith(IPv4_83_223_78) // e-Shelter Berlin
+ || inetV4AddressString.startsWith(IPv4_83_223_94) ) {
+ return IPv6_PREFIX_ES;
+ }
+ } catch (UnknownHostException e) {
+ throw new HSAdminException(e);
+ }
+ throw new HSAdminException("unknown IPv4 address given");
+ }
+
public static boolean isKnownRemote(final String remoteAddress) {
boolean isKnown = false;
if (remoteAddress.startsWith(IPv4_LOCALHOST) || remoteAddress.startsWith(IPv6_LOCALHOST) || remoteAddress.startsWith(IPv6_LOCALHOST_ALT)) {