diff --git a/pom.xml b/pom.xml
index 4b55cf9..40dbd4e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -3,7 +3,7 @@
4.0.0
org.nhind
config-manager
- 6.0
+ 6.0.1
jar
NHIN Direct Java configuration manager
NHIN Direct Java configuration manager
@@ -11,7 +11,7 @@
org.springframework.boot
spring-boot-starter-parent
- 2.1.2.RELEASE
+ 2.1.6.RELEASE
@@ -38,7 +38,7 @@
UTF-8
- Greenwich.RELEASE
+ Greenwich.SR1
@@ -60,12 +60,12 @@
org.nhind
direct-common
- 6.0
+ 6.0.1
org.nhind
agent
- 6.0
+ 6.0.2
@@ -88,7 +88,7 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 2.6.1
+ 2.9.1
-Xdoclint:none
UTF-8
@@ -108,8 +108,7 @@
-
-
+
@@ -136,7 +134,7 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 2.6.1
+ 2.9.1
-Xdoclint:none
UTF-8
diff --git a/src/main/java/org/nhindirect/config/manager/DNSRecordCommands.java b/src/main/java/org/nhindirect/config/manager/DNSRecordCommands.java
index 8651841..73d8a53 100644
--- a/src/main/java/org/nhindirect/config/manager/DNSRecordCommands.java
+++ b/src/main/java/org/nhindirect/config/manager/DNSRecordCommands.java
@@ -118,6 +118,12 @@ public class DNSRecordCommands
private static final String GET_ALL_USAGE = "Gets all records in the DNS store.";
private static final String GET_SOA_CONTACTS = "Gets a list of all the different SOA contacts.";
+
+ private static final String ADD_SRV_USAGE = "Add a new SRV dns record." +
+ "\r\n" + DNSRecordParser.PARSE_SRV_USAGE;
+
+ private static final String ENSURE_SRV_USAGE = "Adds a new SRV dns record if an identical one does't already exist. " +
+ "\r\n" + DNSRecordParser.PARSE_SRV_USAGE;
private DNSRecordPrinter printer;
private DNSRecordParser parser;
@@ -749,6 +755,39 @@ private DNSRecord find(DNSRecord record)
return null;
}
+ /**
+ * Adds an SRV record to the configuration service.
+ * @param args Contains the SRV record attributes.
+ *
+ * @since 1.0
+ */
+ @Command(name = "Dns_SRV_Add", usage = ADD_SRV_USAGE)
+ public void addSRV(String[] args)
+ {
+ DNSRecord record = fromRecord(parser.parseSRV(args));
+
+ addDNS(record);
+ }
+
+ /**
+ * Adds an SRV record to the configuration service only if the record does not exist.
+ * @param args Contains the SRV record attributes.
+ *
+ * @since 1.0
+ */
+ @Command(name = "Dns_SRV_Ensure", usage = ENSURE_SRV_USAGE)
+ public void ensureSRV(String[] args)
+ {
+ DNSRecord record = fromRecord(parser.parseSRV(args));
+ if (!verifyIsUnique(record, false))
+ {
+ return;
+ }
+
+
+ addDNS(record);
+ }
+
/*
* prints the contents of an array of records
*/
diff --git a/src/main/java/org/nhindirect/config/manager/DNSRecordParser.java b/src/main/java/org/nhindirect/config/manager/DNSRecordParser.java
index 75bc6fd..f688683 100644
--- a/src/main/java/org/nhindirect/config/manager/DNSRecordParser.java
+++ b/src/main/java/org/nhindirect/config/manager/DNSRecordParser.java
@@ -31,6 +31,7 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
import org.xbill.DNS.NSRecord;
import org.xbill.DNS.Name;
import org.xbill.DNS.SOARecord;
+import org.xbill.DNS.SRVRecord;
import org.xbill.DNS.TXTRecord;
/**
@@ -77,6 +78,14 @@ public class DNSRecordParser
"\r\n\t alias: the text value of the record" +
"\r\n\t ttl: time to live in seconds";
+ public static final String PARSE_SRV_USAGE = " name target port priority weight ttl" +
+ "\r\n\t name: the name of the SRV entry" +
+ "\r\n\t target: the server that hosts the service of the SRV entry" +
+ "\r\n\t port: the IP port to use when conneting to the target" +
+ "\r\n\t priority: the priority the record compared to other SRV records of the same name" +
+ "\r\n\t weight: the weight the record compared to other SRV records of the same name and priority" +
+ "\r\n\t ttl: time to live in seconds";
+
/**
* Default empty constructor
*
@@ -230,4 +239,23 @@ public NSRecord parseNS(String[] args)
return new NSRecord(nameFromString(domainName), DClass.IN, ttl, nameFromString(target));
}
+
+ /**
+ * Converts SRV record configuration information to an SRVRecord
+ * @param args The NS record configuration parameters.
+ * @return A DNS NSRecord.
+ *
+ * @since 6.0.1
+ */
+ public SRVRecord parseSRV(String[] args)
+ {
+ String name = StringArrayUtil.getRequiredValue(args, 0);
+ String target = StringArrayUtil.getRequiredValue(args, 1);
+ int port = Integer.parseInt(StringArrayUtil.getRequiredValue(args, 2));
+ int priority = Integer.parseInt(StringArrayUtil.getRequiredValue(args, 3));
+ int weight = Integer.parseInt(StringArrayUtil.getRequiredValue(args, 4));
+ int ttl = Integer.parseInt(StringArrayUtil.getRequiredValue(args, 5));
+
+ return new SRVRecord(nameFromString(name), DClass.IN, ttl, priority, weight, port, nameFromString(target));
+ }
}
diff --git a/src/main/java/org/nhindirect/config/manager/printers/DefaultDNSRecordPrinter.java b/src/main/java/org/nhindirect/config/manager/printers/DefaultDNSRecordPrinter.java
index 95d2528..4c9b14d 100644
--- a/src/main/java/org/nhindirect/config/manager/printers/DefaultDNSRecordPrinter.java
+++ b/src/main/java/org/nhindirect/config/manager/printers/DefaultDNSRecordPrinter.java
@@ -99,6 +99,12 @@ private String typeToString(int type)
case Type.NS:
return "NS";
+ case Type.CNAME:
+ return "CNAME";
+
+ case Type.TXT:
+ return "TXT";
+
default:
return "Unknown";
}
@@ -151,6 +157,7 @@ public void print(DNSRecord record)
case Type.NS:
print((NSRecord)toRecord(record));
break;
+
}
writer.flush();