Added byte[] constructors

This commit is contained in:
nathan 2018-03-03 15:53:04 +01:00
parent 3587933022
commit db4fffc893
2 changed files with 29 additions and 1 deletions

View File

@ -78,7 +78,7 @@ class AAAARecord extends DnsRecord {
/**
* Creates an AAAA Record from the given data
*
* @param address The address suffix
* @param address The address that the name refers
*/
public
AAAARecord(Name name, int dclass, long ttl, InetAddress address) {
@ -89,6 +89,20 @@ class AAAARecord extends DnsRecord {
this.address = address.getAddress();
}
/**
* Creates an AAAA Record from the given data
*
* @param address The address that the name refers to as a byte array. This value is NOT COPIED.
*/
public
AAAARecord(Name name, int dclass, long ttl, byte[] address) {
super(name, DnsRecordType.AAAA, dclass, ttl);
if (address.length != Address.addressLength(Address.IPv6)) {
throw new IllegalArgumentException("invalid IPv6 address");
}
this.address = address;
}
/**
* Returns the address
*/

View File

@ -86,6 +86,20 @@ class ARecord extends DnsRecord {
addr = fromArray(address.getAddress());
}
/**
* Creates an A Record from the given data
*
* @param address The address that the name refers to as a byte array. This value is NOT COPIED.
*/
public
ARecord(Name name, int dclass, long ttl, byte[] address) {
super(name, DnsRecordType.A, dclass, ttl);
if (address.length != Address.addressLength(Address.IPv4)) {
throw new IllegalArgumentException("invalid IPv4 address");
}
addr = fromArray(address);
}
/**
* Returns the Internet address
*/