2 * jSite2 - AddPeer.java -
3 * Copyright © 2008 David Roden
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 package net.pterodactylus.fcp;
25 * The “AddPeer” request adds a peer to the node.
27 * @author David ‘Bombe’ Roden <bombe@freenetproject.org>
29 public class AddPeer extends FcpMessage {
32 * Creates a new “AddPeer” request.
39 * Creates a new “AddPeer” request that reads the noderef of the peer from
43 * The file to read the noderef from
45 public AddPeer(String file) {
47 setField("File", file);
51 * Creates a new “AddPeer” request that reads the noderef of the peer from
55 * The URL to read the noderef from
57 public AddPeer(URL url) {
59 setField("URL", String.valueOf(url));
63 * Creates a new “AddPeer” request that adds the peer given by the noderef.
66 * The noderef of the peer
68 public AddPeer(NodeRef nodeRef) {
78 * Sets the noderef of the peer to add.
81 * The noderef of the peer
83 private void setNodeRef(NodeRef nodeRef) {
84 setField("lastGoodVersion", nodeRef.getLastGoodVersion().toString());
85 setField("opennet", String.valueOf(nodeRef.isOpennet()));
86 setField("identity", nodeRef.getIdentity());
87 setField("myName", nodeRef.getMyName());
88 setField("location", String.valueOf(nodeRef.getLocation()));
89 setField("testnet", String.valueOf(nodeRef.isTestnet()));
90 setField("version", String.valueOf(nodeRef.getVersion()));
91 setField("physical.udp", nodeRef.getPhysicalUDP());
92 setField("ark.pubURI", nodeRef.getARK().getPublicURI());
93 setField("ark.number", String.valueOf(nodeRef.getARK().getNumber()));
94 setField("dsaPubKey.y", nodeRef.getDSAPublicKey());
95 setField("dsaGroup.g", nodeRef.getDSAGroup().getBase());
96 setField("dsaGroup.p", nodeRef.getDSAGroup().getPrime());
97 setField("dsaGroup.q", nodeRef.getDSAGroup().getSubprime());
98 setField("auth.negTypes", FcpUtils.encodeMultiIntegerField(nodeRef.getNegotiationTypes()));
99 setField("sig", nodeRef.getSignature());