diff --git a/HISTORY b/HISTORY
index 0b901d8..ff63444 100644
--- a/HISTORY
+++ b/HISTORY
@@ -1,4 +1,10 @@
+Version 1.36 2025-10-26
+ * monitor protocol compatible with IPv4/IPv6 address automatically
+ * FastDFS server verson requirements:
+ # group and storage statistics / monitor APIs: FastDFS server >= V6.13.1
+ # other APIs: FastDFS server >= V6.06
+
Version 1.35 2025-09-04
* group and storage statistics / monitor API output reserved
and available space
diff --git a/pom.xml b/pom.xml
index f15b9c4..d234c28 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
+ * FastDFS Java Client may be copied only under the terms of the GNU Lesser + * General Public License (LGPL). + * Please visit the FastDFS Home Page https://github.com/happyfish100/fastdfs for more detail. + */ + +package org.csource.fastdfs; + +import java.util.Date; + +/** + * C struct body decoder + * + * @author Happy Fish / YuQing + * @version Version 1.36 + */ +public class StructIPv4StorageStat extends StructStorageStat { + protected static int fieldsTotalSize; + protected static StructBase.FieldInfo[] fieldsArray = + new StructBase.FieldInfo[StructStorageStat.FIELD_COUNT]; + + static { + fieldsTotalSize = StructStorageStat.initFieldsArray( + fieldsArray, ProtoCommon.FDFS_IPV4_SIZE); + } + + /** + * get fields total size + * + * @return fields total size + */ + public static int getFieldsTotalSize() { + return fieldsTotalSize; + } + + /** + * + * @param bs byte array + * @param offset start offset + */ + public void setFields(byte[] bs, int offset) { + super.setFields(fieldsArray, bs, offset); + } +} diff --git a/src/main/java/org/csource/fastdfs/StructIPv6StorageStat.java b/src/main/java/org/csource/fastdfs/StructIPv6StorageStat.java new file mode 100644 index 0000000..6cc9dbd --- /dev/null +++ b/src/main/java/org/csource/fastdfs/StructIPv6StorageStat.java @@ -0,0 +1,46 @@ +/** + * Copyright (C) 2025 Happy Fish / YuQing + *
+ * FastDFS Java Client may be copied only under the terms of the GNU Lesser
+ * General Public License (LGPL).
+ * Please visit the FastDFS Home Page https://github.com/happyfish100/fastdfs for more detail.
+ */
+
+package org.csource.fastdfs;
+
+import java.util.Date;
+
+/**
+ * C struct body decoder
+ *
+ * @author Happy Fish / YuQing
+ * @version Version 1.36
+ */
+public class StructIPv6StorageStat extends StructStorageStat {
+ protected static int fieldsTotalSize;
+ protected static StructBase.FieldInfo[] fieldsArray =
+ new StructBase.FieldInfo[StructStorageStat.FIELD_COUNT];
+
+ static {
+ fieldsTotalSize = StructStorageStat.initFieldsArray(
+ fieldsArray, ProtoCommon.FDFS_IPV6_SIZE);
+ }
+
+ /**
+ * get fields total size
+ *
+ * @return fields total size
+ */
+ public static int getFieldsTotalSize() {
+ return fieldsTotalSize;
+ }
+
+ /**
+ *
+ * @param bs byte array
+ * @param offset start offset
+ */
+ public void setFields(byte[] bs, int offset) {
+ super.setFields(fieldsArray, bs, offset);
+ }
+}
diff --git a/src/main/java/org/csource/fastdfs/StructStorageStat.java b/src/main/java/org/csource/fastdfs/StructStorageStat.java
index 039529b..e78da22 100644
--- a/src/main/java/org/csource/fastdfs/StructStorageStat.java
+++ b/src/main/java/org/csource/fastdfs/StructStorageStat.java
@@ -85,10 +85,7 @@ public class StructStorageStat extends StructBase {
protected static final int FIELD_COUNT = 62;
- protected static int fieldsTotalSize;
- protected static StructBase.FieldInfo[] fieldsArray = new StructBase.FieldInfo[FIELD_COUNT];
-
- static {
+ protected static int initFieldsArray(StructBase.FieldInfo[] fieldsArray, int ipaddr_size) {
int offset = 0;
fieldsArray[FIELD_INDEX_STATUS] = new StructBase.FieldInfo(
@@ -104,8 +101,8 @@ public class StructStorageStat extends StructBase {
offset += ProtoCommon.FDFS_STORAGE_ID_MAX_SIZE;
fieldsArray[FIELD_INDEX_IP_ADDR] = new StructBase.FieldInfo(
- "ipAddr", offset, ProtoCommon.FDFS_IPV6_SIZE);
- offset += ProtoCommon.FDFS_IPV6_SIZE;
+ "ipAddr", offset, ipaddr_size);
+ offset += ipaddr_size;
fieldsArray[FIELD_INDEX_SRC_ID] = new StructBase.FieldInfo(
"srcId", offset, ProtoCommon.FDFS_STORAGE_ID_MAX_SIZE);
@@ -339,16 +336,7 @@ public class StructStorageStat extends StructBase {
"ifTrunkServer", offset, 1);
offset += 1;
- fieldsTotalSize = offset;
- }
-
- /**
- * get fields total size
- *
- * @return fields total size
- */
- public static int getFieldsTotalSize() {
- return fieldsTotalSize;
+ return offset;
}
protected byte status;
@@ -978,7 +966,7 @@ public class StructStorageStat extends StructBase {
* @param bs byte array
* @param offset start offset
*/
- public void setFields(byte[] bs, int offset) {
+ protected void setFields(StructBase.FieldInfo[] fieldsArray, byte[] bs, int offset) {
this.status = byteValue(bs, offset, fieldsArray[FIELD_INDEX_STATUS]);
this.readWriteMode = byteValue(bs, offset, fieldsArray[FIELD_INDEX_RW_MODE]);
this.id = stringValue(bs, offset, fieldsArray[FIELD_INDEX_ID]);
@@ -1044,4 +1032,7 @@ public class StructStorageStat extends StructBase {
this.lastHeartBeatTime = dateValue(bs, offset, fieldsArray[FIELD_INDEX_LAST_HEART_BEAT_TIME]);
this.ifTrunkServer = booleanValue(bs, offset, fieldsArray[FIELD_INDEX_IF_TRUNK_FILE]);
}
+
+ public void setFields(byte[] bs, int offset) {
+ }
}
diff --git a/src/main/java/org/csource/fastdfs/TrackerClient.java b/src/main/java/org/csource/fastdfs/TrackerClient.java
index 0249963..565ee56 100644
--- a/src/main/java/org/csource/fastdfs/TrackerClient.java
+++ b/src/main/java/org/csource/fastdfs/TrackerClient.java
@@ -657,7 +657,8 @@ public class TrackerClient {
ipAddrLen = 0;
}
- header = ProtoCommon.packHeader(ProtoCommon.TRACKER_PROTO_CMD_SERVER_LIST_STORAGE, ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + ipAddrLen, (byte) 0);
+ header = ProtoCommon.packHeader(ProtoCommon.TRACKER_PROTO_CMD_SERVER_LIST_STORAGE,
+ ProtoCommon.FDFS_GROUP_NAME_MAX_LEN + ipAddrLen, (byte) 0);
byte[] wholePkg = new byte[header.length + bGroupName.length + ipAddrLen];
System.arraycopy(header, 0, wholePkg, 0, header.length);
System.arraycopy(bGroupName, 0, wholePkg, header.length, bGroupName.length);
@@ -673,9 +674,17 @@ public class TrackerClient {
return null;
}
- ProtoStructDecoder