You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/11/28 01:58:15 UTC

[GitHub] [dolphinscheduler] ruanwenjun commented on a diff in pull request #13013: [Fix-12981]add worker address validator and clear function.

ruanwenjun commented on code in PR #13013:
URL: https://github.com/apache/dolphinscheduler/pull/13013#discussion_r1033060793


##########
dolphinscheduler-master/src/main/java/org/apache/dolphinscheduler/server/master/registry/ServerNodeManager.java:
##########
@@ -201,13 +203,25 @@ public void notify(Event event) {
         }
 
         private void syncSingleWorkerNodeInfo(String workerAddress, WorkerHeartBeat info) {
+            if (!NetUtils.isLegalAddress(workerAddress)) {

Review Comment:
   I don't think this is needed.



##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/NetUtils.java:
##########
@@ -332,4 +334,35 @@ private static NetworkInterface findOuterAddress(List<NetworkInterface> validNet
         return networkInterface;
     }
 
+    /**
+     * check if address is legal address, a legal address should be ip:port
+     * @param ipAndPortAddress address to check
+     * @return true if address is legal
+     */
+    public static boolean isLegalAddress(String ipAndPortAddress) {
+        if (StringUtils.isEmpty(ipAndPortAddress)) {
+            return false;
+        }
+        String[] ipAndPort = ipAndPortAddress.split(":");
+        if (ipAndPort.length != 2) {
+            return false;
+        }
+        return isValidIPv4Address(ipAndPort[0]) && isValidPort(ipAndPort[1]);

Review Comment:
   Can this work on ipv6?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org