diff --git a/apps/i2ptunnel/java/build.xml b/apps/i2ptunnel/java/build.xml
index 09bb837f9..d3e54fef1 100644
--- a/apps/i2ptunnel/java/build.xml
+++ b/apps/i2ptunnel/java/build.xml
@@ -86,7 +86,12 @@
-
+
+
+
+
+
+
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientBase.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientBase.java
index 20409b7ce..adf1799cc 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientBase.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelHTTPClientBase.java
@@ -7,6 +7,7 @@ import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
@@ -40,6 +41,7 @@ import net.i2p.data.Base64;
import net.i2p.data.DataHelper;
import net.i2p.data.Destination;
import net.i2p.data.i2cp.MessageStatusMessage;
+import net.i2p.i2ptunnel.localServer.LocalHTTPServer;
import net.i2p.util.EepGet;
import net.i2p.util.EventDispatcher;
import net.i2p.util.InternalSocket;
@@ -670,8 +672,7 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
* @since 0.9.4 moved from I2PTunnelHTTPClient
*/
protected static String getErrorPage(I2PAppContext ctx, String base, String backup) {
- File errorDir = new File(ctx.getBaseDir(), "docs");
- File file = new File(errorDir, base + "-header.ht");
+ String file = "proxy/" + base + "-header.ht";
try {
return readFile(ctx, file);
} catch(IOException ioe) {
@@ -683,20 +684,24 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
private static final String BUNDLE_NAME = "net.i2p.i2ptunnel.proxy.messages";
/**
+ * As of 0.9.49, loads the error pages from the jar, not the file system.
* @since 0.9.4 moved from I2PTunnelHTTPClient
*/
- private static String readFile(I2PAppContext ctx, File file) throws IOException {
+ private static String readFile(I2PAppContext ctx, String file) throws IOException {
Reader reader = null;
char[] buf = new char[512];
StringBuilder out = new StringBuilder(2048);
+ InputStream in = LocalHTTPServer.getResource(file);
+ if (in == null)
+ throw new IOException();
try {
boolean hasSusiDNS = ctx.portMapper().isRegistered(PortMapper.SVC_SUSIDNS);
boolean hasI2PTunnel = ctx.portMapper().isRegistered(PortMapper.SVC_I2PTUNNEL);
if (hasSusiDNS && hasI2PTunnel) {
- reader = new TranslateReader(ctx, BUNDLE_NAME, new FileInputStream(file));
+ reader = new TranslateReader(ctx, BUNDLE_NAME, in);
} else {
// strip out the addressbook links
- reader = new InputStreamReader(new FileInputStream(file), "UTF-8");
+ reader = new InputStreamReader(in, "UTF-8");
int len;
while((len = reader.read(buf)) > 0) {
out.append(buf, 0, len);
@@ -734,6 +739,7 @@ public abstract class I2PTunnelHTTPClientBase extends I2PTunnelClientBase implem
String rv = out.toString();
return rv;
} finally {
+ try { in.close(); } catch (IOException ioe) {}
try {
if(reader != null)
reader.close();
diff --git a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/localServer/LocalHTTPServer.java b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/localServer/LocalHTTPServer.java
index 26ae12ccd..ab989c101 100644
--- a/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/localServer/LocalHTTPServer.java
+++ b/apps/i2ptunnel/java/src/net/i2p/i2ptunnel/localServer/LocalHTTPServer.java
@@ -5,6 +5,7 @@ package net.i2p.i2ptunnel.localServer;
import java.io.File;
import java.io.IOException;
+import java.io.InputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Map;
@@ -124,32 +125,30 @@ public abstract class LocalHTTPServer {
if ((method.equals("GET") || method.equals("HEAD")) &&
targetRequest.startsWith("/themes/") &&
!targetRequest.contains("..")) {
- String filename = null;
- try {
- filename = targetRequest.substring(8); // "/themes/".length
- } catch (IndexOutOfBoundsException ioobe) {
- return;
- }
+ String filename = targetRequest.substring(1);
// theme hack
- if (filename.startsWith("console/default/"))
+ if (filename.startsWith("themes/console/default/"))
filename = filename.replaceFirst("default", context.getProperty("routerconsole.theme", "light"));
- File themesDir = new File(context.getBaseDir(), "docs/themes");
- File file = new File(themesDir, filename);
- if (file.exists() && !file.isDirectory()) {
- String type;
- if (filename.endsWith(".css"))
- type = "text/css";
- else if (filename.endsWith(".ico"))
- type = "image/x-icon";
- else if (filename.endsWith(".png"))
- type = "image/png";
- else if (filename.endsWith(".jpg"))
- type = "image/jpeg";
- else type = "text/html";
- out.write("HTTP/1.1 200 OK\r\nContent-Type: ".getBytes("UTF-8"));
- out.write(type.getBytes("UTF-8"));
- out.write("\r\nCache-Control: max-age=86400\r\nConnection: close\r\nProxy-Connection: close\r\n\r\n".getBytes("UTF-8"));
- FileUtil.readFile(filename, themesDir.getAbsolutePath(), out);
+ InputStream in = getResource(filename);
+ if (in != null) {
+ try {
+ String type;
+ if (filename.endsWith(".css"))
+ type = "text/css";
+ else if (filename.endsWith(".ico"))
+ type = "image/x-icon";
+ else if (filename.endsWith(".png"))
+ type = "image/png";
+ else if (filename.endsWith(".jpg"))
+ type = "image/jpeg";
+ else type = "text/html";
+ out.write("HTTP/1.1 200 OK\r\nContent-Type: ".getBytes("UTF-8"));
+ out.write(type.getBytes("UTF-8"));
+ out.write("\r\nCache-Control: max-age=86400\r\nConnection: close\r\nProxy-Connection: close\r\n\r\n".getBytes("UTF-8"));
+ DataHelper.copy(in, out);
+ } finally {
+ try { in.close(); } catch (IOException ioe) {}
+ }
return;
}
}
@@ -483,6 +482,15 @@ public abstract class LocalHTTPServer {
return buf.toString();
}
+ /**
+ * @param resource relative path
+ * @return stream or null if not found
+ * @since 0.9.49
+ */
+ public static InputStream getResource(String resource) {
+ return LocalHTTPServer.class.getResourceAsStream("/net/i2p/i2ptunnel/resources/" + resource);
+ }
+
/** these strings go in the jar, not the war */
private static final String BUNDLE_NAME = "net.i2p.i2ptunnel.proxy.messages";
diff --git a/installer/resources/proxy/README.txt b/apps/i2ptunnel/resources/proxy/README.txt
similarity index 100%
rename from installer/resources/proxy/README.txt
rename to apps/i2ptunnel/resources/proxy/README.txt
diff --git a/installer/resources/proxy/ahelper-conflict-header.ht b/apps/i2ptunnel/resources/proxy/ahelper-conflict-header.ht
similarity index 100%
rename from installer/resources/proxy/ahelper-conflict-header.ht
rename to apps/i2ptunnel/resources/proxy/ahelper-conflict-header.ht
diff --git a/installer/resources/proxy/ahelper-new-header.ht b/apps/i2ptunnel/resources/proxy/ahelper-new-header.ht
similarity index 100%
rename from installer/resources/proxy/ahelper-new-header.ht
rename to apps/i2ptunnel/resources/proxy/ahelper-new-header.ht
diff --git a/installer/resources/proxy/ahelper-notfound-header.ht b/apps/i2ptunnel/resources/proxy/ahelper-notfound-header.ht
similarity index 100%
rename from installer/resources/proxy/ahelper-notfound-header.ht
rename to apps/i2ptunnel/resources/proxy/ahelper-notfound-header.ht
diff --git a/installer/resources/proxy/auth-header.ht b/apps/i2ptunnel/resources/proxy/auth-header.ht
similarity index 100%
rename from installer/resources/proxy/auth-header.ht
rename to apps/i2ptunnel/resources/proxy/auth-header.ht
diff --git a/installer/resources/proxy/b32-auth-header.ht b/apps/i2ptunnel/resources/proxy/b32-auth-header.ht
similarity index 100%
rename from installer/resources/proxy/b32-auth-header.ht
rename to apps/i2ptunnel/resources/proxy/b32-auth-header.ht
diff --git a/installer/resources/proxy/b32-header.ht b/apps/i2ptunnel/resources/proxy/b32-header.ht
similarity index 100%
rename from installer/resources/proxy/b32-header.ht
rename to apps/i2ptunnel/resources/proxy/b32-header.ht
diff --git a/installer/resources/proxy/baduri-header.ht b/apps/i2ptunnel/resources/proxy/baduri-header.ht
similarity index 100%
rename from installer/resources/proxy/baduri-header.ht
rename to apps/i2ptunnel/resources/proxy/baduri-header.ht
diff --git a/installer/resources/proxy/denied-header.ht b/apps/i2ptunnel/resources/proxy/denied-header.ht
similarity index 100%
rename from installer/resources/proxy/denied-header.ht
rename to apps/i2ptunnel/resources/proxy/denied-header.ht
diff --git a/installer/resources/proxy/dnf-header.ht b/apps/i2ptunnel/resources/proxy/dnf-header.ht
similarity index 100%
rename from installer/resources/proxy/dnf-header.ht
rename to apps/i2ptunnel/resources/proxy/dnf-header.ht
diff --git a/installer/resources/proxy/dnfb-header.ht b/apps/i2ptunnel/resources/proxy/dnfb-header.ht
similarity index 100%
rename from installer/resources/proxy/dnfb-header.ht
rename to apps/i2ptunnel/resources/proxy/dnfb-header.ht
diff --git a/installer/resources/proxy/dnfh-header.ht b/apps/i2ptunnel/resources/proxy/dnfh-header.ht
similarity index 100%
rename from installer/resources/proxy/dnfh-header.ht
rename to apps/i2ptunnel/resources/proxy/dnfh-header.ht
diff --git a/installer/resources/proxy/dnfp-header.ht b/apps/i2ptunnel/resources/proxy/dnfp-header.ht
similarity index 100%
rename from installer/resources/proxy/dnfp-header.ht
rename to apps/i2ptunnel/resources/proxy/dnfp-header.ht
diff --git a/installer/resources/proxy/enc-header.ht b/apps/i2ptunnel/resources/proxy/enc-header.ht
similarity index 100%
rename from installer/resources/proxy/enc-header.ht
rename to apps/i2ptunnel/resources/proxy/enc-header.ht
diff --git a/installer/resources/proxy/encp-header.ht b/apps/i2ptunnel/resources/proxy/encp-header.ht
similarity index 100%
rename from installer/resources/proxy/encp-header.ht
rename to apps/i2ptunnel/resources/proxy/encp-header.ht
diff --git a/installer/resources/proxy/localhost-header.ht b/apps/i2ptunnel/resources/proxy/localhost-header.ht
similarity index 100%
rename from installer/resources/proxy/localhost-header.ht
rename to apps/i2ptunnel/resources/proxy/localhost-header.ht
diff --git a/installer/resources/proxy/nols-header.ht b/apps/i2ptunnel/resources/proxy/nols-header.ht
similarity index 100%
rename from installer/resources/proxy/nols-header.ht
rename to apps/i2ptunnel/resources/proxy/nols-header.ht
diff --git a/installer/resources/proxy/nolsp-header.ht b/apps/i2ptunnel/resources/proxy/nolsp-header.ht
similarity index 100%
rename from installer/resources/proxy/nolsp-header.ht
rename to apps/i2ptunnel/resources/proxy/nolsp-header.ht
diff --git a/installer/resources/proxy/noproxy-header.ht b/apps/i2ptunnel/resources/proxy/noproxy-header.ht
similarity index 100%
rename from installer/resources/proxy/noproxy-header.ht
rename to apps/i2ptunnel/resources/proxy/noproxy-header.ht
diff --git a/installer/resources/proxy/protocol-header.ht b/apps/i2ptunnel/resources/proxy/protocol-header.ht
similarity index 100%
rename from installer/resources/proxy/protocol-header.ht
rename to apps/i2ptunnel/resources/proxy/protocol-header.ht
diff --git a/installer/resources/proxy/reset-header.ht b/apps/i2ptunnel/resources/proxy/reset-header.ht
similarity index 100%
rename from installer/resources/proxy/reset-header.ht
rename to apps/i2ptunnel/resources/proxy/reset-header.ht
diff --git a/installer/resources/proxy/resetp-header.ht b/apps/i2ptunnel/resources/proxy/resetp-header.ht
similarity index 100%
rename from installer/resources/proxy/resetp-header.ht
rename to apps/i2ptunnel/resources/proxy/resetp-header.ht
diff --git a/build.xml b/build.xml
index dd24907b9..86d19bfb1 100644
--- a/build.xml
+++ b/build.xml
@@ -1659,11 +1659,10 @@
-
+
-
-
-
-