From 6a3c52b7fa1ed07197f94445043822461dc91e3b Mon Sep 17 00:00:00 2001
From: sponge <sponge@mail.i2p>
Date: Fri, 28 Nov 2008 16:07:29 +0000
Subject: [PATCH] Added verify command to check that a destination's BASE64 is
 correct for external applications that need it.

---
 apps/BOB/build.xml                            |  5 ++++
 apps/BOB/nbproject/build-impl.xml             | 23 +++++++++++++++----
 apps/BOB/nbproject/genfiles.properties        |  8 +++----
 apps/BOB/nbproject/private/private.properties |  4 ++--
 apps/BOB/src/net/i2p/BOB/DoCMDS.java          | 21 ++++++++++++-----
 5 files changed, 44 insertions(+), 17 deletions(-)

diff --git a/apps/BOB/build.xml b/apps/BOB/build.xml
index f76222aeac..0d2a66eaa3 100644
--- a/apps/BOB/build.xml
+++ b/apps/BOB/build.xml
@@ -2,6 +2,11 @@
 <!-- You may freely edit this file. See commented blocks below for -->
 <!-- some examples of how to customize the build. -->
 <!-- (If you delete it and reopen the project it will be recreated.) -->
+<!-- By default, only the Clean and Build commands use this build script. -->
+<!-- Commands such as Run, Debug, and Test only use this build script if -->
+<!-- the Compile on Save feature is turned off for the project. -->
+<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
+<!-- in the project's Project Properties dialog box.-->
 <project name="BOB" default="default" basedir=".">
     <description>Builds, tests, and runs the project BOB.</description>
     <import file="nbproject/build-impl.xml"/>
diff --git a/apps/BOB/nbproject/build-impl.xml b/apps/BOB/nbproject/build-impl.xml
index 5dcf755638..9feea8e039 100644
--- a/apps/BOB/nbproject/build-impl.xml
+++ b/apps/BOB/nbproject/build-impl.xml
@@ -218,13 +218,13 @@ is divided into following sections:
             </sequential>
         </macrodef>
     </target>
-    <target name="-init-macrodef-nbjpda">
+    <target depends="-init-debug-args" name="-init-macrodef-nbjpda">
         <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1">
             <attribute default="${main.class}" name="name"/>
             <attribute default="${debug.classpath}" name="classpath"/>
             <attribute default="" name="stopclassname"/>
             <sequential>
-                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="dt_socket">
+                <nbjpdastart addressproperty="jpda.address" name="@{name}" stopclassname="@{stopclassname}" transport="${debug-transport}">
                     <classpath>
                         <path path="@{classpath}"/>
                     </classpath>
@@ -255,6 +255,12 @@ is divided into following sections:
         <condition else="-Xdebug" property="debug-args-line" value="-Xdebug -Xnoagent -Djava.compiler=none">
             <istrue value="${have-jdk-older-than-1.4}"/>
         </condition>
+        <condition else="dt_socket" property="debug-transport-by-os" value="dt_shmem">
+            <os family="windows"/>
+        </condition>
+        <condition else="${debug-transport-by-os}" property="debug-transport" value="${debug.transport}">
+            <isset property="debug.transport"/>
+        </condition>
     </target>
     <target depends="-init-debug-args" name="-init-macrodef-debug">
         <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/3">
@@ -264,7 +270,7 @@ is divided into following sections:
             <sequential>
                 <java classname="@{classname}" dir="${work.dir}" fork="true">
                     <jvmarg line="${debug-args-line}"/>
-                    <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/>
+                    <jvmarg value="-Xrunjdwp:transport=${debug-transport},address=${jpda.address}"/>
                     <jvmarg line="${run.jvmargs}"/>
                     <classpath>
                         <path path="@{classpath}"/>
@@ -311,6 +317,13 @@ is divided into following sections:
                 ===================
             -->
     <target depends="init" name="deps-jar" unless="no.deps"/>
+    <target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
+    <target depends="init" name="-check-automatic-build">
+        <available file="${build.classes.dir}/.netbeans_automatic_build" property="netbeans.automatic.build"/>
+    </target>
+    <target depends="init" if="netbeans.automatic.build" name="-clean-after-automatic-build">
+        <antcall target="clean"/>
+    </target>
     <target depends="init,deps-jar" name="-pre-pre-compile">
         <mkdir dir="${build.classes.dir}"/>
     </target>
@@ -331,7 +344,7 @@ is divided into following sections:
         <!-- Empty placeholder for easier customization. -->
         <!-- You can override this target in the ../build.xml file. -->
     </target>
-    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
+    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project." name="compile"/>
     <target name="-pre-compile-single">
         <!-- Empty placeholder for easier customization. -->
         <!-- You can override this target in the ../build.xml file. -->
@@ -345,7 +358,7 @@ is divided into following sections:
         <!-- Empty placeholder for easier customization. -->
         <!-- You can override this target in the ../build.xml file. -->
     </target>
-    <target depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
+    <target depends="init,deps-jar,-verify-automatic-build,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single" name="compile-single"/>
     <!--
                 ====================
                 JAR BUILDING SECTION
diff --git a/apps/BOB/nbproject/genfiles.properties b/apps/BOB/nbproject/genfiles.properties
index 55b2caf317..dfc3734b8a 100644
--- a/apps/BOB/nbproject/genfiles.properties
+++ b/apps/BOB/nbproject/genfiles.properties
@@ -1,8 +1,8 @@
 build.xml.data.CRC32=209349b6
-build.xml.script.CRC32=05a1ffd9
-build.xml.stylesheet.CRC32=be360661
+build.xml.script.CRC32=403e69e6
+build.xml.stylesheet.CRC32=958a1d3e
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
 nbproject/build-impl.xml.data.CRC32=209349b6
-nbproject/build-impl.xml.script.CRC32=eeeca375
-nbproject/build-impl.xml.stylesheet.CRC32=487672f9
+nbproject/build-impl.xml.script.CRC32=75fac64c
+nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
diff --git a/apps/BOB/nbproject/private/private.properties b/apps/BOB/nbproject/private/private.properties
index f11a1a7a76..979533fbdb 100644
--- a/apps/BOB/nbproject/private/private.properties
+++ b/apps/BOB/nbproject/private/private.properties
@@ -2,5 +2,5 @@ do.depend=false
 do.jar=true
 javac.debug=true
 javadoc.preview=true
-jaxws.endorsed.dir=/usr/local/netbeans-6.1/java2/modules/ext/jaxws21/api
-user.properties.file=/root/.netbeans/6.1/build.properties
+jaxws.endorsed.dir=/usr/local/netbeans-6.5/java2/modules/ext/jaxws21/api:/usr/local/netbeans-6.5/ide10/modules/ext/jaxb/api
+user.properties.file=/root/.netbeans/6.5/build.properties
diff --git a/apps/BOB/src/net/i2p/BOB/DoCMDS.java b/apps/BOB/src/net/i2p/BOB/DoCMDS.java
index f309bcb96d..2aaeba9e9c 100644
--- a/apps/BOB/src/net/i2p/BOB/DoCMDS.java
+++ b/apps/BOB/src/net/i2p/BOB/DoCMDS.java
@@ -46,7 +46,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 = "01",  BEXT = "-C";
+	public static final String BMAJ = "00",  BMIN = "00",  BREV = "01",  BEXT = "-D";
 	public static final String BOBversion = BMAJ + "." + BMIN + "." + BREV + BEXT;
 	private Socket server;
 	private Properties props;
@@ -92,6 +92,7 @@ public class DoCMDS implements Runnable {
 	private static final String C_start = "start";
 	private static final String C_status = "status";
 	private static final String C_stop = "stop";
+	private static final String C_verify = "verify";
 
 	/* all the coomands available, plus description */
 	private static final String C_ALL[][] = {
@@ -115,6 +116,7 @@ public class DoCMDS implements Runnable {
 		{C_start, C_start + " * Start the current nickname tunnel."},
 		{C_status, C_status + " nickname * Display status of a nicknamed tunnel."},
 		{C_stop, C_stop + " * Stops the current nicknamed tunnel."},
+		{C_verify, C_verify + " BASE64_key * Verifies BASE64 destination."},
 		{"", "COMMANDS: " + // this is ugly, but...
 		 C_help + " " +
 		 C_clear + " " +
@@ -135,7 +137,8 @@ public class DoCMDS implements Runnable {
 		 C_show + " " +
 		 C_start + " " +
 		 C_status + " " +
-		 C_stop
+		 C_stop + " " +
+		 C_verify
 		},
 		{" ", " "} // end of list
 	};
@@ -346,12 +349,12 @@ public class DoCMDS implements Runnable {
 	 * @return
 	 */
 	private boolean is64ok(String data) {
-		String dest = new String(data);
-		if(dest.replaceAll("[a-zA-Z0-9~-]", "").length() == 0) {
+		try {
+			Destination x = new Destination(data);
 			return true;
+		} catch(Exception e) {
+			return false;
 		}
-
-		return false;
 	}
 
 	/**
@@ -619,6 +622,12 @@ die:                            {
 									}
 								}
 
+							}else if(Command.equals(C_verify)) {
+								if(is64ok(Arg)) {
+									out.println("OK");
+								} else {
+									out.println("ERROR not in BASE64 format");
+								}
 							} else if(Command.equals(C_setkeys)) {
 								// Set the NamedDB to a privatekey in BASE64 format
 								if(ns) {
-- 
GitLab