From a4c0d3d6d878da55435cb9d9cc8cff6199644199 Mon Sep 17 00:00:00 2001 From: Peter Palfrader Date: Sun, 19 Oct 2003 15:08:35 +0000 Subject: Support random path creation --- src/org/noreply/fancydress/type3/Hop.java | 39 ++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'src/org/noreply/fancydress/type3/Hop.java') diff --git a/src/org/noreply/fancydress/type3/Hop.java b/src/org/noreply/fancydress/type3/Hop.java index 181d2e8..9c61b2d 100644 --- a/src/org/noreply/fancydress/type3/Hop.java +++ b/src/org/noreply/fancydress/type3/Hop.java @@ -3,14 +3,40 @@ 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) { + 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() { @@ -20,4 +46,15 @@ public class Hop { public RSAPublicKey getPubKey() { return pubKey; } + + public boolean supportsPacketVersion(String v) { + for (int i=0; i