2 * © 2008 INA Service GmbH
4 package net.pterodactylus.util.fcp;
9 * The “Peer” reply by the node contains information about a peer.
11 * @author <a href="mailto:dr@ina-germany.de">David Roden</a>
14 public class Peer extends BaseMessage {
17 * Creates a new “Peer” reply from the received message.
19 * @param receivedMessage
20 * The received message
22 public Peer(FcpMessage receivedMessage) {
23 super(receivedMessage);
27 * Returns the “physical.udp” line from the message. It contains all IP
28 * addresses and port numbers of the peer.
30 * @return The IP addresses and port numbers of the peer
32 public String getPhysicalUDP() {
33 return getField("physical.udp");
37 * Returns whether the listed peer is an opennet peer.
39 * @return <code>true</code> if the peer is an opennet peer,
40 * <code>false</code> if the peer is a darknet peer
42 public boolean isOpennet() {
43 return Boolean.valueOf(getField("opennet"));
47 * Returns the “y” part of the peer’s public DSA key.
49 * @return The public DSA key
51 public String getDSAPublicKey() {
52 return getField("dsaPubKey.y");
56 * Returns the DSA group of the peer.
58 * @return The DSA group of the peer
60 public DSAGroup getDSAGroup() {
61 return new DSAGroup(getField("dsaGroup.g"), getField("dsaGroup.p"), getField("dsaGroup.q"));
65 * Returns the last good version of the peer, i.e. the oldest version the
66 * peer will connect to.
68 * @return The last good version of the peer
70 public Version getLastGoodVersion() {
71 return new Version(getField("lastGoodVersion"));
75 * Returns the ARK of the peer.
77 * @return The ARK of the peer
80 return new ARK(getField("ark.pubURI"), getField("ark.number"));
84 * Returns the identity of the peer.
86 * @return The identity of the peer
88 public String getIdentity() {
89 return getField("identity");
93 * Returns the name of the peer. If the peer is not a darknet peer it will
96 * @return The name of the peer, or <code>null</code> if the peer is an
99 public String getMyName() {
100 return getField("myName");
104 * Returns the location of the peer.
106 * @return The location of the peer
107 * @throws NumberFormatException
108 * if the field can not be parsed
110 public double getLocation() throws NumberFormatException {
111 return Double.valueOf(getField("location"));
115 * Returns whether the peer is a testnet node.
117 * @return <code>true</code> if the peer is a testnet node,
118 * <code>false</code> otherwise
120 public boolean isTestnet() {
121 return Boolean.valueOf("testnet");
125 * Returns the version of the peer.
127 * @return The version of the peer
129 public Version getVersion() {
130 return new Version(getField("version"));
134 * Returns the negotiation types the peer supports.
136 * @return The supported negotiation types
138 public int[] getNegotiationTypes() {
139 return FcpUtils.parseMultiIntegerField(getField("auth.negTypes"));