From c5fc07024cca407533765e96258663b6c45e6173 Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Mon, 6 Mar 2023 12:04:52 +0100 Subject: [PATCH] provide ip gateway --- hsarback/src/de/hsadmin/mods/pac/INetAddress.java | 8 ++++++++ hsarback/src/de/hsadmin/pillar/JsonPillarServlet.java | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/pac/INetAddress.java b/hsarback/src/de/hsadmin/mods/pac/INetAddress.java index 6c74c18..0e5f6a1 100644 --- a/hsarback/src/de/hsadmin/mods/pac/INetAddress.java +++ b/hsarback/src/de/hsadmin/mods/pac/INetAddress.java @@ -73,10 +73,18 @@ public class INetAddress extends AbstractEntity implements Serializable { return name; } + public String getInet4Gateway() throws HSAdminException { + return IPv6Trick.IPv4Gateway(name); + } + public String getInet6Addr() throws HSAdminException { return IPv6Trick.convertIPv4ToIPv6(name); } + public String getInet6Gateway() throws HSAdminException { + return IPv6Trick.IPv6Gateway(name); + } + public void setInetAddr(String inetAddr) { this.name = inetAddr; } diff --git a/hsarback/src/de/hsadmin/pillar/JsonPillarServlet.java b/hsarback/src/de/hsadmin/pillar/JsonPillarServlet.java index 519a3fb..78bd670 100644 --- a/hsarback/src/de/hsadmin/pillar/JsonPillarServlet.java +++ b/hsarback/src/de/hsadmin/pillar/JsonPillarServlet.java @@ -76,9 +76,16 @@ public class JsonPillarServlet extends HttpServlet { final PrintWriter writer = resp.getWriter(); writer.println("{"); writer.println(" \"hivename\": \"" + hive.getHiveName() + "\""); - writer.println(" , \"hiveipv4\": \"" + hive.getInetAddr().getInet4Addr() + "\""); + final INetAddress inetAddr = hive.getInetAddr(); + writer.println(" , \"hiveipv4\": \"" + inetAddr.getInet4Addr() + "\""); try { - writer.println(" , \"hiveipv6\": \"" + hive.getInetAddr().getInet6Addr() + "\""); + writer.println(" , \"hiveipv4gateway\": \"" + inetAddr.getInet4Gateway() + "\""); + } catch (HSAdminException e) { + // dont care + } + try { + writer.println(" , \"hiveipv6\": \"" + inetAddr.getInet6Addr() + "\""); + writer.println(" , \"hiveipv6gateway\": \"" + inetAddr.getInet6Gateway() + "\""); } catch (HSAdminException e) { // dont care }