--- /dev/null
+package net.pterodactylus.util.fcp;
+
+/**
+ * Container for ARKs (address resolution keys).
+ *
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class ARK {
+
+ /** The public URI of the ARK. */
+ private final String publicURI;
+
+ /** The number of the ARK. */
+ private final int number;
+
+ /**
+ * Creates a new ARK with the given URI and number.
+ *
+ * @param publicURI
+ * The public URI of the ARK
+ * @param number
+ * The number of the ARK
+ */
+ public ARK(String publicURI, String number) {
+ if ((publicURI == null) || (number == null)) {
+ throw new NullPointerException(((publicURI == null) ? "publicURI" : "number") + " must not be null");
+ }
+ this.publicURI = publicURI;
+ try {
+ this.number = Integer.valueOf(number);
+ } catch (NumberFormatException nfe1) {
+ throw new IllegalArgumentException("number must be numeric", nfe1);
+ }
+ }
+
+ /**
+ * Returns the public URI of the ARK.
+ *
+ * @return The public URI of the ARK
+ */
+ public String getPublicURI() {
+ return publicURI;
+ }
+
+ /**
+ * Returns the number of the ARK.
+ *
+ * @return The number of the ARK
+ */
+ public int getNumber() {
+ return number;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * © 2008 INA Service GmbH
+ */
+package net.pterodactylus.util.fcp;
+
+
+/**
+ * A basic message abstraction that wraps a received FCP message.
+ *
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class BaseMessage {
+
+ /** The received message, wrapped here. */
+ private final FcpMessage receivedMessage;
+
+ /**
+ * Creates a new base message that wraps the given message.
+ *
+ * @param receivedMessage
+ * The FCP message that was received
+ */
+ public BaseMessage(FcpMessage receivedMessage) {
+ this.receivedMessage = receivedMessage;
+ }
+
+ /**
+ * Returns the name of the message.
+ *
+ * @return The name of the message
+ */
+ public String getName() {
+ return receivedMessage.getName();
+ }
+
+ /**
+ * Returns the content of the field.
+ *
+ * @param field
+ * The name of the field
+ * @return The content of the field, or <code>null</code> if there is no
+ * such field
+ */
+ public String getField(String field) {
+ return receivedMessage.getField(field);
+ }
+
+}
--- /dev/null
+/**
+ * © 2008 INA Service GmbH
+ */
+package net.pterodactylus.util.fcp;
+
+
+/**
+ * A “ClientHello” message that <i>must</i> be sent to the node first thing
+ * after calling {@link FcpConnection#connect()}.
+ *
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class ClientHello extends FcpMessage {
+
+ /**
+ * Creates a new “ClientHello” message with the given client name. The
+ * client name has to be unique to the node otherwise you will get a
+ * {@link CloseConnectionDuplicateClientName} response from the node!
+ *
+ * @param clientName
+ * The unique client name
+ */
+ public ClientHello(String clientName) {
+ this(clientName, "2.0");
+ }
+
+ /**
+ * Creates a new “ClientHello” message with the given client name. The
+ * client name has to be unique to the node otherwise you will get a
+ * {@link CloseConnectionDuplicateClientName} response from the node!
+ *
+ * The expected FCP version is currently ignored by the node.
+ *
+ * @param clientName
+ * The unique client name
+ * @param expectedVersion
+ * The FCP version that the node is expected to talk
+ */
+ public ClientHello(String clientName, String expectedVersion) {
+ super("ClientHello");
+ setField("Name", clientName);
+ setField("ExpectedVersion", expectedVersion);
+ }
+
+}
--- /dev/null
+/**
+ * © 2008 INA Service GmbH
+ */
+package net.pterodactylus.util.fcp;
+
+
+/**
+ * A “CloseConnectionDuplicateClientName” message.
+ *
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class CloseConnectionDuplicateClientName extends BaseMessage {
+
+ /**
+ * Creates a new CloseConnectionDuplicateClientName message that wraps the
+ * given message.
+ *
+ * @param receivedMessage
+ * The received message
+ */
+ public CloseConnectionDuplicateClientName(FcpMessage receivedMessage) {
+ super(receivedMessage);
+ }
+
+}
--- /dev/null
+package net.pterodactylus.util.fcp;
+
+import java.security.interfaces.DSAParams;
+
+/**
+ * Container for the DSA group of a peer. A DSA group consists of a base
+ * (called “g”), a prime (called “p”) and a subprime (called “q”).
+ *
+ * @see DSAParams
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class DSAGroup {
+
+ /** The base of the DSA group. */
+ private final String base;
+
+ /** The prime of the DSA group. */
+ private final String prime;
+
+ /** The subprime of the DSA group. */
+ private final String subprime;
+
+ /**
+ * Creates a new DSA group with the given base (“g”), prime (“p”), and
+ * subprime (“q”).
+ *
+ * @param base
+ * The base of the DSA group
+ * @param prime
+ * The prime of the DSA group
+ * @param subprime
+ * The subprime of the DSA group
+ */
+ public DSAGroup(String base, String prime, String subprime) {
+ this.base = base;
+ this.prime = prime;
+ this.subprime = subprime;
+ }
+
+ /**
+ * Returns the base (“g”) of the DSA group.
+ *
+ * @return The base of the DSA group
+ */
+ public String getBase() {
+ return base;
+ }
+
+ /**
+ * Returns the prime (“p”) of the DSA group.
+ *
+ * @return The prime of the DSA group
+ */
+ public String getPrime() {
+ return prime;
+ }
+
+ /**
+ * Returns the subprime (“q”) of the DSA group.
+ *
+ * @return The subprime of the DSA group
+ */
+ public String getSubprime() {
+ return subprime;
+ }
+
+}
\ No newline at end of file
--- /dev/null
+/**
+ * © 2008 INA Service GmbH
+ */
+package net.pterodactylus.util.fcp;
+
+
+/**
+ * The “EndListPeerNotes” message signals the end of a list of “PeerNote”
+ * messages.
+ *
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class EndListPeerNotes extends BaseMessage {
+
+ /**
+ * Creates a new “EndListPeerNotes” message that wraps the received message.
+ *
+ * @param fcpMessage
+ * The received message
+ */
+ public EndListPeerNotes(FcpMessage fcpMessage) {
+ super(fcpMessage);
+ }
+
+}
--- /dev/null
+/**
+ * © 2008 INA Service GmbH
+ */
+package net.pterodactylus.util.fcp;
+
+
+/**
+ * This message marks the end of a list of “Peer” replies.
+ *
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class EndListPeers extends BaseMessage {
+
+ /**
+ * Creates a new “EndListPeers” message that wraps the received message.
+ *
+ * @param receivedMessage
+ * The message that was received
+ */
+ public EndListPeers(FcpMessage receivedMessage) {
+ super(receivedMessage);
+ }
+
+}
*/
package net.pterodactylus.util.fcp;
-import net.pterodactylus.util.fcp.message.CloseConnectionDuplicateClientName;
-import net.pterodactylus.util.fcp.message.EndListPeerNotes;
-import net.pterodactylus.util.fcp.message.EndListPeers;
-import net.pterodactylus.util.fcp.message.NodeHello;
-import net.pterodactylus.util.fcp.message.Peer;
-import net.pterodactylus.util.fcp.message.PeerNote;
-import net.pterodactylus.util.fcp.message.SSKKeypair;
/**
* Adapter for {@link FcpListener}.
/**
* @see net.pterodactylus.util.fcp.FcpListener#receivedNodeHello(net.pterodactylus.util.fcp.FcpConnection,
- * net.pterodactylus.util.fcp.message.NodeHello)
+ * net.pterodactylus.util.fcp.NodeHello)
*/
public void receivedNodeHello(FcpConnection fcpConnection, NodeHello nodeHello) {
/* empty. */
/**
* @see net.pterodactylus.util.fcp.FcpListener#receivedCloseConnectionDuplicateClientName(net.pterodactylus.util.fcp.FcpConnection,
- * net.pterodactylus.util.fcp.message.CloseConnectionDuplicateClientName)
+ * net.pterodactylus.util.fcp.CloseConnectionDuplicateClientName)
*/
public void receivedCloseConnectionDuplicateClientName(FcpConnection fcpConnection, CloseConnectionDuplicateClientName closeConnectionDuplicateClientName) {
/* empty. */
/**
* @see net.pterodactylus.util.fcp.FcpListener#receivedSSKKeypair(net.pterodactylus.util.fcp.FcpConnection,
- * net.pterodactylus.util.fcp.message.SSKKeypair)
+ * net.pterodactylus.util.fcp.SSKKeypair)
*/
public void receivedSSKKeypair(FcpConnection fcpConnection, SSKKeypair sskKeypair) {
/* empty. */
/**
* @see net.pterodactylus.util.fcp.FcpListener#receivedPeer(net.pterodactylus.util.fcp.FcpConnection,
- * net.pterodactylus.util.fcp.message.Peer)
+ * net.pterodactylus.util.fcp.Peer)
*/
public void receivedPeer(FcpConnection fcpConnection, Peer peer) {
/* empty. */
/**
* @see net.pterodactylus.util.fcp.FcpListener#receivedEndListPeers(net.pterodactylus.util.fcp.FcpConnection,
- * net.pterodactylus.util.fcp.message.EndListPeers)
+ * net.pterodactylus.util.fcp.EndListPeers)
*/
public void receivedEndListPeers(FcpConnection fcpConnection, EndListPeers endListPeers) {
/* empty. */
/**
* @see net.pterodactylus.util.fcp.FcpListener#receviedPeerNote(net.pterodactylus.util.fcp.FcpConnection,
- * net.pterodactylus.util.fcp.message.PeerNote)
+ * net.pterodactylus.util.fcp.PeerNote)
*/
public void receviedPeerNote(FcpConnection fcpConnection, PeerNote peerNote) {
/* empty. */
/**
* @see net.pterodactylus.util.fcp.FcpListener#receivedEndListPeerNotes(net.pterodactylus.util.fcp.FcpConnection,
- * net.pterodactylus.util.fcp.message.EndListPeerNotes)
+ * net.pterodactylus.util.fcp.EndListPeerNotes)
*/
public void receivedEndListPeerNotes(FcpConnection fcpConnection, EndListPeerNotes endListPeerNotes) {
/* empty. */
import java.util.ArrayList;
import java.util.List;
-import net.pterodactylus.util.fcp.message.CloseConnectionDuplicateClientName;
-import net.pterodactylus.util.fcp.message.EndListPeerNotes;
-import net.pterodactylus.util.fcp.message.EndListPeers;
-import net.pterodactylus.util.fcp.message.NodeHello;
-import net.pterodactylus.util.fcp.message.Peer;
-import net.pterodactylus.util.fcp.message.PeerNote;
-import net.pterodactylus.util.fcp.message.SSKKeypair;
import net.pterodactylus.util.io.Closer;
/**
import java.util.EventListener;
-import net.pterodactylus.util.fcp.message.CloseConnectionDuplicateClientName;
-import net.pterodactylus.util.fcp.message.EndListPeerNotes;
-import net.pterodactylus.util.fcp.message.EndListPeers;
-import net.pterodactylus.util.fcp.message.NodeHello;
-import net.pterodactylus.util.fcp.message.Peer;
-import net.pterodactylus.util.fcp.message.PeerNote;
-import net.pterodactylus.util.fcp.message.SSKKeypair;
/**
* Interface for objects that want to be notified on certain FCP events.
import java.io.IOException;
import junit.framework.TestCase;
-import net.pterodactylus.util.fcp.message.ClientHello;
-import net.pterodactylus.util.fcp.message.CloseConnectionDuplicateClientName;
-import net.pterodactylus.util.fcp.message.GenerateSSK;
-import net.pterodactylus.util.fcp.message.NodeHello;
/**
* Tests various commands and the FCP connection.
FcpAdapter fcpAdapter = new FcpAdapter() {
/**
* @see net.pterodactylus.util.fcp.FcpAdapter#receivedNodeHello(net.pterodactylus.util.fcp.FcpConnection,
- * net.pterodactylus.util.fcp.message.NodeHello)
+ * net.pterodactylus.util.fcp.NodeHello)
*/
@Override
public void receivedNodeHello(FcpConnection fcpConnection, NodeHello nodeHello) {
/**
* @see net.pterodactylus.util.fcp.FcpAdapter#receivedCloseConnectionDuplicateClientName(net.pterodactylus.util.fcp.FcpConnection,
- * net.pterodactylus.util.fcp.message.CloseConnectionDuplicateClientName)
+ * net.pterodactylus.util.fcp.CloseConnectionDuplicateClientName)
*/
@Override
public void receivedCloseConnectionDuplicateClientName(FcpConnection fcpConnection, CloseConnectionDuplicateClientName closeConnectionDuplicateClientName) {
--- /dev/null
+/**
+ * © 2008 INA Service GmbH
+ */
+package net.pterodactylus.util.fcp;
+
+
+/**
+ * A “GenerateSSK” message. This message tells the node to generate a new SSK
+ * key pair.
+ *
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class GenerateSSK extends FcpMessage {
+
+ /**
+ * Creates a new “GenerateSSK” message.
+ */
+ public GenerateSSK() {
+ this(FcpUtils.getUniqueIdentifier());
+ }
+
+ /**
+ * Creates a new “GenerateSSK” message with the given client identifier.
+ *
+ * @param clientIdentifier
+ * The client identifier
+ */
+ public GenerateSSK(String clientIdentifier) {
+ super("GenerateSSK");
+ setField("Identifier", clientIdentifier);
+ }
+
+}
--- /dev/null
+/**
+ * © 2008 INA Service GmbH
+ */
+package net.pterodactylus.util.fcp;
+
+
+/**
+ * The “ListPeer” request asks the node about the details of a given peer.
+ *
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class ListPeer extends FcpMessage {
+
+ /**
+ * Creates a new “ListPeer” request that returns information about the node
+ * specified by <code>nodeIdentifier</code>. <code>nodeIdentifier</code>
+ * can be of several formats: The node’s name, its identity, or its IP
+ * address and port (connection with a ‘:’).
+ *
+ * @param nodeIdentifier
+ * The identifier of the node to get details about
+ */
+ public ListPeer(String nodeIdentifier) {
+ super("ListPeer");
+ setField("NodeIdentifier", nodeIdentifier);
+ }
+
+}
--- /dev/null
+/**
+ * © 2008 INA Service GmbH
+ */
+package net.pterodactylus.util.fcp;
+
+
+/**
+ * A “ListPeerNodes” request tells the node to list all notes that have been
+ * entered for a node. Note that notes are only supported for darknet nodes.
+ *
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class ListPeerNotes extends FcpMessage {
+
+ /**
+ * Creates a new “ListPeerNotes” request that lists all notes of the
+ * specified node.
+ *
+ * @param nodeIdentifier
+ * The identifier of the node
+ */
+ public ListPeerNotes(String nodeIdentifier) {
+ super("ListPeerNotes");
+ setField("NodeIdentifier", nodeIdentifier);
+ }
+
+}
--- /dev/null
+/**
+ * © 2008 INA Service GmbH
+ */
+package net.pterodactylus.util.fcp;
+
+
+/**
+ * The “ListPeer” requests asks the node for a list of all peers it has.
+ *
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class ListPeers extends FcpMessage {
+
+ /**
+ * Creates a new “ListPeers” request that only includes basic data of the
+ * peers.
+ */
+ public ListPeers() {
+ this(false, false);
+ }
+
+ /**
+ * Creates a new “ListPeers” request that includes wanted data of the peers.
+ *
+ * @param withMetadata
+ * If <code>true</code> metadata of the peers is included in
+ * the reply
+ * @param withVolatile
+ * if <code>true</code> volatile data of the peers is included
+ * in the reply
+ */
+ public ListPeers(boolean withMetadata, boolean withVolatile) {
+ super("ListPeers");
+ setField("WithMetadata", String.valueOf(withMetadata));
+ setField("WithVolatile", String.valueOf(withVolatile));
+ }
+
+}
--- /dev/null
+/**
+ * © 2008 INA Service GmbH
+ */
+package net.pterodactylus.util.fcp;
+
+
+/**
+ * Some convenience methods for parsing a “NodeHello” message from the node.
+ *
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class NodeHello extends BaseMessage {
+
+ /**
+ * Createa a new “NodeHello” message that wraps the received message.
+ *
+ * @param receivedMessage
+ * The received FCP message
+ */
+ public NodeHello(FcpMessage receivedMessage) {
+ super(receivedMessage);
+ }
+
+ /**
+ * Returns the build of the node. This may not be a number but also a string
+ * like “@custom@” in case you built the node yourself.
+ *
+ * @return The build of the node
+ */
+ public String getBuild() {
+ return getField("Build");
+ }
+
+ /**
+ * Returns the build number of the node. This may not be a number but also a
+ * string like “@custom@” in case you built the node yourself.
+ *
+ * @return The build number of the node, or <code>-1</code> if the build
+ * number could not be determined
+ */
+ public int getBuildNumber() {
+ String build = getBuild();
+ try {
+ return Integer.valueOf(build);
+ } catch (NumberFormatException nfe1) {
+ /* ignore. */
+ }
+ return -1;
+ }
+
+ /**
+ * Returns the number of compression codecs.
+ *
+ * @return The number of compression codecs
+ */
+ public String getCompressionCodecs() {
+ return getField("CompressionCodecs");
+ }
+
+ /**
+ * Returns the number of compression codecs.
+ *
+ * @return The number of compression codecs, or <code>-1</code> if the
+ * number of compression codecs could not be determined
+ */
+ public int getCompressionCodecsNumber() {
+ String compressionCodecs = getCompressionCodecs();
+ try {
+ return Integer.valueOf(compressionCodecs);
+ } catch (NumberFormatException nfe1) {
+ /* ignore. */
+ }
+ return -1;
+ }
+
+ /**
+ * Returns the unique connection identifier.
+ *
+ * @return The connection identifier
+ */
+ public String getConnectionIdentifier() {
+ return getField("ConnectionIdentifier");
+ }
+
+ /**
+ * Returns the build of the external library file.
+ *
+ * @return The build of the external library file
+ */
+ public String getExtBuild() {
+ return getField("ExtBuild");
+ }
+
+ /**
+ * Returns the build number of the external library file.
+ *
+ * @return The build number of the external library file, or <code>-1</code>
+ * if the build number could not be determined
+ */
+ public int getExtBuildNumber() {
+ String extBuild = getExtBuild();
+ try {
+ return Integer.valueOf(extBuild);
+ } catch (NumberFormatException nfe1) {
+ /* ignore. */
+ }
+ return -1;
+ }
+
+ /**
+ * Returns the revision of the external library file.
+ *
+ * @return The revision of the external library file
+ */
+ public String getExtRevision() {
+ return getField("ExtRevision");
+ }
+
+ /**
+ * Returns the revision number of the external library file.
+ *
+ * @return The revision number of the external library file, or
+ * <code>-1</code> if the revision number could not be determined
+ */
+ public int getExtRevisionNumber() {
+ String extRevision = getExtRevision();
+ try {
+ return Integer.valueOf(extRevision);
+ } catch (NumberFormatException nfe1) {
+ /* ignore. */
+ }
+ return -1;
+ }
+
+ /**
+ * Returns the FCP version the node speaks.
+ *
+ * @return The FCP version the node speaks
+ */
+ public String getFCPVersion() {
+ return getField("FCPVersion");
+ }
+
+ /**
+ * Returns the make of the node, e.g. “Fred” (freenet reference
+ * implementation).
+ *
+ * @return The make of the node
+ */
+ public String getNode() {
+ return getField("Node");
+ }
+
+ /**
+ * Returns the language of the node as 2-letter code, e.g. “en” or “de”.
+ *
+ * @return The language of the node
+ */
+ public String getNodeLanguage() {
+ return getField("NodeLanguage");
+ }
+
+ /**
+ * Returns the revision of the node.
+ *
+ * @return The revision of the node
+ */
+ public String getRevision() {
+ return getField("Revision");
+ }
+
+ /**
+ * Returns the revision number of the node.
+ *
+ * @return The revision number of the node, or <code>-1</code> if the
+ * revision number coult not be determined
+ */
+ public int getRevisionNumber() {
+ String revision = getRevision();
+ try {
+ return Integer.valueOf(revision);
+ } catch (NumberFormatException nfe1) {
+ /* ignore. */
+ }
+ return -1;
+ }
+
+ /**
+ * Returns whether the node is currently is testnet mode.
+ *
+ * @return <code>true</code> if the node is currently in testnet mode,
+ * <code>false</code> otherwise
+ */
+ public boolean getTestnet() {
+ return Boolean.valueOf(getField("Testnet"));
+ }
+
+ /**
+ * Returns the version of the node.
+ *
+ * @return The version of the node
+ */
+ public String getVersion() {
+ return getField("Version");
+ }
+
+}
--- /dev/null
+/**
+ * © 2008 INA Service GmbH
+ */
+package net.pterodactylus.util.fcp;
+
+
+
+/**
+ * The “Peer” reply by the node contains information about a peer.
+ *
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class Peer extends BaseMessage {
+
+ /**
+ * Creates a new “Peer” reply from the received message.
+ *
+ * @param receivedMessage
+ * The received message
+ */
+ public Peer(FcpMessage receivedMessage) {
+ super(receivedMessage);
+ }
+
+ /**
+ * Returns the “physical.udp” line from the message. It contains all IP
+ * addresses and port numbers of the peer.
+ *
+ * @return The IP addresses and port numbers of the peer
+ */
+ public String getPhysicalUDP() {
+ return getField("physical.udp");
+ }
+
+ /**
+ * Returns whether the listed peer is an opennet peer.
+ *
+ * @return <code>true</code> if the peer is an opennet peer,
+ * <code>false</code> if the peer is a darknet peer
+ */
+ public boolean isOpennet() {
+ return Boolean.valueOf(getField("opennet"));
+ }
+
+ /**
+ * Returns the “y” part of the peer’s public DSA key.
+ *
+ * @return The public DSA key
+ */
+ public String getDSAPublicKey() {
+ return getField("dsaPubKey.y");
+ }
+
+ /**
+ * Returns the DSA group of the peer.
+ *
+ * @return The DSA group of the peer
+ */
+ public DSAGroup getDSAGroup() {
+ return new DSAGroup(getField("dsaGroup.g"), getField("dsaGroup.p"), getField("dsaGroup.q"));
+ }
+
+ /**
+ * Returns the last good version of the peer, i.e. the oldest version the
+ * peer will connect to.
+ *
+ * @return The last good version of the peer
+ */
+ public Version getLastGoodVersion() {
+ return new Version(getField("lastGoodVersion"));
+ }
+
+ /**
+ * Returns the ARK of the peer.
+ *
+ * @return The ARK of the peer
+ */
+ public ARK getARK() {
+ return new ARK(getField("ark.pubURI"), getField("ark.number"));
+ }
+
+ /**
+ * Returns the identity of the peer.
+ *
+ * @return The identity of the peer
+ */
+ public String getIdentity() {
+ return getField("identity");
+ }
+
+ /**
+ * Returns the name of the peer. If the peer is not a darknet peer it will
+ * have no name.
+ *
+ * @return The name of the peer, or <code>null</code> if the peer is an
+ * opennet peer
+ */
+ public String getMyName() {
+ return getField("myName");
+ }
+
+ /**
+ * Returns the location of the peer.
+ *
+ * @return The location of the peer
+ * @throws NumberFormatException
+ * if the field can not be parsed
+ */
+ public double getLocation() throws NumberFormatException {
+ return Double.valueOf(getField("location"));
+ }
+
+ /**
+ * Returns whether the peer is a testnet node.
+ *
+ * @return <code>true</code> if the peer is a testnet node,
+ * <code>false</code> otherwise
+ */
+ public boolean isTestnet() {
+ return Boolean.valueOf("testnet");
+ }
+
+ /**
+ * Returns the version of the peer.
+ *
+ * @return The version of the peer
+ */
+ public Version getVersion() {
+ return new Version(getField("version"));
+ }
+
+ /**
+ * Returns the negotiation types the peer supports.
+ *
+ * @return The supported negotiation types
+ */
+ public int[] getNegotiationTypes() {
+ return FcpUtils.parseMultiIntegerField(getField("auth.negTypes"));
+ }
+
+}
--- /dev/null
+/**
+ * © 2008 INA Service GmbH
+ */
+package net.pterodactylus.util.fcp;
+
+
+/**
+ * The “PeerNote” message contains a private note that has been entered for a
+ * darknet peer.
+ *
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class PeerNote extends BaseMessage {
+
+ /** The type for base64 encoded peer notes. */
+ public static final int NOTE_TYPE_BASE64 = 1;
+
+ /**
+ * Creates a “PeerNote” message that wraps the recevied message.
+ *
+ * @param receivedMessage
+ * The received message
+ */
+ public PeerNote(FcpMessage receivedMessage) {
+ super(receivedMessage);
+ }
+
+ /**
+ * Returns the note text in whatever format is specified by
+ * {@link #getPeerNoteType()}.
+ *
+ * @return The note text
+ */
+ public String getNoteText() {
+ return getField("NoteText");
+ }
+
+ /**
+ * Returns the type of the peer note. The type <code>1</code> means that
+ * the text of the note is base64-encoded.
+ *
+ * @return The type of the peer note
+ * @throws NumberFormatException
+ * if the field can not be parsed
+ */
+ public int getPeerNoteType() throws NumberFormatException {
+ return Integer.valueOf(getField("PeerNoteType"));
+ }
+
+}
--- /dev/null
+/**
+ * © 2008 INA Service GmbH
+ */
+package net.pterodactylus.util.fcp;
+
+
+/**
+ * An “SSKKeypair” message that is sent as a response to a {@link GenerateSSK}
+ * message.
+ *
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class SSKKeypair extends BaseMessage {
+
+ /**
+ * Creates a new “SSKKeypair” message that wraps the received message.
+ *
+ * @param receivedMessage
+ * The received message
+ */
+ public SSKKeypair(FcpMessage receivedMessage) {
+ super(receivedMessage);
+ }
+
+ /**
+ * Returns the identifier of the request.
+ *
+ * @return The identifier of the request
+ */
+ public String getIdentifier() {
+ return getField("Identifier");
+ }
+
+ /**
+ * Returns the URI that must be used to insert data.
+ *
+ * @return The insert URI
+ */
+ public String getInsertURI() {
+ return getField("InsertURI");
+ }
+
+ /**
+ * Returns the URI that must be used to request data.
+ *
+ * @return The request URI
+ */
+ public String getRequestURI() {
+ return getField("RequestURI");
+ }
+
+}
--- /dev/null
+package net.pterodactylus.util.fcp;
+
+import java.util.StringTokenizer;
+
+/**
+ * Container for the “lastGoodVersion” field.
+ *
+ * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
+ * @version $Id$
+ */
+public class Version {
+
+ /** The name of the node implementation. */
+ private final String nodeName;
+
+ /** The tree version of the node. */
+ private final String treeVersion;
+
+ /** The protocol version of the node. */
+ private final String protocolVersion;
+
+ /** The build number of the node. */
+ private final int buildNumber;
+
+ /**
+ * Creates a new Version from the given string. The string consists of
+ * the four required fields node name, tree version, protocol version,
+ * and build number, separated by a comma.
+ *
+ * @param version
+ * The version string
+ * @throws NullPointerException
+ * if <code>version</code> is <code>null</code>
+ * @throws IllegalArgumentException
+ * if <code>version</code> is not in the right format
+ */
+ public Version(String version) {
+ if (version == null) {
+ throw new NullPointerException("version must not be null");
+ }
+ StringTokenizer versionTokens = new StringTokenizer(version, ",");
+ if (versionTokens.countTokens() != 4) {
+ throw new IllegalArgumentException("version must consist of four fields");
+ }
+ this.nodeName = versionTokens.nextToken();
+ this.treeVersion = versionTokens.nextToken();
+ this.protocolVersion = versionTokens.nextToken();
+ try {
+ this.buildNumber = Integer.valueOf(versionTokens.nextToken());
+ } catch (NumberFormatException nfe1) {
+ throw new IllegalArgumentException("last part of version must be numeric", nfe1);
+ }
+ }
+
+ /**
+ * Creates a new Version from the given parts.
+ *
+ * @param nodeName
+ * The name of the node implementation
+ * @param treeVersion
+ * The tree version
+ * @param protocolVersion
+ * The protocol version
+ * @param buildNumber
+ * The build number of the node
+ */
+ public Version(String nodeName, String treeVersion, String protocolVersion, int buildNumber) {
+ this.nodeName = nodeName;
+ this.treeVersion = treeVersion;
+ this.protocolVersion = protocolVersion;
+ this.buildNumber = buildNumber;
+ }
+
+ /**
+ * Returns the name of the node implementation.
+ *
+ * @return The node name
+ */
+ public String getNodeName() {
+ return nodeName;
+ }
+
+ /**
+ * The tree version of the node.
+ *
+ * @return The tree version of the node
+ */
+ public String getTreeVersion() {
+ return treeVersion;
+ }
+
+ /**
+ * The protocol version of the node
+ *
+ * @return The protocol version of the node
+ */
+ public String getProtocolVersion() {
+ return protocolVersion;
+ }
+
+ /**
+ * The build number of the node.
+ *
+ * @return The build number of the node
+ */
+ public int getBuildNumber() {
+ return buildNumber;
+ }
+
+}
\ No newline at end of file
+++ /dev/null
-/**
- * © 2008 INA Service GmbH
- */
-package net.pterodactylus.util.fcp.message;
-
-import net.pterodactylus.util.fcp.FcpMessage;
-
-/**
- * A basic message abstraction that wraps a received FCP message.
- *
- * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
- * @version $Id$
- */
-public class BaseMessage {
-
- /** The received message, wrapped here. */
- private final FcpMessage receivedMessage;
-
- /**
- * Creates a new base message that wraps the given message.
- *
- * @param receivedMessage
- * The FCP message that was received
- */
- public BaseMessage(FcpMessage receivedMessage) {
- this.receivedMessage = receivedMessage;
- }
-
- /**
- * Returns the name of the message.
- *
- * @return The name of the message
- */
- public String getName() {
- return receivedMessage.getName();
- }
-
- /**
- * Returns the content of the field.
- *
- * @param field
- * The name of the field
- * @return The content of the field, or <code>null</code> if there is no
- * such field
- */
- public String getField(String field) {
- return receivedMessage.getField(field);
- }
-
-}
+++ /dev/null
-/**
- * © 2008 INA Service GmbH
- */
-package net.pterodactylus.util.fcp.message;
-
-import net.pterodactylus.util.fcp.FcpConnection;
-import net.pterodactylus.util.fcp.FcpMessage;
-
-/**
- * A “ClientHello” message that <i>must</i> be sent to the node first thing
- * after calling {@link FcpConnection#connect()}.
- *
- * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
- * @version $Id$
- */
-public class ClientHello extends FcpMessage {
-
- /**
- * Creates a new “ClientHello” message with the given client name. The
- * client name has to be unique to the node otherwise you will get a
- * {@link CloseConnectionDuplicateClientName} response from the node!
- *
- * @param clientName
- * The unique client name
- */
- public ClientHello(String clientName) {
- this(clientName, "2.0");
- }
-
- /**
- * Creates a new “ClientHello” message with the given client name. The
- * client name has to be unique to the node otherwise you will get a
- * {@link CloseConnectionDuplicateClientName} response from the node!
- *
- * The expected FCP version is currently ignored by the node.
- *
- * @param clientName
- * The unique client name
- * @param expectedVersion
- * The FCP version that the node is expected to talk
- */
- public ClientHello(String clientName, String expectedVersion) {
- super("ClientHello");
- setField("Name", clientName);
- setField("ExpectedVersion", expectedVersion);
- }
-
-}
+++ /dev/null
-/**
- * © 2008 INA Service GmbH
- */
-package net.pterodactylus.util.fcp.message;
-
-import net.pterodactylus.util.fcp.FcpMessage;
-
-/**
- * A “CloseConnectionDuplicateClientName” message.
- *
- * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
- * @version $Id$
- */
-public class CloseConnectionDuplicateClientName extends BaseMessage {
-
- /**
- * Creates a new CloseConnectionDuplicateClientName message that wraps the
- * given message.
- *
- * @param receivedMessage
- * The received message
- */
- public CloseConnectionDuplicateClientName(FcpMessage receivedMessage) {
- super(receivedMessage);
- }
-
-}
+++ /dev/null
-/**
- * © 2008 INA Service GmbH
- */
-package net.pterodactylus.util.fcp.message;
-
-import net.pterodactylus.util.fcp.FcpMessage;
-
-/**
- * The “EndListPeerNotes” message signals the end of a list of “PeerNote”
- * messages.
- *
- * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
- * @version $Id$
- */
-public class EndListPeerNotes extends BaseMessage {
-
- /**
- * Creates a new “EndListPeerNotes” message that wraps the received message.
- *
- * @param fcpMessage
- * The received message
- */
- public EndListPeerNotes(FcpMessage fcpMessage) {
- super(fcpMessage);
- }
-
-}
+++ /dev/null
-/**
- * © 2008 INA Service GmbH
- */
-package net.pterodactylus.util.fcp.message;
-
-import net.pterodactylus.util.fcp.FcpMessage;
-
-/**
- * This message marks the end of a list of “Peer” replies.
- *
- * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
- * @version $Id$
- */
-public class EndListPeers extends BaseMessage {
-
- /**
- * Creates a new “EndListPeers” message that wraps the received message.
- *
- * @param receivedMessage
- * The message that was received
- */
- public EndListPeers(FcpMessage receivedMessage) {
- super(receivedMessage);
- }
-
-}
+++ /dev/null
-/**
- * © 2008 INA Service GmbH
- */
-package net.pterodactylus.util.fcp.message;
-
-import net.pterodactylus.util.fcp.FcpMessage;
-import net.pterodactylus.util.fcp.FcpUtils;
-
-/**
- * A “GenerateSSK” message. This message tells the node to generate a new SSK
- * key pair.
- *
- * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
- * @version $Id$
- */
-public class GenerateSSK extends FcpMessage {
-
- /**
- * Creates a new “GenerateSSK” message.
- */
- public GenerateSSK() {
- this(FcpUtils.getUniqueIdentifier());
- }
-
- /**
- * Creates a new “GenerateSSK” message with the given client identifier.
- *
- * @param clientIdentifier
- * The client identifier
- */
- public GenerateSSK(String clientIdentifier) {
- super("GenerateSSK");
- setField("Identifier", clientIdentifier);
- }
-
-}
+++ /dev/null
-/**
- * © 2008 INA Service GmbH
- */
-package net.pterodactylus.util.fcp.message;
-
-import net.pterodactylus.util.fcp.FcpMessage;
-
-/**
- * The “ListPeer” request asks the node about the details of a given peer.
- *
- * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
- * @version $Id$
- */
-public class ListPeer extends FcpMessage {
-
- /**
- * Creates a new “ListPeer” request that returns information about the node
- * specified by <code>nodeIdentifier</code>. <code>nodeIdentifier</code>
- * can be of several formats: The node’s name, its identity, or its IP
- * address and port (connection with a ‘:’).
- *
- * @param nodeIdentifier
- * The identifier of the node to get details about
- */
- public ListPeer(String nodeIdentifier) {
- super("ListPeer");
- setField("NodeIdentifier", nodeIdentifier);
- }
-
-}
+++ /dev/null
-/**
- * © 2008 INA Service GmbH
- */
-package net.pterodactylus.util.fcp.message;
-
-import net.pterodactylus.util.fcp.FcpMessage;
-
-/**
- * A “ListPeerNodes” request tells the node to list all notes that have been
- * entered for a node. Note that notes are only supported for darknet nodes.
- *
- * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
- * @version $Id$
- */
-public class ListPeerNotes extends FcpMessage {
-
- /**
- * Creates a new “ListPeerNotes” request that lists all notes of the
- * specified node.
- *
- * @param nodeIdentifier
- * The identifier of the node
- */
- public ListPeerNotes(String nodeIdentifier) {
- super("ListPeerNotes");
- setField("NodeIdentifier", nodeIdentifier);
- }
-
-}
+++ /dev/null
-/**
- * © 2008 INA Service GmbH
- */
-package net.pterodactylus.util.fcp.message;
-
-import net.pterodactylus.util.fcp.FcpMessage;
-
-/**
- * The “ListPeer” requests asks the node for a list of all peers it has.
- *
- * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
- * @version $Id$
- */
-public class ListPeers extends FcpMessage {
-
- /**
- * Creates a new “ListPeers” request that only includes basic data of the
- * peers.
- */
- public ListPeers() {
- this(false, false);
- }
-
- /**
- * Creates a new “ListPeers” request that includes wanted data of the peers.
- *
- * @param withMetadata
- * If <code>true</code> metadata of the peers is included in
- * the reply
- * @param withVolatile
- * if <code>true</code> volatile data of the peers is included
- * in the reply
- */
- public ListPeers(boolean withMetadata, boolean withVolatile) {
- super("ListPeers");
- setField("WithMetadata", String.valueOf(withMetadata));
- setField("WithVolatile", String.valueOf(withVolatile));
- }
-
-}
+++ /dev/null
-/**
- * © 2008 INA Service GmbH
- */
-package net.pterodactylus.util.fcp.message;
-
-import net.pterodactylus.util.fcp.FcpMessage;
-
-/**
- * Some convenience methods for parsing a “NodeHello” message from the node.
- *
- * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
- * @version $Id$
- */
-public class NodeHello extends BaseMessage {
-
- /**
- * Createa a new “NodeHello” message that wraps the received message.
- *
- * @param receivedMessage
- * The received FCP message
- */
- public NodeHello(FcpMessage receivedMessage) {
- super(receivedMessage);
- }
-
- /**
- * Returns the build of the node. This may not be a number but also a string
- * like “@custom@” in case you built the node yourself.
- *
- * @return The build of the node
- */
- public String getBuild() {
- return getField("Build");
- }
-
- /**
- * Returns the build number of the node. This may not be a number but also a
- * string like “@custom@” in case you built the node yourself.
- *
- * @return The build number of the node, or <code>-1</code> if the build
- * number could not be determined
- */
- public int getBuildNumber() {
- String build = getBuild();
- try {
- return Integer.valueOf(build);
- } catch (NumberFormatException nfe1) {
- /* ignore. */
- }
- return -1;
- }
-
- /**
- * Returns the number of compression codecs.
- *
- * @return The number of compression codecs
- */
- public String getCompressionCodecs() {
- return getField("CompressionCodecs");
- }
-
- /**
- * Returns the number of compression codecs.
- *
- * @return The number of compression codecs, or <code>-1</code> if the
- * number of compression codecs could not be determined
- */
- public int getCompressionCodecsNumber() {
- String compressionCodecs = getCompressionCodecs();
- try {
- return Integer.valueOf(compressionCodecs);
- } catch (NumberFormatException nfe1) {
- /* ignore. */
- }
- return -1;
- }
-
- /**
- * Returns the unique connection identifier.
- *
- * @return The connection identifier
- */
- public String getConnectionIdentifier() {
- return getField("ConnectionIdentifier");
- }
-
- /**
- * Returns the build of the external library file.
- *
- * @return The build of the external library file
- */
- public String getExtBuild() {
- return getField("ExtBuild");
- }
-
- /**
- * Returns the build number of the external library file.
- *
- * @return The build number of the external library file, or <code>-1</code>
- * if the build number could not be determined
- */
- public int getExtBuildNumber() {
- String extBuild = getExtBuild();
- try {
- return Integer.valueOf(extBuild);
- } catch (NumberFormatException nfe1) {
- /* ignore. */
- }
- return -1;
- }
-
- /**
- * Returns the revision of the external library file.
- *
- * @return The revision of the external library file
- */
- public String getExtRevision() {
- return getField("ExtRevision");
- }
-
- /**
- * Returns the revision number of the external library file.
- *
- * @return The revision number of the external library file, or
- * <code>-1</code> if the revision number could not be determined
- */
- public int getExtRevisionNumber() {
- String extRevision = getExtRevision();
- try {
- return Integer.valueOf(extRevision);
- } catch (NumberFormatException nfe1) {
- /* ignore. */
- }
- return -1;
- }
-
- /**
- * Returns the FCP version the node speaks.
- *
- * @return The FCP version the node speaks
- */
- public String getFCPVersion() {
- return getField("FCPVersion");
- }
-
- /**
- * Returns the make of the node, e.g. “Fred” (freenet reference
- * implementation).
- *
- * @return The make of the node
- */
- public String getNode() {
- return getField("Node");
- }
-
- /**
- * Returns the language of the node as 2-letter code, e.g. “en” or “de”.
- *
- * @return The language of the node
- */
- public String getNodeLanguage() {
- return getField("NodeLanguage");
- }
-
- /**
- * Returns the revision of the node.
- *
- * @return The revision of the node
- */
- public String getRevision() {
- return getField("Revision");
- }
-
- /**
- * Returns the revision number of the node.
- *
- * @return The revision number of the node, or <code>-1</code> if the
- * revision number coult not be determined
- */
- public int getRevisionNumber() {
- String revision = getRevision();
- try {
- return Integer.valueOf(revision);
- } catch (NumberFormatException nfe1) {
- /* ignore. */
- }
- return -1;
- }
-
- /**
- * Returns whether the node is currently is testnet mode.
- *
- * @return <code>true</code> if the node is currently in testnet mode,
- * <code>false</code> otherwise
- */
- public boolean getTestnet() {
- return Boolean.valueOf(getField("Testnet"));
- }
-
- /**
- * Returns the version of the node.
- *
- * @return The version of the node
- */
- public String getVersion() {
- return getField("Version");
- }
-
-}
+++ /dev/null
-/**
- * © 2008 INA Service GmbH
- */
-package net.pterodactylus.util.fcp.message;
-
-import java.security.interfaces.DSAParams;
-import java.util.StringTokenizer;
-
-import net.pterodactylus.util.fcp.FcpMessage;
-import net.pterodactylus.util.fcp.FcpUtils;
-
-/**
- * The “Peer” reply by the node contains information about a peer.
- *
- * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
- * @version $Id$
- */
-public class Peer extends BaseMessage {
-
- /**
- * Creates a new “Peer” reply from the received message.
- *
- * @param receivedMessage
- * The received message
- */
- public Peer(FcpMessage receivedMessage) {
- super(receivedMessage);
- }
-
- /**
- * Returns the “physical.udp” line from the message. It contains all IP
- * addresses and port numbers of the peer.
- *
- * @return The IP addresses and port numbers of the peer
- */
- public String getPhysicalUDP() {
- return getField("physical.udp");
- }
-
- /**
- * Returns whether the listed peer is an opennet peer.
- *
- * @return <code>true</code> if the peer is an opennet peer,
- * <code>false</code> if the peer is a darknet peer
- */
- public boolean isOpennet() {
- return Boolean.valueOf(getField("opennet"));
- }
-
- /**
- * Returns the “y” part of the peer’s public DSA key.
- *
- * @return The public DSA key
- */
- public String getDSAPublicKey() {
- return getField("dsaPubKey.y");
- }
-
- /**
- * Returns the DSA group of the peer.
- *
- * @return The DSA group of the peer
- */
- public DSAGroup getDSAGroup() {
- return new DSAGroup(getField("dsaGroup.g"), getField("dsaGroup.p"), getField("dsaGroup.q"));
- }
-
- /**
- * Returns the last good version of the peer, i.e. the oldest version the
- * peer will connect to.
- *
- * @return The last good version of the peer
- */
- public Version getLastGoodVersion() {
- return new Version(getField("lastGoodVersion"));
- }
-
- /**
- * Returns the ARK of the peer.
- *
- * @return The ARK of the peer
- */
- public ARK getARK() {
- return new ARK(getField("ark.pubURI"), getField("ark.number"));
- }
-
- /**
- * Returns the identity of the peer.
- *
- * @return The identity of the peer
- */
- public String getIdentity() {
- return getField("identity");
- }
-
- /**
- * Returns the name of the peer. If the peer is not a darknet peer it will
- * have no name.
- *
- * @return The name of the peer, or <code>null</code> if the peer is an
- * opennet peer
- */
- public String getMyName() {
- return getField("myName");
- }
-
- /**
- * Returns the location of the peer.
- *
- * @return The location of the peer
- * @throws NumberFormatException
- * if the field can not be parsed
- */
- public double getLocation() throws NumberFormatException {
- return Double.valueOf(getField("location"));
- }
-
- /**
- * Returns whether the peer is a testnet node.
- *
- * @return <code>true</code> if the peer is a testnet node,
- * <code>false</code> otherwise
- */
- public boolean isTestnet() {
- return Boolean.valueOf("testnet");
- }
-
- /**
- * Returns the version of the peer.
- *
- * @return The version of the peer
- */
- public Version getVersion() {
- return new Version(getField("version"));
- }
-
- /**
- * Returns the negotiation types the peer supports.
- *
- * @return The supported negotiation types
- */
- public int[] getNegotiationTypes() {
- return FcpUtils.parseMultiIntegerField(getField("auth.negTypes"));
- }
-
- /**
- * Container for the “lastGoodVersion” field.
- *
- * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
- * @version $Id$
- */
- public static class Version {
-
- /** The name of the node implementation. */
- private final String nodeName;
-
- /** The tree version of the node. */
- private final String treeVersion;
-
- /** The protocol version of the node. */
- private final String protocolVersion;
-
- /** The build number of the node. */
- private final int buildNumber;
-
- /**
- * Creates a new Version from the given string. The string consists of
- * the four required fields node name, tree version, protocol version,
- * and build number, separated by a comma.
- *
- * @param version
- * The version string
- * @throws NullPointerException
- * if <code>version</code> is <code>null</code>
- * @throws IllegalArgumentException
- * if <code>version</code> is not in the right format
- */
- public Version(String version) {
- if (version == null) {
- throw new NullPointerException("version must not be null");
- }
- StringTokenizer versionTokens = new StringTokenizer(version, ",");
- if (versionTokens.countTokens() != 4) {
- throw new IllegalArgumentException("version must consist of four fields");
- }
- this.nodeName = versionTokens.nextToken();
- this.treeVersion = versionTokens.nextToken();
- this.protocolVersion = versionTokens.nextToken();
- try {
- this.buildNumber = Integer.valueOf(versionTokens.nextToken());
- } catch (NumberFormatException nfe1) {
- throw new IllegalArgumentException("last part of version must be numeric", nfe1);
- }
- }
-
- /**
- * Creates a new Version from the given parts.
- *
- * @param nodeName
- * The name of the node implementation
- * @param treeVersion
- * The tree version
- * @param protocolVersion
- * The protocol version
- * @param buildNumber
- * The build number of the node
- */
- public Version(String nodeName, String treeVersion, String protocolVersion, int buildNumber) {
- this.nodeName = nodeName;
- this.treeVersion = treeVersion;
- this.protocolVersion = protocolVersion;
- this.buildNumber = buildNumber;
- }
-
- /**
- * Returns the name of the node implementation.
- *
- * @return The node name
- */
- public String getNodeName() {
- return nodeName;
- }
-
- /**
- * The tree version of the node.
- *
- * @return The tree version of the node
- */
- public String getTreeVersion() {
- return treeVersion;
- }
-
- /**
- * The protocol version of the node
- *
- * @return The protocol version of the node
- */
- public String getProtocolVersion() {
- return protocolVersion;
- }
-
- /**
- * The build number of the node.
- *
- * @return The build number of the node
- */
- public int getBuildNumber() {
- return buildNumber;
- }
-
- }
-
- /**
- * Container for ARKs (address resolution keys).
- *
- * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
- * @version $Id$
- */
- public static class ARK {
-
- /** The public URI of the ARK. */
- private final String publicURI;
-
- /** The number of the ARK. */
- private final int number;
-
- /**
- * Creates a new ARK with the given URI and number.
- *
- * @param publicURI
- * The public URI of the ARK
- * @param number
- * The number of the ARK
- */
- public ARK(String publicURI, String number) {
- if ((publicURI == null) || (number == null)) {
- throw new NullPointerException(((publicURI == null) ? "publicURI" : "number") + " must not be null");
- }
- this.publicURI = publicURI;
- try {
- this.number = Integer.valueOf(number);
- } catch (NumberFormatException nfe1) {
- throw new IllegalArgumentException("number must be numeric", nfe1);
- }
- }
-
- /**
- * Returns the public URI of the ARK.
- *
- * @return The public URI of the ARK
- */
- public String getPublicURI() {
- return publicURI;
- }
-
- /**
- * Returns the number of the ARK.
- *
- * @return The number of the ARK
- */
- public int getNumber() {
- return number;
- }
-
- }
-
- /**
- * Container for the DSA group of a peer. A DSA group consists of a base
- * (called “g”), a prime (called “p”) and a subprime (called “q”).
- *
- * @see DSAParams
- * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
- * @version $Id$
- */
- public static class DSAGroup {
-
- /** The base of the DSA group. */
- private final String base;
-
- /** The prime of the DSA group. */
- private final String prime;
-
- /** The subprime of the DSA group. */
- private final String subprime;
-
- /**
- * Creates a new DSA group with the given base (“g”), prime (“p”), and
- * subprime (“q”).
- *
- * @param base
- * The base of the DSA group
- * @param prime
- * The prime of the DSA group
- * @param subprime
- * The subprime of the DSA group
- */
- public DSAGroup(String base, String prime, String subprime) {
- this.base = base;
- this.prime = prime;
- this.subprime = subprime;
- }
-
- /**
- * Returns the base (“g”) of the DSA group.
- *
- * @return The base of the DSA group
- */
- public String getBase() {
- return base;
- }
-
- /**
- * Returns the prime (“p”) of the DSA group.
- *
- * @return The prime of the DSA group
- */
- public String getPrime() {
- return prime;
- }
-
- /**
- * Returns the subprime (“q”) of the DSA group.
- *
- * @return The subprime of the DSA group
- */
- public String getSubprime() {
- return subprime;
- }
-
- }
-
-}
+++ /dev/null
-/**
- * © 2008 INA Service GmbH
- */
-package net.pterodactylus.util.fcp.message;
-
-import net.pterodactylus.util.fcp.FcpMessage;
-
-/**
- * The “PeerNote” message contains a private note that has been entered for a
- * darknet peer.
- *
- * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
- * @version $Id$
- */
-public class PeerNote extends BaseMessage {
-
- /** The type for base64 encoded peer notes. */
- public static final int NOTE_TYPE_BASE64 = 1;
-
- /**
- * Creates a “PeerNote” message that wraps the recevied message.
- *
- * @param receivedMessage
- * The received message
- */
- public PeerNote(FcpMessage receivedMessage) {
- super(receivedMessage);
- }
-
- /**
- * Returns the note text in whatever format is specified by
- * {@link #getPeerNoteType()}.
- *
- * @return The note text
- */
- public String getNoteText() {
- return getField("NoteText");
- }
-
- /**
- * Returns the type of the peer note. The type <code>1</code> means that
- * the text of the note is base64-encoded.
- *
- * @return The type of the peer note
- * @throws NumberFormatException
- * if the field can not be parsed
- */
- public int getPeerNoteType() throws NumberFormatException {
- return Integer.valueOf(getField("PeerNoteType"));
- }
-
-}
+++ /dev/null
-/**
- * © 2008 INA Service GmbH
- */
-package net.pterodactylus.util.fcp.message;
-
-import net.pterodactylus.util.fcp.FcpMessage;
-
-/**
- * An “SSKKeypair” message that is sent as a response to a {@link GenerateSSK}
- * message.
- *
- * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
- * @version $Id$
- */
-public class SSKKeypair extends BaseMessage {
-
- /**
- * Creates a new “SSKKeypair” message that wraps the received message.
- *
- * @param receivedMessage
- * The received message
- */
- public SSKKeypair(FcpMessage receivedMessage) {
- super(receivedMessage);
- }
-
- /**
- * Returns the identifier of the request.
- *
- * @return The identifier of the request
- */
- public String getIdentifier() {
- return getField("Identifier");
- }
-
- /**
- * Returns the URI that must be used to insert data.
- *
- * @return The insert URI
- */
- public String getInsertURI() {
- return getField("InsertURI");
- }
-
- /**
- * Returns the URI that must be used to request data.
- *
- * @return The request URI
- */
- public String getRequestURI() {
- return getField("RequestURI");
- }
-
-}
+++ /dev/null
-/**
- * Package that holds all the message types that are used in the communication with a Freenet Node.
- */
-package net.pterodactylus.util.fcp.message;
\ No newline at end of file
--- /dev/null
+/**
+ * Package that holds all the message types that are used in the communication with a Freenet Node.
+ */
+package net.pterodactylus.util.fcp;
\ No newline at end of file