2005-05-01 00:48:15 +00:00
|
|
|
package net.i2p.router.web;
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.Writer;
|
|
|
|
|
|
|
|
import net.i2p.router.RouterContext;
|
|
|
|
|
|
|
|
public class PeerHelper {
|
|
|
|
private RouterContext _context;
|
|
|
|
private Writer _out;
|
2006-05-18 03:00:48 +00:00
|
|
|
private int _sortFlags;
|
|
|
|
private String _urlBase;
|
2005-05-01 00:48:15 +00:00
|
|
|
/**
|
|
|
|
* Configure this bean to query a particular router context
|
|
|
|
*
|
|
|
|
* @param contextId begging few characters of the routerHash, or null to pick
|
|
|
|
* the first one we come across.
|
|
|
|
*/
|
|
|
|
public void setContextId(String contextId) {
|
|
|
|
try {
|
|
|
|
_context = ContextHelper.getContext(contextId);
|
|
|
|
} catch (Throwable t) {
|
|
|
|
t.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public PeerHelper() {}
|
|
|
|
|
|
|
|
public void setOut(Writer out) { _out = out; }
|
2006-05-18 03:00:48 +00:00
|
|
|
public void setSort(String flags) {
|
|
|
|
if (flags != null) {
|
|
|
|
try {
|
|
|
|
_sortFlags = Integer.parseInt(flags);
|
|
|
|
} catch (NumberFormatException nfe) {
|
|
|
|
_sortFlags = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_sortFlags = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public void setUrlBase(String base) { _urlBase = base; }
|
2005-05-01 00:48:15 +00:00
|
|
|
|
|
|
|
public String getPeerSummary() {
|
|
|
|
try {
|
2006-05-18 03:00:48 +00:00
|
|
|
_context.commSystem().renderStatusHTML(_out, _urlBase, _sortFlags);
|
2005-10-29 21:35:24 +00:00
|
|
|
_context.bandwidthLimiter().renderStatusHTML(_out);
|
2005-05-01 00:48:15 +00:00
|
|
|
} catch (IOException ioe) {
|
|
|
|
ioe.printStackTrace();
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|