diff --git a/inlong-audit/audit-sdk/src/main/java/org/apache/inlong/audit/AuditReporterImpl.java b/inlong-audit/audit-sdk/src/main/java/org/apache/inlong/audit/AuditReporterImpl.java index e8a38da28f9..7d3f1c5755d 100644 --- a/inlong-audit/audit-sdk/src/main/java/org/apache/inlong/audit/AuditReporterImpl.java +++ b/inlong-audit/audit-sdk/src/main/java/org/apache/inlong/audit/AuditReporterImpl.java @@ -194,6 +194,14 @@ public void setAuditProxy(HashSet ipPortList) { ProxyManager.getInstance().setAuditProxy(ipPortList); } + /** + * Set local IP + * @param localIP + */ + public void setLocalIP(String localIP) { + config.setLocalIP(localIP); + } + /** * Set AuditProxy from the manager host */ diff --git a/inlong-audit/audit-sdk/src/main/java/org/apache/inlong/audit/util/Config.java b/inlong-audit/audit-sdk/src/main/java/org/apache/inlong/audit/util/Config.java index a18ba1a8607..a519a7a85fd 100644 --- a/inlong-audit/audit-sdk/src/main/java/org/apache/inlong/audit/util/Config.java +++ b/inlong-audit/audit-sdk/src/main/java/org/apache/inlong/audit/util/Config.java @@ -31,7 +31,7 @@ public class Config { private static final Logger logger = LoggerFactory.getLogger(Config.class); - private String localIP = ""; + private String localIP; private String dockerId = ""; private static final int CGROUP_FILE_LENGTH = 50; private static final int DOCKERID_LENGTH = 10; @@ -40,7 +40,9 @@ public void init() { initIP(); initDockerId(); } - + public void setLocalIP(String localIP) { + this.localIP = localIP; + } public String getLocalIP() { return localIP; } @@ -50,6 +52,9 @@ public String getDockerId() { } private void initIP() { + if (localIP != null) { + return; + } try { for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) { NetworkInterface intf = en.nextElement();