add gateway information to IPv6Trick
This commit is contained in:
parent
416e5a9101
commit
5c2f773269
4
util/.gitignore
vendored
4
util/.gitignore
vendored
@ -1,3 +1,7 @@
|
||||
/build
|
||||
/target
|
||||
/bin
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>de.hsadmin.core</groupId>
|
||||
<artifactId>hsadmin-util</artifactId>
|
||||
<version>4.0.4-SNAPSHOT</version>
|
||||
<version>4.0.5</version>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
|
@ -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)) {
|
||||
|
Loading…
Reference in New Issue
Block a user