@@ -31,6 +31,7 @@ STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3131import org .xbill .DNS .NSRecord ;
3232import org .xbill .DNS .Name ;
3333import org .xbill .DNS .SOARecord ;
34+ import org .xbill .DNS .SRVRecord ;
3435import org .xbill .DNS .TXTRecord ;
3536
3637/**
@@ -77,6 +78,14 @@ public class DNSRecordParser
7778 "\r \n \t alias: the text value of the record" +
7879 "\r \n \t ttl: time to live in seconds" ;
7980
81+ public static final String PARSE_SRV_USAGE = " name target port priority weight ttl" +
82+ "\r \n \t name: the name of the SRV entry" +
83+ "\r \n \t target: the server that hosts the service of the SRV entry" +
84+ "\r \n \t port: the IP port to use when conneting to the target" +
85+ "\r \n \t priority: the priority the record compared to other SRV records of the same name" +
86+ "\r \n \t weight: the weight the record compared to other SRV records of the same name and priority" +
87+ "\r \n \t ttl: time to live in seconds" ;
88+
8089 /**
8190 * Default empty constructor
8291 *
@@ -230,4 +239,23 @@ public NSRecord parseNS(String[] args)
230239
231240 return new NSRecord (nameFromString (domainName ), DClass .IN , ttl , nameFromString (target ));
232241 }
242+
243+ /**
244+ * Converts SRV record configuration information to an SRVRecord
245+ * @param args The NS record configuration parameters.
246+ * @return A DNS NSRecord.
247+ *
248+ * @since 6.0.1
249+ */
250+ public SRVRecord parseSRV (String [] args )
251+ {
252+ String name = StringArrayUtil .getRequiredValue (args , 0 );
253+ String target = StringArrayUtil .getRequiredValue (args , 1 );
254+ int port = Integer .parseInt (StringArrayUtil .getRequiredValue (args , 2 ));
255+ int priority = Integer .parseInt (StringArrayUtil .getRequiredValue (args , 3 ));
256+ int weight = Integer .parseInt (StringArrayUtil .getRequiredValue (args , 4 ));
257+ int ttl = Integer .parseInt (StringArrayUtil .getRequiredValue (args , 5 ));
258+
259+ return new SRVRecord (nameFromString (name ), DClass .IN , ttl , priority , weight , port , nameFromString (target ));
260+ }
233261}
0 commit comments