Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.nhind</groupId>
<artifactId>config-manager</artifactId>
<version>6.0</version>
<version>6.0.1</version>
<packaging>jar</packaging>
<name>NHIN Direct Java configuration manager</name>
<description>NHIN Direct Java configuration manager</description>
<url>https://github.com/DirectProjectJavaRI/config-manager</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.2.RELEASE</version>
<version>2.1.6.RELEASE</version>
<relativePath />
</parent>
<scm>
Expand All @@ -38,7 +38,7 @@
</licenses>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-cloud-dependencies.version>Greenwich.RELEASE</spring-cloud-dependencies.version>
<spring-cloud-dependencies.version>Greenwich.SR1</spring-cloud-dependencies.version>
</properties>
<dependencyManagement>
<dependencies>
Expand All @@ -60,12 +60,12 @@
<dependency>
<groupId>org.nhind</groupId>
<artifactId>direct-common</artifactId>
<version>6.0</version>
<version>6.0.1</version>
</dependency>
<dependency>
<groupId>org.nhind</groupId>
<artifactId>agent</artifactId>
<version>6.0</version>
<version>6.0.2</version>
</dependency>
</dependencies>
<build>
Expand All @@ -88,7 +88,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.6.1</version>
<version>2.9.1</version>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
<charset>UTF-8</charset>
Expand All @@ -108,8 +108,7 @@
</goals>
</execution>
</executions>
</plugin>
<!-- for releases only
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
Expand All @@ -122,8 +121,7 @@
</goals>
</execution>
</executions>
</plugin>
-->
</plugin>
</plugins>
</build>
<reporting>
Expand All @@ -136,7 +134,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.6.1</version>
<version>2.9.1</version>
<configuration>
<additionalparam>-Xdoclint:none</additionalparam>
<charset>UTF-8</charset>
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/org/nhindirect/config/manager/DNSRecordCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
*/
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/org/nhindirect/config/manager/DNSRecordParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down Expand Up @@ -151,6 +157,7 @@ public void print(DNSRecord record)
case Type.NS:
print((NSRecord)toRecord(record));
break;

}

writer.flush();
Expand Down