From: David ‘Bombe’ Roden Date: Wed, 9 Apr 2008 19:39:07 +0000 (+0000) Subject: add constructor that creates noderef from fcp message X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=0375aac1b9e994a88a82973ae0df7b8814251a7e;p=jSite2.git add constructor that creates noderef from fcp message git-svn-id: http://trooper/svn/projects/jSite/trunk@674 c3eda9e8-030b-0410-8277-bc7414b0a119 --- diff --git a/src/net/pterodactylus/util/fcp/NodeRef.java b/src/net/pterodactylus/util/fcp/NodeRef.java index 4eb80eb..cc8241f 100644 --- a/src/net/pterodactylus/util/fcp/NodeRef.java +++ b/src/net/pterodactylus/util/fcp/NodeRef.java @@ -52,6 +52,37 @@ public class NodeRef { private String signature; /** + * Creates a new, empty noderef. + */ + public NodeRef() { + } + + /** + * 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 @@ -155,7 +186,7 @@ public class NodeRef { * * @return The ARK of the node */ - public ARK getArk() { + public ARK getARK() { return ark; } @@ -165,7 +196,7 @@ public class NodeRef { * @param ark * The ARK of the node */ - public void setArk(ARK ark) { + public void setARK(ARK ark) { this.ark = ark; }