!223 update 使用 apache 网络工具 替换 sun 工具 兼容jdk11处理

Merge pull request !223 from 疯狂的狮子Li/N/A
This commit is contained in:
lbw 2022-04-22 07:24:40 +00:00 committed by Gitee
commit 7bac3d9702
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -20,6 +20,7 @@ import com.alibaba.csp.sentinel.util.StringUtil;
import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo; import com.alibaba.csp.sentinel.dashboard.discovery.MachineInfo;
import com.alibaba.csp.sentinel.dashboard.domain.Result; import com.alibaba.csp.sentinel.dashboard.domain.Result;
import org.apache.http.conn.util.InetAddressUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -50,7 +51,9 @@ public class MachineRegistryController {
if (StringUtil.isBlank(ip) || ip.length() > 128) { if (StringUtil.isBlank(ip) || ip.length() > 128) {
return Result.ofFail(-1, "invalid ip: " + ip); return Result.ofFail(-1, "invalid ip: " + ip);
} }
if (!InetAddressUtils.isIPv4Address(ip) && !InetAddressUtils.isIPv6Address(ip)) {
return Result.ofFail(-1, "invalid ip: " + ip);
}
if (port == null || port < -1) { if (port == null || port < -1) {
return Result.ofFail(-1, "invalid port"); return Result.ofFail(-1, "invalid port");
} }