From ddc895358923b3387254711a7cd284d249595d23 Mon Sep 17 00:00:00 2001
From: sponge <sponge@mail.i2p>
Date: Wed, 2 Feb 2011 17:06:34 +0000
Subject: [PATCH] Revise lookup code

---
 apps/BOB/src/net/i2p/BOB/DoCMDS.java   | 18 +++++++++++-------
 apps/BOB/src/net/i2p/BOB/TCPtoI2P.java | 11 ++++++-----
 2 files changed, 17 insertions(+), 12 deletions(-)

diff --git a/apps/BOB/src/net/i2p/BOB/DoCMDS.java b/apps/BOB/src/net/i2p/BOB/DoCMDS.java
index 9894530d81..81c29cc037 100644
--- a/apps/BOB/src/net/i2p/BOB/DoCMDS.java
+++ b/apps/BOB/src/net/i2p/BOB/DoCMDS.java
@@ -32,11 +32,12 @@ import java.net.Socket;
 import java.util.Properties;
 import java.util.StringTokenizer;
 import java.util.concurrent.atomic.AtomicBoolean;
+import net.i2p.I2PAppContext;
 import net.i2p.I2PException;
 import net.i2p.client.I2PClientFactory;
-import net.i2p.data.DataFormatException;
+//import net.i2p.data.DataFormatException;
 import net.i2p.data.Destination;
-import net.i2p.i2ptunnel.I2PTunnel;
+//import net.i2p.i2ptunnel.I2PTunnel;
 import net.i2p.util.Log;
 // needed only for debugging.
 // import java.util.logging.Level;
@@ -52,7 +53,7 @@ public class DoCMDS implements Runnable {
 
 	// FIX ME
 	// I need a better way to do versioning, but this will do for now.
-	public static final String BMAJ = "00",  BMIN = "00",  BREV = "0E",  BEXT = "";
+	public static final String BMAJ = "00",  BMIN = "00",  BREV = "0F",  BEXT = "";
 	public static final String BOBversion = BMAJ + "." + BMIN + "." + BREV + BEXT;
 	private Socket server;
 	private Properties props;
@@ -456,11 +457,14 @@ public class DoCMDS implements Runnable {
 									String reply = null;
 									if (Arg.endsWith(".i2p")) {
 										try {
-											try {
-												dest = I2PTunnel.destFromName(Arg);
-											} catch (DataFormatException ex) {
+											//try {
+												//dest = I2PTunnel.destFromName(Arg);
+											//} catch (DataFormatException ex) {
+											//}
+											dest = I2PAppContext.getGlobalContext().namingService().lookup(Arg);
+											if(dest != null) {
+												reply = dest.toBase64();
 											}
-											reply = dest.toBase64();
 										} catch (NullPointerException npe) {
 											// Could not find the destination!?
 										}
diff --git a/apps/BOB/src/net/i2p/BOB/TCPtoI2P.java b/apps/BOB/src/net/i2p/BOB/TCPtoI2P.java
index a537d942f8..0e00f1c50e 100644
--- a/apps/BOB/src/net/i2p/BOB/TCPtoI2P.java
+++ b/apps/BOB/src/net/i2p/BOB/TCPtoI2P.java
@@ -36,7 +36,8 @@ import net.i2p.client.streaming.I2PSocket;
 import net.i2p.client.streaming.I2PSocketManager;
 import net.i2p.data.DataFormatException;
 import net.i2p.data.Destination;
-import net.i2p.i2ptunnel.I2PTunnel;
+//import net.i2p.i2ptunnel.I2PTunnel;
+import net.i2p.I2PAppContext;
 
 /**
  *
@@ -146,11 +147,11 @@ public class TCPtoI2P implements Runnable {
 				input = line.toLowerCase();
 				Destination dest = null;
 				if (input.endsWith(".i2p")) {
-					try {
-						dest = I2PTunnel.destFromName(input);
+					//dest = I2PTunnel.destFromName(input);
+					dest = I2PAppContext.getGlobalContext().namingService().lookup(input);
+					if (dest != null) {
 						line = dest.toBase64();
-					} catch (NullPointerException npe) {
-						// Could not find the destination!?
+					} else {
 						Emsg("Can't find destination: " + input, out);
 						return;
 					}
-- 
GitLab