This is an automated email from the ASF dual-hosted git repository.

aloyszhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/inlong.git


The following commit(s) were added to refs/heads/master by this push:
     new 1a96ec490c [INLONG-11330][Audit] Audit SDK supports custom setting of 
local IP (#11331)
1a96ec490c is described below

commit 1a96ec490cdcc9ab6159b892ce14c3e4fe03c548
Author: doleyzi <43397300+dole...@users.noreply.github.com>
AuthorDate: Fri Oct 11 14:09:13 2024 +0800

    [INLONG-11330][Audit] Audit SDK supports custom setting of local IP (#11331)
---
 .../src/main/java/org/apache/inlong/audit/AuditReporterImpl.java | 8 ++++++++
 .../src/main/java/org/apache/inlong/audit/util/Config.java       | 9 +++++++--
 2 files changed, 15 insertions(+), 2 deletions(-)

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 e8a38da28f..7d3f1c5755 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 class AuditReporterImpl implements Serializable {
         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 a18ba1a860..a519a7a85f 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 @@ import java.util.Enumeration;
 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 class Config {
         initIP();
         initDockerId();
     }
-
+    public void setLocalIP(String localIP) {
+        this.localIP = localIP;
+    }
     public String getLocalIP() {
         return localIP;
     }
@@ -50,6 +52,9 @@ public class Config {
     }
 
     private void initIP() {
+        if (localIP != null) {
+            return;
+        }
         try {
             for (Enumeration<NetworkInterface> en = 
NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
                 NetworkInterface intf = en.nextElement();

Reply via email to