From 1a49c4af0e1adc796041274c726c23a539f1b53c Mon Sep 17 00:00:00 2001
From: dream
Date: Sat, 10 Sep 2011 02:18:23 +0000
Subject: [PATCH] Fixing Shortcut to parse URLs correctly when adding an
address helper. Also a quick example of how to use rsync over i2p.
---
addresspublisher/nbproject/build-impl.xml | 249 ++++++++++++++----
.../nbproject/genfiles.properties | 4 +-
.../nbproject/private/private.properties | 2 +-
.../src/i2p/dream/lookup/Shortcut.java | 134 +++++++---
rsyncwproxy.sh | 8 +
5 files changed, 302 insertions(+), 95 deletions(-)
create mode 100644 rsyncwproxy.sh
diff --git a/addresspublisher/nbproject/build-impl.xml b/addresspublisher/nbproject/build-impl.xml
index a2ffc77..39fd410 100644
--- a/addresspublisher/nbproject/build-impl.xml
+++ b/addresspublisher/nbproject/build-impl.xml
@@ -80,7 +80,14 @@ is divided into following sections:
-
+
+
+
+
+
+
+
+
@@ -95,8 +102,14 @@ is divided into following sections:
+
+
+
+
+
+
@@ -109,40 +122,41 @@ is divided into following sections:
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
@@ -198,8 +212,17 @@ is divided into following sections:
-
+
+
+
+
+
+
+
+
+
+
@@ -327,7 +350,9 @@ is divided into following sections:
-
+
+
+
@@ -337,7 +362,8 @@ is divided into following sections:
-
+
+
@@ -353,11 +379,56 @@ is divided into following sections:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
@@ -452,6 +523,7 @@ is divided into following sections:
+
@@ -467,7 +539,7 @@ is divided into following sections:
-
+
@@ -596,10 +668,10 @@ is divided into following sections:
-
+
-
+
@@ -608,44 +680,53 @@ is divided into following sections:
- To run this application from the command line without Ant, try:
+ To run this application from the command line without Ant, try:
- java -cp "${run.classpath.with.dist.jar}" ${main.class}
+ java -cp "${run.classpath.with.dist.jar}" ${main.class}
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
-
- java -jar "${dist.jar.resolved}"
+
+
+
-
-
-
-
-
-
- To run this application from the command line without Ant, try:
+
+
+ To run this application from the command line without Ant, try:
- java -jar "${dist.jar.resolved}"
+ java -jar "${dist.jar.resolved}"
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
Must select some files in the IDE or set javac.includes
diff --git a/addresspublisher/nbproject/genfiles.properties b/addresspublisher/nbproject/genfiles.properties
index 529faeb..ccf88a7 100644
--- a/addresspublisher/nbproject/genfiles.properties
+++ b/addresspublisher/nbproject/genfiles.properties
@@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=28e38971@1.38.2.45
# 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=00fdd0af
-nbproject/build-impl.xml.script.CRC32=b5dc77d5
-nbproject/build-impl.xml.stylesheet.CRC32=229523de@1.38.3.45
+nbproject/build-impl.xml.script.CRC32=b8efd1b3
+nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
diff --git a/addresspublisher/nbproject/private/private.properties b/addresspublisher/nbproject/private/private.properties
index 8994e0a..ce75207 100644
--- a/addresspublisher/nbproject/private/private.properties
+++ b/addresspublisher/nbproject/private/private.properties
@@ -5,4 +5,4 @@ file.reference.i2p.jar=/mnt/bb/dream/packages/mtn/i2p.scripts/addresspublisher/l
file.reference.javax.servlet.jar=/mnt/bb/dream/packages/mtn/i2p.scripts/addresspublisher/lib/javax.servlet.jar
javac.debug=true
javadoc.preview=true
-user.properties.file=/mnt/bb/dream/.netbeans/6.9/build.properties
+user.properties.file=/mnt/bb/dream/.netbeans/7.0/build.properties
diff --git a/lookup/shortcut/src/i2p/dream/lookup/Shortcut.java b/lookup/shortcut/src/i2p/dream/lookup/Shortcut.java
index fa2e147..76f988e 100644
--- a/lookup/shortcut/src/i2p/dream/lookup/Shortcut.java
+++ b/lookup/shortcut/src/i2p/dream/lookup/Shortcut.java
@@ -1,24 +1,28 @@
package i2p.dream.lookup;
-import java.util.logging.Level;
-import java.util.logging.Logger;
+import net.i2p.I2PAppContext;
+import net.i2p.data.Base32;
+import net.i2p.data.Base64;
+import net.i2p.data.DataFormatException;
+import net.i2p.data.Destination;
+import net.i2p.data.Hash;
+import net.i2p.data.Base64;
+
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-import net.i2p.data.Base32;
-import net.i2p.data.DataFormatException;
-import net.i2p.data.Destination;
-
+import java.util.logging.Level;
+import java.util.logging.Logger;
import java.io.PrintWriter;
-
-import net.i2p.data.Hash;
-
-import net.i2p.I2PAppContext;
-import net.i2p.data.Base64;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.net.URLDecoder;
+import java.net.MalformedURLException;
public class Shortcut extends HttpServlet {
@@ -31,18 +35,18 @@ public class Shortcut extends HttpServlet {
HttpServletResponse response)
throws ServletException, IOException {
- String name = request.getParameter("name");
- boolean quick = request.getParameter("q") != null;
- if (name == null) {
+ String bleh = request.getParameter("url");
+ URL url = null;
+ String name = null;
+ if(bleh!=null) {
+ url = new URL(URLDecoder.decode(bleh,"utf-8"));
+ name = url.getHost();
+ }
+
+ final boolean quick = request.getParameter("q") != null;
+ if (url == null) {
askForName(response);
} else {
- if (name.startsWith("http://")) {
- name = name.substring(7);
- }
- int i = name.indexOf('/');
- if (i > 0) {
- name = name.substring(0, i);
- }
boolean isb32 = false;
Destination address = null;
int length = name.length();
@@ -61,18 +65,17 @@ public class Shortcut extends HttpServlet {
final String b64 = request.getParameter("b64");
if (b64 == null) {
// lookup works for both b32 and addressbook names.
- System.err.println("nameboo " + name);
address = I2PAppContext.getGlobalContext().namingService().lookup(name);
- // we still want to give it a name though.
+ // we still want to give it a name though, even though b32
if(isb32) {
- name = null;
+ name = request.getParameter("name");
}
- showShortcut(response, name, address, quick);
+ showShortcut(response, name, url, address, quick);
return;
} else {
if (isb32) {
// don't be adding any b32 names to our addressbook now.
- name = null;
+ name = request.getParameter("name");
}
address = new Destination();
try {
@@ -87,7 +90,7 @@ public class Shortcut extends HttpServlet {
});
return;
}
- showShortcut(response, name, address, quick);
+ showShortcut(response, name, url, address, quick);
}
}
}
@@ -117,14 +120,52 @@ public class Shortcut extends HttpServlet {
public void respond(PrintWriter out) {
out.println("Shortcut Finder");
out.println("Enter a name in your addressbook, or a base64 hash to find the shortcut base32 address for the eepsite.
");
- out.println("
");
+ out.println("