2006-02-25 jrandom

* Made the Syndie permalinks in the thread view point to the blog view
    * Disabled TCP again (since the live net seems to be doing well w/out it)
    * Fix the message time on inbound SSU establishment (thanks zzz!)
    * Don't be so aggressive with parallel tunnel creation when a tunnel pool
      just starts up
This commit is contained in:
jrandom
2006-02-25 20:41:51 +00:00
committed by zzz
parent 7b2a435aad
commit 62b7cf64da
10 changed files with 95 additions and 44 deletions

View File

@ -34,7 +34,9 @@ public class BlogRenderer extends HTMLRenderer {
}
public void receiveHeaderEnd() {
_preBodyBuffer.append("<div class=\"syndieBlogPost\"><hr style=\"display: none\" />\n");
_preBodyBuffer.append("<div class=\"syndieBlogPost\" id=\"");
_preBodyBuffer.append(_entry.getURI().getKeyHash().toBase64()).append('/').append(_entry.getURI().getEntryId());
_preBodyBuffer.append("\"><hr style=\"display: none\" />\n");
_preBodyBuffer.append("<div class=\"syndieBlogPostHeader\">\n");
_preBodyBuffer.append("<div class=\"syndieBlogPostSubject\">");
String subject = (String)_headers.get(HEADER_SUBJECT);
@ -160,12 +162,24 @@ public class BlogRenderer extends HTMLRenderer {
protected String getEntryURL(boolean showImages) {
return getEntryURL(_entry, _blog, showImages);
}
static String getEntryURL(EntryContainer entry, BlogInfo blog, boolean showImages) {
static String getEntryURL(EntryContainer entry, BlogInfo blog, boolean showImages) {
if (entry == null) return "unknown";
return "blog.jsp?"
+ ViewBlogServlet.PARAM_BLOG + "=" + (blog != null ? blog.getKey().calculateHash().toBase64() : "") + "&amp;"
+ ViewBlogServlet.PARAM_ENTRY + "="
+ Base64.encode(entry.getURI().getKeyHash().getData()) + '/' + entry.getURI().getEntryId();
return getEntryURL(entry.getURI(), blog, null, showImages);
}
static String getEntryURL(BlogURI entry, BlogInfo blog, BlogURI comment, boolean showImages) {
if (entry == null) return "unknown";
if (comment == null) {
return "blog.jsp?"
+ ViewBlogServlet.PARAM_BLOG + "=" + (blog != null ? blog.getKey().calculateHash().toBase64() : "") + "&amp;"
+ ViewBlogServlet.PARAM_ENTRY + "="
+ Base64.encode(entry.getKeyHash().getData()) + '/' + entry.getEntryId();
} else {
return "blog.jsp?"
+ ViewBlogServlet.PARAM_BLOG + "=" + (blog != null ? blog.getKey().calculateHash().toBase64() : "") + "&amp;"
+ ViewBlogServlet.PARAM_ENTRY + "="
+ Base64.encode(entry.getKeyHash().getData()) + '/' + entry.getEntryId()
+ '#' + Base64.encode(comment.getKeyHash().getData()) + '/' + comment.getEntryId();
}
}
protected String getAttachmentURLBase() {
@ -218,4 +232,4 @@ public class BlogRenderer extends HTMLRenderer {
buf.append(ViewBlogServlet.PARAM_OFFSET).append('=').append(pageNum*numPerPage).append("&amp;");
return buf.toString();
}
}
}

View File

@ -122,36 +122,52 @@ public class ThreadedHTMLRenderer extends HTMLRenderer {
public static String getViewPostLink(String uri, ThreadNode node, User user, boolean isPermalink,
String offset, String tags, String author, boolean authorOnly) {
StringBuffer buf = new StringBuffer(64);
buf.append(uri);
if (node.getChildCount() > 0) {
buf.append('?').append(PARAM_VISIBLE).append('=');
ThreadNode child = node.getChild(0);
buf.append(child.getEntry().getKeyHash().toBase64()).append('/');
buf.append(child.getEntry().getEntryId()).append('&');
if (isPermalink) {
// link to the blog view of the original poster
BlogURI rootBlog = null;
ThreadNode parent = node;
while (parent != null) {
if (parent.getParent() != null) {
parent = parent.getParent();
} else {
rootBlog = parent.getEntry();
break;
}
}
BlogInfo root = BlogManager.instance().getArchive().getBlogInfo(rootBlog.getKeyHash());
return BlogRenderer.getEntryURL(parent.getEntry(), root, node.getEntry(), true);
} else {
buf.append('?').append(PARAM_VISIBLE).append('=');
StringBuffer buf = new StringBuffer(64);
buf.append(uri);
if (node.getChildCount() > 0) {
buf.append('?').append(PARAM_VISIBLE).append('=');
ThreadNode child = node.getChild(0);
buf.append(child.getEntry().getKeyHash().toBase64()).append('/');
buf.append(child.getEntry().getEntryId()).append('&');
} else {
buf.append('?').append(PARAM_VISIBLE).append('=');
buf.append(node.getEntry().getKeyHash().toBase64()).append('/');
buf.append(node.getEntry().getEntryId()).append('&');
}
buf.append(PARAM_VIEW_POST).append('=');
buf.append(node.getEntry().getKeyHash().toBase64()).append('/');
buf.append(node.getEntry().getEntryId()).append('&');
if (!isPermalink) {
if (!empty(offset))
buf.append(PARAM_OFFSET).append('=').append(offset).append('&');
if (!empty(tags))
buf.append(PARAM_TAGS).append('=').append(tags).append('&');
}
if (authorOnly && !empty(author)) {
buf.append(PARAM_AUTHOR).append('=').append(author).append('&');
buf.append(PARAM_THREAD_AUTHOR).append("=true&");
} else if (!isPermalink && !empty(author))
buf.append(PARAM_AUTHOR).append('=').append(author).append('&');
return buf.toString();
}
buf.append(PARAM_VIEW_POST).append('=');
buf.append(node.getEntry().getKeyHash().toBase64()).append('/');
buf.append(node.getEntry().getEntryId()).append('&');
if (!isPermalink) {
if (!empty(offset))
buf.append(PARAM_OFFSET).append('=').append(offset).append('&');
if (!empty(tags))
buf.append(PARAM_TAGS).append('=').append(tags).append('&');
}
if (authorOnly && !empty(author)) {
buf.append(PARAM_AUTHOR).append('=').append(author).append('&');
buf.append(PARAM_THREAD_AUTHOR).append("=true&");
} else if (!isPermalink && !empty(author))
buf.append(PARAM_AUTHOR).append('=').append(author).append('&');
return buf.toString();
}
public static String getViewPostLink(String uri, BlogURI post, User user, boolean isPermalink,
@ -272,8 +288,7 @@ public class ThreadedHTMLRenderer extends HTMLRenderer {
out.write("\n<a href=\"");
out.write(getViewPostLink(baseURI, node, user, true, offset, requestTags, filteredAuthor, authorOnly));
out.write("\" title=\"Select a shareable link directly to this post\">permalink</a>\n");
out.write("\" title=\"Select a link directly to this post within the blog\">permalink</a>\n");
if (true || (!inlineReply) ) {
String refuseReply = (String)_headers.get(HEADER_REFUSE_REPLIES);

View File

@ -1,4 +1,11 @@
$Id: history.txt,v 1.418 2006/02/23 09:38:41 jrandom Exp $
$Id: history.txt,v 1.419 2006/02/24 04:35:52 jrandom Exp $
2006-02-25 jrandom
* Made the Syndie permalinks in the thread view point to the blog view
* Disabled TCP again (since the live net seems to be doing well w/out it)
* Fix the message time on inbound SSU establishment (thanks zzz!)
* Don't be so aggressive with parallel tunnel creation when a tunnel pool
just starts up
2006-02-24 jrandom
* Rounding calculation cleanup in the stats, and avoid an uncontested

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
*
*/
public class RouterVersion {
public final static String ID = "$Revision: 1.359 $ $Date: 2006/02/23 09:38:40 $";
public final static String ID = "$Revision: 1.360 $ $Date: 2006/02/24 04:35:52 $";
public final static String VERSION = "0.6.1.11";
public final static long BUILD = 4;
public final static long BUILD = 5;
public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
System.out.println("Router ID: " + RouterVersion.ID);

View File

@ -56,7 +56,7 @@ public class TransportManager implements TransportEventListener {
transport.setListener(null);
}
static final boolean ALLOW_TCP = true;
static final boolean ALLOW_TCP = false;
private void configTransports() {
String disableTCP = _context.router().getConfigSetting(PROP_DISABLE_TCP);

View File

@ -456,7 +456,7 @@ public class EstablishmentManager {
_log.info("Completing to the peer after confirm: " + peer);
DeliveryStatusMessage dsm = new DeliveryStatusMessage(_context);
dsm.setArrival(Router.NETWORK_ID); // overloaded, sure, but future versions can check this
dsm.setMessageExpiration(dsm.getArrival()+10*1000);
dsm.setMessageExpiration(_context.clock().now()+10*1000);
dsm.setMessageId(_context.random().nextLong(I2NPMessage.MAX_ID_VALUE));
_transport.send(dsm, peer);
}

View File

@ -212,7 +212,7 @@ public class PeerState {
private static final int LARGE_MTU = 1350;
private static final int MIN_RTO = 100 + ACKSender.ACK_FREQUENCY;
private static final int MAX_RTO = 2000; // 5000;
private static final int MAX_RTO = 3000; // 5000;
/** override the default MTU */
private static final String PROP_DEFAULT_MTU = "i2np.udp.mtu";

View File

@ -101,6 +101,7 @@ public class UDPPacket {
_isInbound = inbound;
_initializeTime = _context.clock().now();
_markedType = -1;
_validateCount = 0;
_remoteHost = null;
_released = false;
}

View File

@ -162,7 +162,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
_context.statManager().createRateStat("udp.addressTestInsteadOfUpdate", "How many times we fire off a peer test of ourselves instead of adjusting our own reachable address?", "udp", new long[] { 1*60*1000, 20*60*1000, 60*60*1000, 24*60*60*1000 });
_context.statManager().createRateStat("udp.addressUpdated", "How many times we adjust our own reachable IP address", "udp", new long[] { 1*60*1000, 20*60*1000, 60*60*1000, 24*60*60*1000 });
_context.statManager().createRateStat("udp.proactiveReestablish", "How long a session was idle for when we proactively reestablished it", "udp", new long[] { 1*60*1000, 20*60*1000, 60*60*1000, 24*60*60*1000 });
_context.statManager().createRateStat("udp.dropPeerDroplist", "How many peers currently have their packets dropped outright when a new peer is added to the list?", "udp", new long[] { 1*60*1000, 20*60*1000 });
__instance = this;
}
@ -584,6 +584,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
if (peer != null) {
RemoteHostId remote = peer.getRemoteHostId();
boolean added = false;
int droplistSize = 0;
synchronized (_dropList) {
if (!_dropList.contains(remote)) {
while (_dropList.size() > MAX_DROPLIST_SIZE)
@ -591,8 +592,12 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
_dropList.add(remote);
added = true;
}
droplistSize = _dropList.size();
}
if (added) {
_context.statManager().addRateData("udp.dropPeerDroplist", droplistSize, 0);
SimpleTimer.getInstance().addEvent(new RemoveDropList(remote), DROPLIST_PERIOD);
}
if (added) SimpleTimer.getInstance().addEvent(new RemoveDropList(remote), DROPLIST_PERIOD);
}
_context.shitlist().shitlistRouter(peerHash, "Part of the wrong network");
dropPeer(peerHash);

View File

@ -33,6 +33,7 @@ public class TunnelPool {
private TunnelInfo _lastSelected;
private long _lastSelectionPeriod;
private int _expireSkew;
private long _started;
public TunnelPool(RouterContext ctx, TunnelPoolManager mgr, TunnelPoolSettings settings, TunnelPeerSelector sel) {
_context = ctx;
@ -46,11 +47,13 @@ public class TunnelPool {
_lastSelected = null;
_lifetimeProcessed = 0;
_expireSkew = _context.random().nextInt(90*1000);
_started = System.currentTimeMillis();
refreshSettings();
}
public void startup() {
_alive = true;
_started = System.currentTimeMillis();
_manager.getExecutor().repoll();
if (_settings.isInbound() && (_settings.getDestination() != null) ) {
// we just reconnected and didn't require any new tunnel builders.
@ -101,6 +104,8 @@ public class TunnelPool {
return period;
}
private long getLifetime() { return System.currentTimeMillis() - _started; }
/**
* Pull a random tunnel out of the pool. If there are none available but
* the pool is configured to allow 0hop tunnels, this builds a fake one
@ -555,12 +560,16 @@ public class TunnelPool {
if (rv + inProgress + expireLater + fallback > 4*standardAmount)
rv = 4*standardAmount - inProgress - expireLater - fallback;
long lifetime = getLifetime();
if ( (lifetime < 60*1000) && (rv + inProgress + fallback >= standardAmount) )
rv = standardAmount - inProgress - fallback;
if (_log.shouldLog(Log.DEBUG))
_log.debug("Count: rv: " + rv + " allow? " + allowZeroHop
+ " 30s " + expire30s + " 90s " + expire90s + " 150s " + expire150s + " 210s " + expire210s
+ " 270s " + expire270s + " later " + expireLater
+ " std " + standardAmount + " inProgress " + inProgress + " fallback " + fallback
+ " for " + toString());
+ " for " + toString() + " up for " + lifetime);
if (rv < 0)
return 0;