2 * jFCPlib - AddPeer.java - Copyright © 2008 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 2 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, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 package net.pterodactylus.fcp;
24 * The “AddPeer” request adds a peer to the node.
26 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
28 public class AddPeer extends FcpMessage {
31 * Creates a new “AddPeer” request.
38 * Creates a new “AddPeer” request that reads the noderef of the peer from
42 * The file to read the noderef from
44 public AddPeer(String file) {
46 setField("File", file);
49 public AddPeer(String identifier, String file) {
51 setField("Identifier", identifier);
55 * Creates a new “AddPeer” request that reads the noderef of the peer from
59 * The URL to read the noderef from
61 public AddPeer(URL url) {
63 setField("URL", String.valueOf(url));
66 public AddPeer(String identifier, URL url) {
68 setField("Identifier", identifier);
72 * Creates a new “AddPeer” request that adds the peer given by the noderef.
75 * The noderef of the peer
77 public AddPeer(NodeRef nodeRef) {
82 public AddPeer(String identifier, NodeRef nodeRef) {
84 setField("Identifier", identifier);
92 * Sets the noderef of the peer to add.
95 * The noderef of the peer
97 private void setNodeRef(NodeRef nodeRef) {
98 setField("lastGoodVersion", String.valueOf(nodeRef.getLastGoodVersion()));
99 setField("opennet", String.valueOf(nodeRef.isOpennet()));
100 setField("identity", nodeRef.getIdentity());
101 setField("myName", nodeRef.getMyName());
102 setField("location", String.valueOf(nodeRef.getLocation()));
103 setField("testnet", String.valueOf(nodeRef.isTestnet()));
104 setField("version", String.valueOf(nodeRef.getVersion()));
105 setField("physical.udp", nodeRef.getPhysicalUDP());
106 setField("ark.pubURI", nodeRef.getARK().getPublicURI());
107 setField("ark.number", String.valueOf(nodeRef.getARK().getNumber()));
108 setField("dsaPubKey.y", nodeRef.getDSAPublicKey());
109 setField("dsaGroup.g", nodeRef.getDSAGroup().getBase());
110 setField("dsaGroup.p", nodeRef.getDSAGroup().getPrime());
111 setField("dsaGroup.q", nodeRef.getDSAGroup().getSubprime());
112 setField("auth.negTypes", FcpUtils.encodeMultiIntegerField(nodeRef.getNegotiationTypes()));
113 setField("sig", nodeRef.getSignature());