aboutsummaryrefslogtreecommitdiff
path: root/other/java/client/src
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2021-09-07 16:43:54 -0700
committerChris Lu <chris.lu@gmail.com>2021-09-07 16:43:54 -0700
commit0128239c0f8829bb20edd1df257840dcbfa37c0e (patch)
tree4bf3d7a7ffc313d2c8a8547326204a632d48c4a4 /other/java/client/src
parent35c8ea495fd21f7f10343717a5e1275782b7cae0 (diff)
downloadseaweedfs-0128239c0f8829bb20edd1df257840dcbfa37c0e.tar.xz
seaweedfs-0128239c0f8829bb20edd1df257840dcbfa37c0e.zip
handle ipv6 addresses
Diffstat (limited to 'other/java/client/src')
-rw-r--r--other/java/client/src/main/java/seaweedfs/client/FilerGrpcClient.java2
-rw-r--r--other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java10
2 files changed, 11 insertions, 1 deletions
diff --git a/other/java/client/src/main/java/seaweedfs/client/FilerGrpcClient.java b/other/java/client/src/main/java/seaweedfs/client/FilerGrpcClient.java
index 6c57e2e0d..56aa35876 100644
--- a/other/java/client/src/main/java/seaweedfs/client/FilerGrpcClient.java
+++ b/other/java/client/src/main/java/seaweedfs/client/FilerGrpcClient.java
@@ -54,7 +54,7 @@ public class FilerGrpcClient {
.negotiationType(NegotiationType.TLS)
.sslContext(sslContext));
- filerAddress = String.format("%s:%d", host, grpcPort - 10000);
+ filerAddress = SeaweedUtil.joinHostPort(host, grpcPort - 10000);
FilerProto.GetFilerConfigurationResponse filerConfigurationResponse =
this.getBlockingStub().getFilerConfiguration(
diff --git a/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java b/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java
index 66ea9a98d..027e49b96 100644
--- a/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java
+++ b/other/java/client/src/main/java/seaweedfs/client/SeaweedUtil.java
@@ -43,4 +43,14 @@ public class SeaweedUtil {
String name = fullpath.substring(sep + 1);
return new String[]{parent, name};
}
+
+ public static String joinHostPort(String host, int port) {
+ if (host.startsWith("[") && host.endsWith("]")) {
+ return host + ":" + port;
+ }
+ if (host.indexOf(':')>=0) {
+ return "[" + host + "]:" + port;
+ }
+ return host + ":" + port;
+ }
}