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) {
87 * Sets the noderef of the peer to add.
90 * The noderef of the peer
92 private void setNodeRef(NodeRef nodeRef) {
93 setField("lastGoodVersion", nodeRef.getLastGoodVersion().toString());
94 setField("opennet", String.valueOf(nodeRef.isOpennet()));
95 setField("identity", nodeRef.getIdentity());
96 setField("myName", nodeRef.getMyName());
97 setField("location", String.valueOf(nodeRef.getLocation()));
98 setField("testnet", String.valueOf(nodeRef.isTestnet()));
99 setField("version", String.valueOf(nodeRef.getVersion()));
100 setField("physical.udp", nodeRef.getPhysicalUDP());
101 setField("ark.pubURI", nodeRef.getARK().getPublicURI());
102 setField("ark.number", String.valueOf(nodeRef.getARK().getNumber()));
103 setField("dsaPubKey.y", nodeRef.getDSAPublicKey());
104 setField("dsaGroup.g", nodeRef.getDSAGroup().getBase());
105 setField("dsaGroup.p", nodeRef.getDSAGroup().getPrime());
106 setField("dsaGroup.q", nodeRef.getDSAGroup().getSubprime());
107 setField("auth.negTypes", FcpUtils.encodeMultiIntegerField(nodeRef.getNegotiationTypes()));
108 setField("sig", nodeRef.getSignature());