summaryrefslogtreecommitdiff
path: root/src/org/noreply/fancydress/type3/Hop.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/noreply/fancydress/type3/Hop.java')
-rw-r--r--src/org/noreply/fancydress/type3/Hop.java39
1 files changed, 38 insertions, 1 deletions
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<packetVersions.length; i++)
+ if (v.equals(packetVersions[i]))
+ return true;
+ return false;
+ }
+
+ public String getNickname() {
+ return nickname;
+ };
}