diff options
Diffstat (limited to 'src/main/java/de/measite/minidns/record')
-rw-r--r-- | src/main/java/de/measite/minidns/record/A.java | 43 | ||||
-rw-r--r-- | src/main/java/de/measite/minidns/record/AAAA.java | 49 | ||||
-rw-r--r-- | src/main/java/de/measite/minidns/record/CNAME.java | 46 | ||||
-rw-r--r-- | src/main/java/de/measite/minidns/record/Data.java | 34 | ||||
-rw-r--r-- | src/main/java/de/measite/minidns/record/NS.java | 15 | ||||
-rw-r--r-- | src/main/java/de/measite/minidns/record/PTR.java | 19 | ||||
-rw-r--r-- | src/main/java/de/measite/minidns/record/SRV.java | 124 | ||||
-rw-r--r-- | src/main/java/de/measite/minidns/record/TXT.java | 65 |
8 files changed, 0 insertions, 395 deletions
diff --git a/src/main/java/de/measite/minidns/record/A.java b/src/main/java/de/measite/minidns/record/A.java deleted file mode 100644 index 4311c651..00000000 --- a/src/main/java/de/measite/minidns/record/A.java +++ /dev/null @@ -1,43 +0,0 @@ -package de.measite.minidns.record; - -import java.io.DataInputStream; -import java.io.IOException; - -import de.measite.minidns.Record.TYPE; - -/** - * A record payload (ip pointer). - */ -public class A implements Data { - - /** - * Target IP. - */ - private byte[] ip; - - @Override - public TYPE getType() { - return TYPE.A; - } - - @Override - public byte[] toByteArray() { - return ip; - } - - @Override - public void parse(DataInputStream dis, byte[] data, int length) - throws IOException { - ip = new byte[4]; - dis.readFully(ip); - } - - @Override - public String toString() { - return Integer.toString(ip[0] & 0xff) + "." + - Integer.toString(ip[1] & 0xff) + "." + - Integer.toString(ip[2] & 0xff) + "." + - Integer.toString(ip[3] & 0xff); - } - -} diff --git a/src/main/java/de/measite/minidns/record/AAAA.java b/src/main/java/de/measite/minidns/record/AAAA.java deleted file mode 100644 index e4fd5ecf..00000000 --- a/src/main/java/de/measite/minidns/record/AAAA.java +++ /dev/null @@ -1,49 +0,0 @@ -package de.measite.minidns.record; - -import java.io.DataInputStream; -import java.io.IOException; - -import de.measite.minidns.Record.TYPE; - -/** - * AAAA payload (an ipv6 pointer). - */ -public class AAAA implements Data { - - /** - * The ipv6 address. - */ - private byte[] ip; - - @Override - public TYPE getType() { - return TYPE.AAAA; - } - - @Override - public byte[] toByteArray() { - return ip; - } - - @Override - public void parse(DataInputStream dis, byte[] data, int length) - throws IOException { - ip = new byte[16]; - dis.readFully(ip); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < ip.length; i += 2) { - if (i != 0) { - sb.append(':'); - } - sb.append(Integer.toHexString( - ((ip[i] & 0xff) << 8) + (ip[i + 1] & 0xff) - )); - } - return sb.toString(); - } - -} diff --git a/src/main/java/de/measite/minidns/record/CNAME.java b/src/main/java/de/measite/minidns/record/CNAME.java deleted file mode 100644 index 1ac27814..00000000 --- a/src/main/java/de/measite/minidns/record/CNAME.java +++ /dev/null @@ -1,46 +0,0 @@ -package de.measite.minidns.record; - -import java.io.DataInputStream; -import java.io.IOException; - -import de.measite.minidns.Record.TYPE; -import de.measite.minidns.util.NameUtil; - -/** - * CNAME payload (pointer to another domain / address). - */ -public class CNAME implements Data { - - protected String name; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - @Override - public byte[] toByteArray() { - throw new UnsupportedOperationException("Not implemented yet"); - } - - @Override - public void parse(DataInputStream dis, byte[] data, int length) - throws IOException - { - this.name = NameUtil.parse(dis, data); - } - - @Override - public TYPE getType() { - return TYPE.CNAME; - } - - @Override - public String toString() { - return "to \"" + name + "\""; - } - -} diff --git a/src/main/java/de/measite/minidns/record/Data.java b/src/main/java/de/measite/minidns/record/Data.java deleted file mode 100644 index 7f2db03a..00000000 --- a/src/main/java/de/measite/minidns/record/Data.java +++ /dev/null @@ -1,34 +0,0 @@ -package de.measite.minidns.record; - -import java.io.DataInputStream; -import java.io.IOException; - -import de.measite.minidns.Record.TYPE; - -/** - * Generic payload class. - */ -public interface Data { - - /** - * The payload type. - * @return The payload type. - */ - TYPE getType(); - - /** - * Binary representation of this payload. - * @return The binary representation of this payload. - */ - byte[] toByteArray(); - - /** - * Parse this payload. - * @param dis The input stream. - * @param data The plain data (needed for name cross references). - * @param length The payload length. - * @throws IOException on io error (read past paket boundary). - */ - void parse(DataInputStream dis, byte data[], int length) throws IOException; - -} diff --git a/src/main/java/de/measite/minidns/record/NS.java b/src/main/java/de/measite/minidns/record/NS.java deleted file mode 100644 index 8ac2d4c3..00000000 --- a/src/main/java/de/measite/minidns/record/NS.java +++ /dev/null @@ -1,15 +0,0 @@ -package de.measite.minidns.record; - -import de.measite.minidns.Record.TYPE; - -/** - * Nameserver record. - */ -public class NS extends CNAME { - - @Override - public TYPE getType() { - return TYPE.NS; - } - -} diff --git a/src/main/java/de/measite/minidns/record/PTR.java b/src/main/java/de/measite/minidns/record/PTR.java deleted file mode 100644 index 6e200655..00000000 --- a/src/main/java/de/measite/minidns/record/PTR.java +++ /dev/null @@ -1,19 +0,0 @@ -package de.measite.minidns.record; - -import java.io.DataInputStream; -import java.io.IOException; - -import de.measite.minidns.Record.TYPE; -import de.measite.minidns.util.NameUtil; - -/** - * A PTR record is handled like a CNAME - */ -public class PTR extends CNAME { - - @Override - public TYPE getType() { - return TYPE.PTR; - } - -} diff --git a/src/main/java/de/measite/minidns/record/SRV.java b/src/main/java/de/measite/minidns/record/SRV.java deleted file mode 100644 index 707bf3f5..00000000 --- a/src/main/java/de/measite/minidns/record/SRV.java +++ /dev/null @@ -1,124 +0,0 @@ -package de.measite.minidns.record; - -import java.io.DataInputStream; -import java.io.IOException; - -import de.measite.minidns.Record.TYPE; -import de.measite.minidns.util.NameUtil; - -/** - * SRV record payload (service pointer). - */ -public class SRV implements Data { - - /** - * The priority of this service. - */ - protected int priority; - - /** - * The weight of this service. - */ - protected int weight; - - /** - * The target port. - */ - protected int port; - - /** - * The target server. - */ - protected String name; - - /** - * The priority of this service. Lower values mean higher priority. - * @return The priority. - */ - public int getPriority() { - return priority; - } - - /** - * Set the priority of this service entry. Lower values have higher priority. - * @param priority The new priority. - */ - public void setPriority(int priority) { - this.priority = priority; - } - - /** - * The weight of this service. Services with the same priority should be - * balanced based on weight. - * @return The weight of this service. - */ - public int getWeight() { - return weight; - } - - /** - * Set the weight of this service. - * @param weight The new weight of this service. - */ - public void setWeight(int weight) { - this.weight = weight; - } - - /** - * The target port of this service. - * @return The target port of this service. - */ - public int getPort() { - return port; - } - - /** - * Set the target port of this service. - * @param port The new target port. - */ - public void setPort(int port) { - this.port = port; - } - - /** - * The name of the target server. - * @return The target servers name. - */ - public String getName() { - return name; - } - - /** - * Set the name of the target server. - * @param name The new target servers name. - */ - public void setName(String name) { - this.name = name; - } - - @Override - public byte[] toByteArray() { - throw new UnsupportedOperationException("Not implemented yet"); - } - - @Override - public void parse(DataInputStream dis, byte[] data, int length) - throws IOException - { - this.priority = dis.readUnsignedShort(); - this.weight = dis.readUnsignedShort(); - this.port = dis.readUnsignedShort(); - this.name = NameUtil.parse(dis, data); - } - - @Override - public String toString() { - return "SRV " + name + ":" + port + " p:" + priority + " w:" + weight; - } - - @Override - public TYPE getType() { - return TYPE.SRV; - } - -} diff --git a/src/main/java/de/measite/minidns/record/TXT.java b/src/main/java/de/measite/minidns/record/TXT.java deleted file mode 100644 index 03e73040..00000000 --- a/src/main/java/de/measite/minidns/record/TXT.java +++ /dev/null @@ -1,65 +0,0 @@ -package de.measite.minidns.record; - -import java.io.DataInputStream; -import java.io.IOException; - -import de.measite.minidns.Record.TYPE; -import de.measite.minidns.util.NameUtil; - -/** - * TXT record (actually a binary blob with wrappers for text content). - */ -public class TXT implements Data { - - protected byte[] blob; - - public byte[] getBlob() { - return blob; - } - - public void setBlob(byte[] blob) { - this.blob = blob; - } - - public String getText() { - try { - return (new String(blob, "UTF-8")).intern(); - } catch (Exception e) { - /* Can't happen for UTF-8 unless it's really a blob */ - return null; - } - } - - public void setText(String text) { - try { - this.blob = text.getBytes("UTF-8"); - } catch (Exception e) { - /* Can't happen, UTF-8 IS supported */ - throw new RuntimeException("UTF-8 not supported", e); - } - } - - @Override - public byte[] toByteArray() { - throw new UnsupportedOperationException("Not implemented yet"); - } - - @Override - public void parse(DataInputStream dis, byte[] data, int length) - throws IOException - { - blob = new byte[length]; - dis.readFully(blob); - } - - @Override - public TYPE getType() { - return TYPE.TXT; - } - - @Override - public String toString() { - return "\"" + getText() + "\""; - } - -} |