Skip to content

Commit fc6b772

Browse files
authored
Fix host validation to support domain name (#436) (#439)
* Fix host validation to support domain name * lint: fixed line length
1 parent 176a8f2 commit fc6b772

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

client/src/main/java/com/vesoft/nebula/client/meta/AbstractMetaClient.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.facebook.thrift.transport.TTransport;
1010
import com.google.common.base.Preconditions;
1111
import com.google.common.net.InetAddresses;
12+
import com.google.common.net.InternetDomainName;
1213
import com.vesoft.nebula.client.graph.data.HostAddress;
1314
import java.net.InetAddress;
1415
import java.net.UnknownHostException;
@@ -31,8 +32,10 @@ public AbstractMetaClient(List<HostAddress> addresses, int timeout,
3132
for (HostAddress address : addresses) {
3233
String host = InetAddress.getByName(address.getHost()).getHostAddress();
3334
int port = address.getPort();
34-
// check if the address is a valid ip address or uri address and port is valid
35-
if ((!InetAddresses.isInetAddress(host) || !InetAddresses.isUriInetAddress(host))
35+
// check if the address is a valid ip, uri address or domain name and port is valid
36+
if (!(InetAddresses.isInetAddress(host)
37+
|| InetAddresses.isUriInetAddress(host)
38+
|| InternetDomainName.isValid(host))
3639
|| (port <= 0 || port >= 65535)) {
3740
throw new IllegalArgumentException(String.format("%s:%d is not a valid address",
3841
host, port));

0 commit comments

Comments
 (0)