From 447fee913990db825f5b7b7e535af946653281b8 Mon Sep 17 00:00:00 2001 From: gm2552 Date: Fri, 25 Jan 2019 06:22:32 -0600 Subject: [PATCH 1/4] Updating project to version 6.1-SNAPSHOT. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 4b55cf9..b1e0418 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.nhind config-manager - 6.0 + 6.1-SNAPSHOT jar NHIN Direct Java configuration manager NHIN Direct Java configuration manager From 7baa77aa380d8785290a8bf82c131c3bc8a633bf Mon Sep 17 00:00:00 2001 From: gm2552 Date: Fri, 8 Mar 2019 07:19:46 -0600 Subject: [PATCH 2/4] Updating to SpringBoot 2.1.3 and SpringCloud Greenwich.SR1 --- pom.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index b1e0418..7a94b79 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.nhind config-manager - 6.1-SNAPSHOT + 6.0.1-SNAPSHOT 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.3.RELEASE @@ -38,7 +38,7 @@ UTF-8 - Greenwich.RELEASE + Greenwich.SR1 @@ -55,17 +55,17 @@ org.nhind config-service-client - 6.0 + 6.0.1-SNAPSHOT org.nhind direct-common - 6.0 + 6.0.1-SNAPSHOT org.nhind agent - 6.0 + 6.0.3-SNAPSHOT From fa96dfabc6bb7b54311af00c322d1e33e41f90c3 Mon Sep 17 00:00:00 2001 From: gm2552 Date: Fri, 8 Mar 2019 10:42:21 -0600 Subject: [PATCH 3/4] Updating javadoc plugin to 2.9.1 --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 7a94b79..ac4431d 100644 --- a/pom.xml +++ b/pom.xml @@ -88,7 +88,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.6.1 + 2.9.1 -Xdoclint:none UTF-8 @@ -136,7 +136,7 @@ org.apache.maven.plugins maven-javadoc-plugin - 2.6.1 + 2.9.1 -Xdoclint:none UTF-8 From 51ab8d2f4da005f0f4088c17e2cd0af873b193db Mon Sep 17 00:00:00 2001 From: gm2552 Date: Mon, 22 Jul 2019 10:31:28 -0500 Subject: [PATCH 4/4] Adding ability to add txt records. --- pom.xml | 16 ++++---- .../config/manager/DNSRecordCommands.java | 39 +++++++++++++++++++ .../config/manager/DNSRecordParser.java | 28 +++++++++++++ .../printers/DefaultDNSRecordPrinter.java | 7 ++++ 4 files changed, 81 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index ac4431d..40dbd4e 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.nhind config-manager - 6.0.1-SNAPSHOT + 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.3.RELEASE + 2.1.6.RELEASE @@ -55,17 +55,17 @@ org.nhind config-service-client - 6.0.1-SNAPSHOT + 6.0 org.nhind direct-common - 6.0.1-SNAPSHOT + 6.0.1 org.nhind agent - 6.0.3-SNAPSHOT + 6.0.2 @@ -108,8 +108,7 @@ - - + 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();