/* $Id$ */ package org.noreply.fancydress.type3; import org.noreply.fancydress.type3.routing.*; import org.noreply.fancydress.crypto.*; import org.noreply.fancydress.status.*; import org.noreply.fancydress.directory.*; public class Hop { private Routing routing; private RSAPublicKey pubKey; private String[] packetVersions; private String nickname; public Hop(Routing routing, RSAPublicKey pubKey, String[] packetVersions, String nickname) { this.routing = routing; this.pubKey = pubKey; this.packetVersions = packetVersions; this.nickname = nickname; } public Hop(Server server) throws Mix3PathProblemException { if (!server.isUseable()) throw new Mix3PathProblemException("Invalid path: '"+server.getNickname()+"' is not useable"); ServerDescriptor desc; try { desc = server.getDescriptor(); } catch (Mix3NoServerDescriptorException e) { throw new Error ("We should have a server descriptor at that point"); } IncomingMMTPSection incoming = desc.getIncomingMMTPSection(); if (incoming.getHostname() != null) this.routing = new RoutingHOST(incoming.getHostname(), incoming.getPort(), server.getKeyID()); else this.routing = new RoutingIP4(incoming.getIP(), incoming.getPort(), server.getKeyID()); /* FIXME */ this.pubKey = desc.getPacketKey(); this.packetVersions = desc.getPacketVersions(); this.nickname = server.getNickname(); } public Routing getRouting() { return routing; } public RSAPublicKey getPubKey() { return pubKey; } public boolean supportsPacketVersion(String v) { for (int i=0; i