cache b64 dest strings
help typo fix (thx duck)
lots of seedless fixes
build cleanups
This commit is contained in:
zzz
2010-03-24 03:01:38 +00:00
parent 35961ea642
commit 902377b92a
6 changed files with 51 additions and 32 deletions

View File

@@ -11,7 +11,7 @@
<delete file="plugin/i2ptunnel.config" />
<!-- get version number -->
<buildnumber file="scripts/build.number" />
<property name="release.number" value="0.1" />
<property name="release.number" value="0.2" />
<!-- make the update xpi2p -->
<!-- this contains everything except i2ptunnel.config -->

View File

@@ -8,7 +8,7 @@ A new eepsite tunnel and Jetty server have been started for your open tracker.
This link is also at the top of your router console when ZzzOT is running.
<p>Report bugs or add comments on
<a href="htp://zzz.i2p//forums/16">the plugin forum on zzz.i2p</a>.
<a href="http://zzz.i2p//forums/16">the plugin forum on zzz.i2p</a>.
<h3>Eepsite Key and Helpful Hints for I2P</h3>

View File

@@ -145,6 +145,10 @@
<Arg>/Seedless/index.jsp</Arg>
<Arg>/tracker/seedless.jsp</Arg>
</Call>
<Call name="addForward">
<Arg>/Seedless/seedless</Arg>
<Arg>/tracker/seedless.jsp</Arg>
</Call>
</New>
</Arg>
</Call>

View File

@@ -24,27 +24,10 @@
<target name="build" depends="jar, war" />
<target name="builddep">
</target>
<condition property="depend.available">
<typefound name="depend" />
</condition>
<target name="depend" if="depend.available">
<depend
cache="build"
srcdir="./src"
destdir="./build/obj" >
<!-- Depend on classes instead of jars where available -->
<classpath>
<pathelement location="../../../core/java/build/obj" />
<pathelement location="../../ministreaming/java/build/obj" />
<pathelement location="../../jetty/jettylib/org.mortbay.jetty.jar" />
<pathelement location="../../jetty/jettylib/javax.servlet.jar" />
</classpath>
</depend>
</target>
<property name="javac.compilerargs" value="" />
<target name="compile" depends="depend">
<target name="compile">
<mkdir dir="./build" />
<mkdir dir="./build/obj" />
<javac

View File

@@ -18,8 +18,11 @@ package net.i2p.zzzot;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import net.i2p.data.Destination;
import net.i2p.util.SimpleScheduler;
import net.i2p.util.SimpleTimer;
/*
* A single peer for a single torrent.
@@ -32,15 +35,26 @@ public class Peer extends HashMap<String, Object> {
private long lastSeen;
private long bytesLeft;
private static final ConcurrentHashMap<String, String> destCache = new ConcurrentHashMap();
private static final Integer PORT = Integer.valueOf(6881);
private static final long CLEAN_TIME = 3*60*60*1000;
static {
SimpleScheduler.getInstance().addPeriodicEvent(new Cleaner(), CLEAN_TIME);
}
public Peer(byte[] id, Destination address) {
super(3);
if (id.length != 20)
throw new IllegalArgumentException("Bad peer ID length: " + id.length);
put("peer id", id);
put("ip", address.toBase64() + ".i2p");
put("port", PORT);
// cache the 520-byte address strings
String dest = address.toBase64() + ".i2p";
String oldDest = destCache.putIfAbsent(dest, dest);
if (oldDest != null)
dest = oldDest;
put("ip", dest);
}
public void setLeft(long l) {
@@ -55,4 +69,10 @@ public class Peer extends HashMap<String, Object> {
public long lastSeen() {
return lastSeen;
}
private static class Cleaner implements SimpleTimer.TimedEvent {
public void timeReached() {
destCache.clear();
}
}
}

View File

@@ -1,4 +1,4 @@
<%@page import="net.i2p.crypto.SHA256Generator" %><%@page import="net.i2p.data.Base32" %><%@page import="net.i2p.data.Base64" %><%@page import="net.i2p.zzzot.*" %><%
<%@page import="net.i2p.crypto.SHA256Generator" %><%@page import="net.i2p.data.Base32" %><%@page import="net.i2p.data.Base64" %><%@page import="net.i2p.data.DataHelper" %><%@page import="net.i2p.zzzot.*" %><%
/*
* Copyright 2010 zzz (zzz@mail.i2p)
@@ -18,7 +18,13 @@
*/
String req = request.getHeader("X-Seedless");
// extension for ease of eepget and browser
if (req == null)
req = request.getParameter("X-Seedless");
// we should really put in our own b32
String me = request.getHeader("Host");
if (me == null)
me = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.b32.i2p";
// unused, we don't accept announces
String him = request.getHeader("X-I2P-DestB32");
String xff = request.getHeader("X-Forwarded-For");
@@ -34,13 +40,18 @@
response.setStatus(403, msg);
out.println(msg);
} else if (req == null) {
out.println("seedless server");
} else if (req.startsWith("announce ")) {
out.println("");
} else if (req.startsWith("locate ") && me != null) {
// probe
out.println("tracker " + US_MINUTES);
out.println("eepsite " + US_MINUTES);
out.println("seedless " + US_MINUTES);
} else if (req.startsWith("announce")) {
out.println("thanks");
} else if (req.startsWith("locate")) {
// ignore the search string, if any, in the request
// us
out.println(Base64.encode(me + ' ' + US_MINUTES + " bt-tracker"));
out.println(Base64.encode(me + ' ' + US_MINUTES + " tracker"));
out.println(Base64.encode(me + ' ' + US_MINUTES + " seedless"));
out.println(Base64.encode(me + ' ' + US_MINUTES + " eepsite"));
// all the peers
Torrents torrents = ZzzOTController.getTorrents();
for (InfoHash ihash : torrents.keySet()) {
@@ -59,16 +70,17 @@
role = " bt-seed";
else
role = " bt-leech";
// spg wants UTF-8 but all we have is binary data, sorry
String ihs = new String(ihash.getData(), "ISO-8859-1");
String ids = new String((byte[])p.get("peer id"), "ISO-8859-1");
// spg wants UTF-8 but all we have is binary data, so hex it
String ihs = DataHelper.toHexString(ihash.getData());
String ids = DataHelper.toHexString((byte[])p.get("peer id"));
out.println(Base64.encode(b32 + PEER_MINUTES + role +
" info_hash=" + ihs +
" peer_id=" + ids));
";peer_id=" + ids));
}
}
} else {
out.println("2");
// error code
out.println("SC_NOT_ACCEPTABLE");
}
%>