2 * jFCPlib - NodeData.java - Copyright © 2008–2016 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.fcp;
21 * The “NodeData” contains the noderef of the node, along with additional data.
23 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
25 public class NodeData extends BaseMessage {
27 /** The noderef of the node. */
28 private final NodeRef nodeRef;
31 * Creates a new “NodeData” message that wraps the received message.
33 * @param receivedMessage
34 * The received message
36 public NodeData(FcpMessage receivedMessage) {
37 super(receivedMessage);
38 nodeRef = new NodeRef(receivedMessage);
42 * Returns the noderef of the node.
44 * @return The noderef of the node
46 public NodeRef getNodeRef() {
51 * Returns the last good version, i.e. the oldest version the node will
54 * @return The last good version
56 public Version getLastGoodVersion() {
57 return nodeRef.getLastGoodVersion();
61 * Returns the signature of the noderef.
63 * @return The signature of the noderef
65 public String getSignature() {
66 return nodeRef.getSignature();
70 * Returns whether the noderef is the opennet noderef of the node
72 * @return <code>true</code> if the noderef is the opennet noderef of the
73 * node, <code>false</code> otherwise
75 public boolean isOpennet() {
76 return nodeRef.isOpennet();
80 * Returns the identity of the node
82 * @return The identity of the node
84 public String getIdentity() {
85 return nodeRef.getIdentity();
89 * Returns the name of the node.
91 * @return The name of the node
93 public String getMyName() {
94 return nodeRef.getMyName();
98 * Returns the version of the node.
100 * @return The version of the node
102 public Version getVersion() {
103 return nodeRef.getVersion();
107 * Returns IP addresses and port number of the node.
109 * @return The IP addresses and port numbers of the node
111 public String getPhysicalUDP() {
112 return nodeRef.getPhysicalUDP();
116 * Returns the ARK of the node.
118 * @return The ARK of the node
120 public ARK getARK() {
121 return nodeRef.getARK();
125 * Returns the public key of the node.
127 * @return The public key of the node
129 public String getDSAPublicKey() {
130 return nodeRef.getDSAPublicKey();
134 * Returns the private key of the node.
136 * @return The private key of the node
138 public String getDSKPrivateKey() {
139 return getField("dsaPrivKey.x");
143 * Returns the DSA group of the node.
145 * @return The DSA group of the node
147 public DSAGroup getDSAGroup() {
148 return nodeRef.getDSAGroup();
152 * Returns the negotiation types supported by the node.
154 * @return The node’s supported negotiation types
156 public int[] getNegotiationTypes() {
157 return nodeRef.getNegotiationTypes();
161 * Returns one of the volatile fields from the message. The given field
162 * name is prepended with “volatile.” so if you want to get the value of
163 * the field with the name “volatile.freeJavaMemory” you only need to
164 * specify “freeJavaMemory”.
167 * The name of the field
168 * @return The value of the field, or <code>null</code> if there is no such
171 public String getVolatile(String field) {
172 return getField("volatile." + field);