X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=inline;f=src%2Fnet%2Fpterodactylus%2Futil%2Ffcp%2FNodeRef.java;h=1546b7b5f102364a795ff617b658633693307305;hb=b9a83b75fbab2af9cb9e6217b7ea4414b59b8851;hp=4eb80ebc0dd0fe78b0fc742c6482d58cd33ec7fd;hpb=efceb56d8cedd9e18e599a2f2d1e21d64aacc002;p=jSite2.git
diff --git a/src/net/pterodactylus/util/fcp/NodeRef.java b/src/net/pterodactylus/util/fcp/NodeRef.java
index 4eb80eb..1546b7b 100644
--- a/src/net/pterodactylus/util/fcp/NodeRef.java
+++ b/src/net/pterodactylus/util/fcp/NodeRef.java
@@ -7,7 +7,7 @@ package net.pterodactylus.util.fcp;
* A reference for a node. The noderef contains all data that is necessary to
* establish a trusted and secure connection to the node.
*
- * @author David Roden
+ * @author David âBombeâ Roden <bombe@freenetproject.org>
* @version $Id$
*/
public class NodeRef {
@@ -52,6 +52,38 @@ public class NodeRef {
private String signature;
/**
+ * Creates a new, empty noderef.
+ */
+ public NodeRef() {
+ /* intentionally left blank. */
+ }
+
+ /**
+ * Creates a new noderef that is initialized with fields from the given
+ * message.
+ *
+ * @param fromMessage
+ * The message to get initial values for the noderef from
+ */
+ public NodeRef(FcpMessage fromMessage) {
+ identity = fromMessage.getField("identity");
+ opennet = Boolean.valueOf(fromMessage.getField("opennet"));
+ name = fromMessage.getField("myName");
+ if (fromMessage.hasField("location")) {
+ location = Double.valueOf(fromMessage.getField("location"));
+ }
+ physicalUDP = fromMessage.getField("physical.udp");
+ ark = new ARK(fromMessage.getField("ark.pubURI"), fromMessage.getField("ark.privURI"), fromMessage.getField("ark.number"));
+ dsaPublicKey = fromMessage.getField("dsaPubKey.y");
+ dsaGroup = new DSAGroup(fromMessage.getField("dsaGroup.b"), fromMessage.getField("dsaGroup.p"), fromMessage.getField("dsaGroup.q"));
+ negotiationTypes = FcpUtils.decodeMultiIntegerField(fromMessage.getField("auth.negTypes"));
+ version = new Version(fromMessage.getField("version"));
+ lastGoodVersion = new Version(fromMessage.getField("lastGoodVersion"));
+ testnet = Boolean.valueOf(fromMessage.getField("testnet"));
+ signature = fromMessage.getField("sig");
+ }
+
+ /**
* Returns the identity of the node.
*
* @return The identity of the node
@@ -98,7 +130,7 @@ public class NodeRef {
* @return The name of the node, or null
if the node is an
* opennet peer
*/
- public String getName() {
+ public String getMyName() {
return name;
}
@@ -155,7 +187,7 @@ public class NodeRef {
*
* @return The ARK of the node
*/
- public ARK getArk() {
+ public ARK getARK() {
return ark;
}
@@ -165,7 +197,7 @@ public class NodeRef {
* @param ark
* The ARK of the node
*/
- public void setArk(ARK ark) {
+ public void setARK(ARK ark) {
this.ark = ark;
}