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>
30 public class AddPeer extends FcpMessage {
33 * Creates a new “AddPeer” request.
40 * Creates a new “AddPeer” request that reads the noderef of the peer from
44 * The file to read the noderef from
46 public AddPeer(String file) {
48 setField("File", file);
52 * Creates a new “AddPeer” request that reads the noderef of the peer from
56 * The URL to read the noderef from
58 public AddPeer(URL url) {
60 setField("URL", String.valueOf(url));
64 * Creates a new “AddPeer” request that adds the peer given by the noderef.
67 * The noderef of the peer
69 public AddPeer(NodeRef nodeRef) {
79 * Sets the noderef of the peer to add.
82 * The noderef of the peer
84 private void setNodeRef(NodeRef nodeRef) {
85 setField("lastGoodVersion", nodeRef.getLastGoodVersion().toString());
86 setField("opennet", String.valueOf(nodeRef.isOpennet()));
87 setField("identity", nodeRef.getIdentity());
88 setField("myName", nodeRef.getMyName());
89 setField("location", String.valueOf(nodeRef.getLocation()));
90 setField("testnet", String.valueOf(nodeRef.isTestnet()));
91 setField("version", String.valueOf(nodeRef.getVersion()));
92 setField("physical.udp", nodeRef.getPhysicalUDP());
93 setField("ark.pubURI", nodeRef.getARK().getPublicURI());
94 setField("ark.number", String.valueOf(nodeRef.getARK().getNumber()));
95 setField("dsaPubKey.y", nodeRef.getDSAPublicKey());
96 setField("dsaGroup.g", nodeRef.getDSAGroup().getBase());
97 setField("dsaGroup.p", nodeRef.getDSAGroup().getPrime());
98 setField("dsaGroup.q", nodeRef.getDSAGroup().getSubprime());
99 setField("auth.negTypes", FcpUtils.encodeMultiIntegerField(nodeRef.getNegotiationTypes()));
100 setField("sig", nodeRef.getSignature());