propagate from branch 'i2p.i2p.zzz.test3' (head d4461db52b7de97b89dafa6d6a2b18d9dc075b38)

to branch 'i2p.i2p' (head 5529edcb3dd730aa750302bb4267116c56c354da)
This commit is contained in:
zzz
2009-07-06 13:09:05 +00:00
206 changed files with 492 additions and 416 deletions

View File

@ -140,7 +140,7 @@ public class BitField
public String toString()
{
// Not very efficient
StringBuffer sb = new StringBuffer("BitField(");
StringBuilder sb = new StringBuilder("BitField(");
sb.append(size).append(")[");
for (int i = 0; i < size; i++)
if (get(i))

View File

@ -362,7 +362,7 @@ public class MetaInfo
*/
private static String hexencode(byte[] bs)
{
StringBuffer sb = new StringBuffer(bs.length*2);
StringBuilder sb = new StringBuilder(bs.length*2);
for (int i = 0; i < bs.length; i++)
{
int c = bs[i] & 0xFF;
@ -432,7 +432,7 @@ public class MetaInfo
private byte[] calculateInfoHash()
{
Map info = createInfoMap();
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
buf.append("info: ");
for (Iterator iter = info.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry)iter.next();

View File

@ -190,7 +190,7 @@ public class PeerID implements Comparable
{
boolean leading_zeros = true;
StringBuffer sb = new StringBuffer(bs.length*2);
StringBuilder sb = new StringBuilder(bs.length*2);
for (int i = 0; i < bs.length; i++)
{
int c = bs[i] & 0xFF;

View File

@ -702,7 +702,7 @@ public class SnarkManager implements Snark.CompleteListener {
// , "mastertracker", "http://VzXD~stRKbL3MOmeTn1iaCQ0CFyTmuFHiKYyo0Rd~dFPZFCYH-22rT8JD7i-C2xzYFa4jT5U2aqHzHI-Jre4HL3Ri5hFtZrLk2ax3ji7Qfb6qPnuYkuiF2E2UDmKUOppI8d9Ye7tjdhQVCy0izn55tBaB-U7UWdcvSK2i85sauyw3G0Gfads1Rvy5-CAe2paqyYATcDmGjpUNLoxbfv9KH1KmwRTNH6k1v4PyWYYnhbT39WfKMbBjSxVQRdi19cyJrULSWhjxaQfJHeWx5Z8Ev4bSPByBeQBFl2~4vqy0S5RypINsRSa3MZdbiAAyn5tr5slWR6QdoqY3qBQgBJFZppy-3iWkFqqKgSxCPundF8gdDLC5ddizl~KYcYKl42y9SGFHIukH-TZs8~em0~iahzsqWVRks3zRG~tlBcX2U3M2~OJs~C33-NKhyfZT7-XFBREvb8Szmd~p66jDxrwOnKaku-G6DyoQipJqIz4VHmY9-y5T8RrUcJcM-5lVoMpAAAA.i2p/announce.php=http://tracker.mastertracker.i2p/"
// , "Galen", "http://5jpwQMI5FT303YwKa5Rd38PYSX04pbIKgTaKQsWbqoWjIfoancFdWCShXHLI5G5ofOb0Xu11vl2VEMyPsg1jUFYSVnu4-VfMe3y4TKTR6DTpetWrnmEK6m2UXh91J5DZJAKlgmO7UdsFlBkQfR2rY853-DfbJtQIFl91tbsmjcA5CGQi4VxMFyIkBzv-pCsuLQiZqOwWasTlnzey8GcDAPG1LDcvfflGV~6F5no9mnuisZPteZKlrv~~TDoXTj74QjByWc4EOYlwqK8sbU9aOvz~s31XzErbPTfwiawiaZ0RUI-IDrKgyvmj0neuFTWgjRGVTH8bz7cBZIc3viy6ioD-eMQOrXaQL0TCWZUelRwHRvgdPiQrxdYQs7ixkajeHzxi-Pq0EMm5Vbh3j3Q9kfUFW3JjFDA-MLB4g6XnjCbM5J1rC0oOBDCIEfhQkszru5cyLjHiZ5yeA0VThgu~c7xKHybv~OMXION7V8pBKOgET7ZgAkw1xgYe3Kkyq5syAAAA.i2p/tr/announce.php=http://galen.i2p/tr/"
, "crstrack", "http://b4G9sCdtfvccMAXh~SaZrPqVQNyGQbhbYMbw6supq2XGzbjU4NcOmjFI0vxQ8w1L05twmkOvg5QERcX6Mi8NQrWnR0stLExu2LucUXg1aYjnggxIR8TIOGygZVIMV3STKH4UQXD--wz0BUrqaLxPhrm2Eh9Hwc8TdB6Na4ShQUq5Xm8D4elzNUVdpM~RtChEyJWuQvoGAHY3ppX-EJJLkiSr1t77neS4Lc-KofMVmgI9a2tSSpNAagBiNI6Ak9L1T0F9uxeDfEG9bBSQPNMOSUbAoEcNxtt7xOW~cNOAyMyGydwPMnrQ5kIYPY8Pd3XudEko970vE0D6gO19yoBMJpKx6Dh50DGgybLQ9CpRaynh2zPULTHxm8rneOGRcQo8D3mE7FQ92m54~SvfjXjD2TwAVGI~ae~n9HDxt8uxOecAAvjjJ3TD4XM63Q9TmB38RmGNzNLDBQMEmJFpqQU8YeuhnS54IVdUoVQFqui5SfDeLXlSkh4vYoMU66pvBfWbAAAA.i2p/tracker/announce.php=http://crstrack.i2p/tracker/"
, "Postman2", "http://lnQ6yoBTxQuQU8EQ1FlF395ITIQF-HGJxUeFvzETLFnoczNjQvKDbtSB7aHhn853zjVXrJBgwlB9sO57KakBDaJ50lUZgVPhjlI19TgJ-CxyHhHSCeKx5JzURdEW-ucdONMynr-b2zwhsx8VQCJwCEkARvt21YkOyQDaB9IdV8aTAmP~PUJQxRwceaTMn96FcVenwdXqleE16fI8CVFOV18jbJKrhTOYpTtcZKV4l1wNYBDwKgwPx5c0kcrRzFyw5~bjuAKO~GJ5dR7BQsL7AwBoQUS4k1lwoYrG1kOIBeDD3XF8BWb6K3GOOoyjc1umYKpur3G~FxBuqtHAsDRICkEbKUqJ9mPYQlTSujhNxiRIW-oLwMtvayCFci99oX8MvazPS7~97x0Gsm-onEK1Td9nBdmq30OqDxpRtXBimbzkLbR1IKObbg9HvrKs3L-kSyGwTUmHG9rSQSoZEvFMA-S0EXO~o4g21q1oikmxPMhkeVwQ22VHB0-LZJfmLr4SAAAA.i2p/announce.php=http://tracker2.postman.i2p/"
, "Postman2", "http://tracker2.postman.i2p/announce.php=http://tracker2.postman.i2p/"
};
/** comma delimited list of name=announceURL=baseURL for the trackers to be displayed */

View File

@ -373,7 +373,7 @@ public class TrackerClient extends I2PAppThread
*/
public static String urlencode(byte[] bs)
{
StringBuffer sb = new StringBuffer(bs.length*3);
StringBuilder sb = new StringBuilder(bs.length*3);
for (int i = 0; i < bs.length; i++)
{
int c = bs[i] & 0xFF;

View File

@ -398,7 +398,7 @@ public class I2PSnarkServlet extends HttpServlet {
return rv;
}
private static final int MAX_DISPLAYED_FILENAME_LENGTH = 60;
private static final int MAX_DISPLAYED_FILENAME_LENGTH = 44;
private static final int MAX_DISPLAYED_ERROR_LENGTH = 40;
private void displaySnark(PrintWriter out, Snark snark, String uri, int row, long stats[], boolean showPeers, boolean showDebug) throws IOException {
String filename = snark.torrent;
@ -506,7 +506,7 @@ public class I2PSnarkServlet extends HttpServlet {
// temporarily hardcoded for postman* and anonymity, requires bytemonsoon patch for lookup by info_hash
String announce = snark.meta.getAnnounce();
if (announce.startsWith("http://YRgrgTLG") || announce.startsWith("http://8EoJZIKr") ||
announce.startsWith("http://lnQ6yoBT")) {
announce.startsWith("http://lnQ6yoBT") || announce.startsWith("http://tracker2.postman.i2p/")) {
Map trackers = _manager.getTrackers();
for (Iterator iter = trackers.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry)iter.next();
@ -759,7 +759,7 @@ public class I2PSnarkServlet extends HttpServlet {
+ _manager.util().getI2CPHost() + "\" size=\"15\" /> ");
out.write("port: <input type=\"text\" name=\"i2cpPort\" value=\"" +
+ _manager.util().getI2CPPort() + "\" size=\"5\" maxlength=\"5\" /> <br />\n");
StringBuffer opts = new StringBuffer(64);
StringBuilder opts = new StringBuilder(64);
Map options = new TreeMap(_manager.util().getI2CPOptions());
for (Iterator iter = options.entrySet().iterator(); iter.hasNext(); ) {
Map.Entry entry = (Map.Entry)iter.next();

View File

@ -179,7 +179,7 @@ public class I2PTunnelConnectClient extends I2PTunnelClientBase implements Runna
out = s.getOutputStream();
in = s.getInputStream();
String line, method = null, host = null, destination = null, restofline = null;
StringBuffer newRequest = new StringBuffer();
StringBuilder newRequest = new StringBuilder();
int ahelper = 0;
while (true) {
// Use this rather than BufferedReader because we can't have readahead,

View File

@ -240,7 +240,7 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
out = s.getOutputStream();
InputReader reader = new InputReader(s.getInputStream());
String line, method = null, protocol = null, host = null, destination = null;
StringBuffer newRequest = new StringBuffer();
StringBuilder newRequest = new StringBuilder();
int ahelper = 0;
while ((line = reader.readLine(method)) != null) {
line = line.trim();
@ -811,11 +811,14 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
* but inproxy/gateway ops would be wise to block proxy.i2p to prevent
* exposing the docs/ directory or perhaps other issues through
* uncaught vulnerabilities.
* Restrict to the /themes/ directory for now.
*
* @param targetRequest "proxy.i2p/foo.png HTTP/1.1"
* @param targetRequest "proxy.i2p/themes/foo.png HTTP/1.1"
*/
private static void serveLocalFile(OutputStream out, String method, String targetRequest) {
if (method.equals("GET") || method.equals("HEAD")) {
if ((method.equals("GET") || method.equals("HEAD")) &&
targetRequest.startsWith("proxy.i2p/themes/") &&
!targetRequest.contains("..")) {
int space = targetRequest.indexOf(' ');
String filename = null;
try {

View File

@ -74,7 +74,7 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
InputStream in = socket.getInputStream();
StringBuffer command = new StringBuffer(128);
StringBuilder command = new StringBuilder(128);
Properties headers = readHeaders(in, command);
headers.setProperty(HASH_HEADER, socket.getPeerDestination().calculateHash().toBase64());
headers.setProperty(DEST32_HEADER, Base32.encode(socket.getPeerDestination().calculateHash().getData()) + ".b32.i2p" );
@ -309,8 +309,8 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
}
}
private String formatHeaders(Properties headers, StringBuffer command) {
StringBuffer buf = new StringBuffer(command.length() + headers.size() * 64);
private String formatHeaders(Properties headers, StringBuilder command) {
StringBuilder buf = new StringBuilder(command.length() + headers.size() * 64);
buf.append(command.toString().trim()).append("\r\n");
for (Iterator iter = headers.keySet().iterator(); iter.hasNext(); ) {
String name = (String)iter.next();
@ -321,9 +321,9 @@ public class I2PTunnelHTTPServer extends I2PTunnelServer {
return buf.toString();
}
private Properties readHeaders(InputStream in, StringBuffer command) throws IOException {
private Properties readHeaders(InputStream in, StringBuilder command) throws IOException {
Properties headers = new Properties();
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
boolean ok = DataHelper.readLine(in, command);
if (!ok) throw new IOException("EOF reached while reading the HTTP command [" + command.toString() + "]");

View File

@ -82,7 +82,7 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase implements Runnable
try {
i2ps = createI2PSocket(dest);
i2ps.setReadTimeout(readTimeout);
StringBuffer expectedPong = new StringBuffer();
StringBuilder expectedPong = new StringBuilder();
Thread in = new I2PThread(new IrcInboundFilter(s,i2ps, expectedPong), "IRC Client " + __clientId + " in");
in.start();
Thread out = new I2PThread(new IrcOutboundFilter(s,i2ps, expectedPong), "IRC Client " + __clientId + " out");
@ -121,9 +121,9 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase implements Runnable
private Socket local;
private I2PSocket remote;
private StringBuffer expectedPong;
private StringBuilder expectedPong;
IrcInboundFilter(Socket _local, I2PSocket _remote, StringBuffer pong) {
IrcInboundFilter(Socket _local, I2PSocket _remote, StringBuilder pong) {
local=_local;
remote=_remote;
expectedPong=pong;
@ -195,9 +195,9 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase implements Runnable
private Socket local;
private I2PSocket remote;
private StringBuffer expectedPong;
private StringBuilder expectedPong;
IrcOutboundFilter(Socket _local, I2PSocket _remote, StringBuffer pong) {
IrcOutboundFilter(Socket _local, I2PSocket _remote, StringBuilder pong) {
local=_local;
remote=_remote;
expectedPong=pong;
@ -266,7 +266,7 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase implements Runnable
*
*/
public String inboundFilter(String s, StringBuffer expectedPong) {
public String inboundFilter(String s, StringBuilder expectedPong) {
String field[]=s.split(" ",4);
String command;
@ -353,7 +353,7 @@ public class I2PTunnelIRCClient extends I2PTunnelClientBase implements Runnable
return null;
}
public String outboundFilter(String s, StringBuffer expectedPong) {
public String outboundFilter(String s, StringBuilder expectedPong) {
String field[]=s.split(" ",3);
String command;

View File

@ -135,7 +135,7 @@ public class I2PTunnelIRCServer extends I2PTunnelServer implements Runnable {
/** keep reading until we see USER or SERVER */
private String filterRegistration(InputStream in, String newHostname) throws IOException {
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
int lineCount = 0;
while (true) {

View File

@ -211,7 +211,7 @@ public class I2Ping extends I2PTunnelTask implements Runnable {
int fail = 0;
long totalTime = 0;
int cnt = countPing ? CPING_COUNT : PING_COUNT;
StringBuffer pingResults = new StringBuffer(2 * cnt + destination.length() + 3);
StringBuilder pingResults = new StringBuilder(2 * cnt + destination.length() + 3);
for (int i = 0; i < cnt; i++) {
boolean sent;
sent = ping(dest);

View File

@ -385,7 +385,7 @@ public class TunnelController implements Logging {
public String getI2CPHost() { return _config.getProperty("i2cpHost"); }
public String getI2CPPort() { return _config.getProperty("i2cpPort"); }
public String getClientOptions() {
StringBuffer opts = new StringBuffer(64);
StringBuilder opts = new StringBuilder(64);
for (Iterator iter = _config.keySet().iterator(); iter.hasNext(); ) {
String key = (String)iter.next();
String val = _config.getProperty(key);
@ -447,7 +447,7 @@ public class TunnelController implements Logging {
return true;
}
public void getSummary(StringBuffer buf) {
public void getSummary(StringBuilder buf) {
String type = getType();
if ("httpclient".equals(type))
getHttpClientSummary(buf);
@ -461,7 +461,7 @@ public class TunnelController implements Logging {
buf.append("Unknown type ").append(type);
}
private void getHttpClientSummary(StringBuffer buf) {
private void getHttpClientSummary(StringBuilder buf) {
String description = getDescription();
if ( (description != null) && (description.trim().length() > 0) )
buf.append("<i>").append(description).append("</i><br />\n");
@ -482,7 +482,7 @@ public class TunnelController implements Logging {
getOptionSummary(buf);
}
private void getClientSummary(StringBuffer buf) {
private void getClientSummary(StringBuilder buf) {
String description = getDescription();
if ( (description != null) && (description.trim().length() > 0) )
buf.append("<i>").append(description).append("</i><br />\n");
@ -499,7 +499,7 @@ public class TunnelController implements Logging {
getOptionSummary(buf);
}
private void getServerSummary(StringBuffer buf) {
private void getServerSummary(StringBuilder buf) {
String description = getDescription();
if ( (description != null) && (description.trim().length() > 0) )
buf.append("<i>").append(description).append("</i><br />\n");
@ -510,7 +510,7 @@ public class TunnelController implements Logging {
getOptionSummary(buf);
}
private void getHttpServerSummary(StringBuffer buf) {
private void getHttpServerSummary(StringBuilder buf) {
String description = getDescription();
if ( (description != null) && (description.trim().length() > 0) )
buf.append("<i>").append(description).append("</i><br />\n");
@ -522,7 +522,7 @@ public class TunnelController implements Logging {
getOptionSummary(buf);
}
private void getOptionSummary(StringBuffer buf) {
private void getOptionSummary(StringBuilder buf) {
String opts = getClientOptions();
if ( (opts != null) && (opts.length() > 0) )
buf.append("Network options: ").append(opts).append("<br />\n");

View File

@ -245,7 +245,7 @@ public class TunnelControllerGroup {
map.putAll(cur);
}
StringBuffer buf = new StringBuffer(1024);
StringBuilder buf = new StringBuilder(1024);
for (Iterator iter = map.keySet().iterator(); iter.hasNext(); ) {
String key = (String)iter.next();
String val = (String)map.get(key);

View File

@ -123,7 +123,7 @@ public class SOCKS4aServer extends SOCKSServer {
}
private String readString(DataInputStream in) throws IOException {
StringBuffer sb = new StringBuffer(16);
StringBuilder sb = new StringBuilder(16);
char c;
while ((c = (char) (in.readByte() & 0xff)) != 0)
sb.append(c);

View File

@ -223,7 +223,7 @@ public class EditBean extends IndexBean {
if (tun != null) {
Properties opts = getOptions(tun);
if (opts == null) return "";
StringBuffer buf = new StringBuffer(64);
StringBuilder buf = new StringBuilder(64);
int i = 0;
for (Iterator iter = opts.keySet().iterator(); iter.hasNext(); ) {
String key = (String)iter.next();

View File

@ -302,7 +302,7 @@ public class IndexBean {
if (_group == null)
return "";
StringBuffer buf = new StringBuffer(512);
StringBuilder buf = new StringBuilder(512);
if (_action != null) {
try {
buf.append(processAction()).append("\n");
@ -927,11 +927,11 @@ public class IndexBean {
}
private String getMessages(List msgs) {
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
getMessages(msgs, buf);
return buf.toString();
}
private void getMessages(List msgs, StringBuffer buf) {
private void getMessages(List msgs, StringBuilder buf) {
if (msgs == null) return;
for (int i = 0; i < msgs.size(); i++) {
buf.append((String)msgs.get(i)).append("\n");

View File

@ -18,7 +18,7 @@
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
<% if (editBean.allowCSS()) {
%><link href="images/favicon.ico" type="image/x-icon" rel="shortcut icon" />
%><link href="/themes/console/images/favicon.ico" type="image/x-icon" rel="shortcut icon" />
<link href="<%=editBean.getTheme()%>default.css" rel="stylesheet" type="text/css" />
<link href="<%=editBean.getTheme()%>i2ptunnel.css" rel="stylesheet" type="text/css" />
<% }
@ -388,7 +388,7 @@
<label for="localDestination" accesskey="L">
<span class="accessKey">L</span>ocal destination:
</label>
<textarea rows="1" cols="60" readonly="readonly" id="localDestination" title="Read Only: Local Destination (if known)" wrap="off"><%=editBean.getDestinationBase64(curTunnel)%></textarea>
<textarea rows="1" style="height: 3em;" cols="60" readonly="readonly" id="localDestination" title="Read Only: Local Destination (if known)" wrap="off"><%=editBean.getDestinationBase64(curTunnel)%></textarea>
<span class="comment">(if known)</span>
</div>

View File

@ -18,7 +18,7 @@
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
<% if (editBean.allowCSS()) {
%><link href="images/favicon.ico" type="image/x-icon" rel="shortcut icon" />
%><link href="/themes/console/images/favicon.ico" type="image/x-icon" rel="shortcut icon" />
<link href="<%=editBean.getTheme()%>default.css" rel="stylesheet" type="text/css" />
<link href="<%=editBean.getTheme()%>i2ptunnel.css" rel="stylesheet" type="text/css" />
<% }
@ -148,7 +148,7 @@
<label for="localDestination" accesskey="L">
<span class="accessKey">L</span>ocal destination:
</label>
<textarea rows="1" cols="60" readonly="readonly" id="localDestination" title="Read Only: Local Destination (if known)" wrap="off"><%=editBean.getDestinationBase64(curTunnel)%></textarea>
<textarea rows="1" style="height: 3em;" cols="60" readonly="readonly" id="localDestination" title="Read Only: Local Destination (if known)" wrap="off"><%=editBean.getDestinationBase64(curTunnel)%></textarea>
<% if (!"".equals(editBean.getDestinationBase64(curTunnel))) { %>
<a href="/susidns/addressbook.jsp?book=private&hostname=<%=editBean.getTunnelName(curTunnel)%>&destination=<%=editBean.getDestinationBase64(curTunnel)%>#add">Add to local addressbook</a>
<% } %>
@ -270,7 +270,7 @@
<label for="encrypt" accesskey="e">
Encryption Key:
</label>
<textarea rows="1" cols="44" id="portField" name="encryptKey" title="Encrypt Key" wrap="off"><%=editBean.getEncryptKey(curTunnel)%></textarea>
<textarea rows="1" style="height: 3em;" cols="44" id="portField" name="encryptKey" title="Encrypt Key" wrap="off"><%=editBean.getEncryptKey(curTunnel)%></textarea>
</div>
<div id="portField" class="rowItem">
<label for="force" accesskey="c">
@ -299,7 +299,7 @@
<label for="accessList" accesskey="s">
Access List:
</label>
<textarea rows="2" cols="60" id="hostField" name="accessList" title="Access List" wrap="off"><%=editBean.getAccessList(curTunnel)%></textarea>
<textarea rows="2" style="height: 4em;" cols="60" id="hostField" name="accessList" title="Access List" wrap="off"><%=editBean.getAccessList(curTunnel)%></textarea>
<span class="comment">(Restrict to these clients only)</span>
</div>

View File

@ -10,7 +10,7 @@
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
<% if (indexBean.allowCSS()) {
%><link href="images/favicon.ico" type="image/x-icon" rel="shortcut icon" />
%><link href="/themes/console/images/favicon.ico" type="image/x-icon" rel="shortcut icon" />
<link href="<%=indexBean.getTheme()%>default.css" rel="stylesheet" type="text/css" />
<link href="<%=indexBean.getTheme()%>i2ptunnel.css" rel="stylesheet" type="text/css" />
<% }
@ -76,7 +76,7 @@
%>
<div class="nameField rowItem">
<label>Name:</label>
<span class="text"><a href="edit.jsp?tunnel=<%=curClient%>" title="Edit Tunnel Settings for <%=indexBean.getTunnelName(curClient)%>"><%=indexBean.getTunnelName(curClient)%></a></span>
<span class="text"><a href="edit.jsp?tunnel=<%=curClient%>" title="Edit Tunnel Settings for <%=indexBean.getTunnelName(curClient)%>"><%=indexBean.getTunnelName(curClient)%> (Edit)</a></span>
</div>
<div class="portField rowItem">
<label>Port:</label>
@ -192,7 +192,7 @@
%>
<div class="nameField rowItem">
<label>Name:</label>
<span class="text"><a href="edit.jsp?tunnel=<%=curServer%>" title="Edit Server Tunnel Settings for <%=indexBean.getTunnelName(curServer)%>"><%=indexBean.getTunnelName(curServer)%></a></span>
<span class="text"><a href="edit.jsp?tunnel=<%=curServer%>" title="Edit Server Tunnel Settings for <%=indexBean.getTunnelName(curServer)%>"><%=indexBean.getTunnelName(curServer)%> (Edit)</a></span>
</div>
<div class="previewField rowItem">
<label>Points at:</label>

View File

@ -88,7 +88,7 @@ public class I2PRequestLog extends NCSARequestLog
if (_fileOut==null)
return;
StringBuffer buf = new StringBuffer(160);
StringBuilder buf = new StringBuilder(160);
String addr = request.getField("X-I2P-DestHash");
if(addr != null)

View File

@ -10,7 +10,7 @@ public class ConfigAdvancedHelper extends HelperBase {
public ConfigAdvancedHelper() {}
public String getSettings() {
StringBuffer buf = new StringBuffer(4*1024);
StringBuilder buf = new StringBuilder(4*1024);
Set names = _context.router().getConfigSettings();
TreeSet sortedNames = new TreeSet(names);
for (Iterator iter = sortedNames.iterator(); iter.hasNext(); ) {

View File

@ -13,7 +13,7 @@ public class ConfigClientsHelper extends HelperBase {
public ConfigClientsHelper() {}
public String getForm1() {
StringBuffer buf = new StringBuffer(1024);
StringBuilder buf = new StringBuilder(1024);
buf.append("<table border=\"1\">\n");
buf.append("<tr><th>Client</th><th>Run at Startup?</th><th>Start Now</th><th>Class and arguments</th></tr>\n");
@ -29,7 +29,7 @@ public class ConfigClientsHelper extends HelperBase {
}
public String getForm2() {
StringBuffer buf = new StringBuffer(1024);
StringBuilder buf = new StringBuilder(1024);
buf.append("<table border=\"1\">\n");
buf.append("<tr><th>WebApp</th><th>Run at Startup?</th><th>Start Now</th><th>Description</th></tr>\n");
Properties props = RouterConsoleRunner.webAppProperties();
@ -46,7 +46,7 @@ public class ConfigClientsHelper extends HelperBase {
return buf.toString();
}
private void renderForm(StringBuffer buf, String index, String name, boolean urlify, boolean enabled, boolean ro, String desc) {
private void renderForm(StringBuilder buf, String index, String name, boolean urlify, boolean enabled, boolean ro, String desc) {
buf.append("<tr><td>");
if (urlify && enabled) {
String link = "/";

View File

@ -29,7 +29,7 @@ public class ConfigLoggingHelper extends HelperBase {
return (bytes/(1024)) + "k";
}
public String getLogLevelTable() {
StringBuffer buf = new StringBuffer(32*1024);
StringBuilder buf = new StringBuilder(32*1024);
Properties limits = _context.logManager().getLimits();
TreeSet sortedLogs = new TreeSet();
for (Iterator iter = limits.keySet().iterator(); iter.hasNext(); ) {
@ -51,7 +51,7 @@ public class ConfigLoggingHelper extends HelperBase {
}
public String getDefaultLogLevelBox() {
String cur = _context.logManager().getDefaultLimit();
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
buf.append("<select name=\"defaultloglevel\">\n");
buf.append("<option value=\"DEBUG\" ");

View File

@ -190,7 +190,7 @@ public class ConfigNetHelper extends HelperBase {
}
private static String getBurstFactor(int numSeconds, String name) {
StringBuffer buf = new StringBuffer(256);
StringBuilder buf = new StringBuilder(256);
buf.append("<select name=\"").append(name).append("\">\n");
boolean found = false;
for (int i = 10; i <= 70; i += 10) {
@ -220,7 +220,7 @@ public class ConfigNetHelper extends HelperBase {
public String getSharePercentageBox() {
int pct = (int) (100 * _context.router().getSharePercentage());
StringBuffer buf = new StringBuffer(256);
StringBuilder buf = new StringBuilder(256);
buf.append("<select style=\"text-align: right;\" name=\"sharePercentage\">\n");
boolean found = false;
for (int i = 30; i <= 110; i += 10) {

View File

@ -71,7 +71,7 @@ public class ConfigRestartBean {
/** @param s value,label,... pairs */
private static String buttons(String url, String nonce, String s) {
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
StringTokenizer tok = new StringTokenizer(s, ",");
buf.append("<form action=\"").append(url).append("\" method=\"GET\">\n");
buf.append("<input type=\"hidden\" name=\"consoleNonce\" value=\"").append(nonce).append("\" >\n");

View File

@ -102,7 +102,7 @@ public class ConfigStatsHandler extends FormHandler {
}
}
StringBuffer stats = new StringBuffer();
StringBuilder stats = new StringBuilder();
for (int i = 0; i < _stats.size(); i++) {
stats.append((String)_stats.get(i));
if (i + 1 < _stats.size())

View File

@ -13,7 +13,7 @@ public class ConfigTunnelsHelper extends HelperBase {
public String getForm() {
StringBuffer buf = new StringBuffer(1024);
StringBuilder buf = new StringBuilder(1024);
buf.append("<table border=\"1\">\n");
TunnelPoolSettings exploratoryIn = _context.tunnelManager().getInboundSettings();
TunnelPoolSettings exploratoryOut = _context.tunnelManager().getOutboundSettings();
@ -54,7 +54,7 @@ public class ConfigTunnelsHelper extends HelperBase {
private static final int MAX_BACKUP_QUANTITY = 3;
private static final int MAX_VARIANCE = 2;
private static final int MIN_NEG_VARIANCE = -1;
private void renderForm(StringBuffer buf, int index, String prefix, String name, TunnelPoolSettings in, TunnelPoolSettings out) {
private void renderForm(StringBuilder buf, int index, String prefix, String name, TunnelPoolSettings in, TunnelPoolSettings out) {
buf.append("<tr><th colspan=\"3\"><a name=\"").append(prefix).append("\">");
buf.append(name).append("</a></th></tr>\n");
@ -179,7 +179,7 @@ public class ConfigTunnelsHelper extends HelperBase {
buf.append("<tr><td colspan=\"3\"><hr /></td></tr>\n");
}
private void renderOptions(StringBuffer buf, int min, int max, int now, String prefix, String name) {
private void renderOptions(StringBuilder buf, int min, int max, int now, String prefix, String name) {
for (int i = min; i <= max; i++) {
buf.append("<option value=\"").append(i).append("\" ");
if (i == now)

View File

@ -58,7 +58,7 @@ public class ConfigUpdateHelper extends HelperBase {
ms = Long.parseLong(freq);
} catch (NumberFormatException nfe) {}
StringBuffer buf = new StringBuffer(256);
StringBuilder buf = new StringBuilder(256);
buf.append("<select name=\"refreshFrequency\">");
for (int i = 0; i < PERIODS.length; i++) {
buf.append("<option value=\"").append(PERIODS[i]);
@ -77,7 +77,7 @@ public class ConfigUpdateHelper extends HelperBase {
public String getUpdatePolicySelectBox() {
String policy = _context.getProperty(ConfigUpdateHandler.PROP_UPDATE_POLICY, ConfigUpdateHandler.DEFAULT_UPDATE_POLICY);
StringBuffer buf = new StringBuffer(256);
StringBuilder buf = new StringBuilder(256);
buf.append("<select name=\"updatePolicy\">");
if ("notify".equals(policy))

View File

@ -45,7 +45,7 @@ public class ContentHelper extends HelperBase {
if (str == null)
return "";
else {
StringBuffer sb = new StringBuffer(str.length()+11);
StringBuilder sb = new StringBuilder(str.length()+11);
sb.append("<pre>");
for (int i=0; i < str.length(); i++) {
char c = str.charAt(i);

View File

@ -87,7 +87,7 @@ public class FormHandler {
process();
if (_errors.size() <= 0 && _notices.size() <= 0)
return "";
StringBuffer buf = new StringBuffer(512);
StringBuilder buf = new StringBuilder(512);
buf.append("<div class=\"messages\" id=\"messages\"><p>");
if (_errors.size() > 0) {
buf.append("<span class=\"error\">");
@ -178,7 +178,7 @@ public class FormHandler {
if (source.size() <= 0) {
return "";
} else {
StringBuffer buf = new StringBuffer(512);
StringBuilder buf = new StringBuilder(512);
buf.append("<ul>\n");
for (int i = 0; i < source.size(); i++) {
buf.append("<li>");

View File

@ -46,7 +46,7 @@ public class LogsHelper extends HelperBase {
private String formatMessages(List msgs) {
boolean colorize = Boolean.valueOf(_context.getProperty("routerconsole.logs.color")).booleanValue();
StringBuffer buf = new StringBuffer(16*1024);
StringBuilder buf = new StringBuilder(16*1024);
buf.append("<ul>");
buf.append("<code>\n");
for (int i = msgs.size(); i > 0; i--) {

View File

@ -27,7 +27,7 @@ public class NavHelper extends HelperBase {
}
public String getClientAppLinks() {
StringBuffer buf = new StringBuffer(1024);
StringBuilder buf = new StringBuilder(1024);
for (Iterator iter = _apps.keySet().iterator(); iter.hasNext(); ) {
String name = (String)iter.next();
String path = (String)_apps.get(name);

View File

@ -144,7 +144,7 @@ public class NewsFetcher implements Runnable, EepGet.StatusListener {
FileInputStream in = null;
try {
in = new FileInputStream(_newsFile);
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
while (DataHelper.readLine(in, buf)) {
int index = buf.indexOf(VERSION_PREFIX);
if (index == -1) {

View File

@ -50,7 +50,7 @@ public class ServiceManager {
// InputStream StdoutStream = _shellCommand.getInputStream();
// InputStream StderrStream = _shellCommand.getErrorStream();
StringBuffer result = null;
StringBuilder result = null;
if (_shellCommand.executeAndWait(command))
return null;

View File

@ -87,7 +87,7 @@ public class StatSummarizer implements Runnable {
removeDb(r);
}
// add new ones
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
for (int i = 0; i < newSpecs.size(); i++) {
Rate r = (Rate)newSpecs.get(i);
if (!old.contains(r))

View File

@ -344,7 +344,7 @@ public class SummaryHelper extends HelperBase {
List clients = new ArrayList(_context.clientManager().listClients());
Collections.sort(clients, new AlphaComparator());
StringBuffer buf = new StringBuffer(512);
StringBuilder buf = new StringBuilder(512);
buf.append("<u><b>Local destinations</b></u><br />");
for (Iterator iter = clients.iterator(); iter.hasNext(); ) {

View File

@ -156,7 +156,7 @@ public class UpdateHandler {
// ignored
}
public void bytesTransferred(long alreadyTransferred, int currentWrite, long bytesTransferred, long bytesRemaining, String url) {
StringBuffer buf = new StringBuffer(64);
StringBuilder buf = new StringBuilder(64);
buf.append("<b>Updating</b> ");
double pct = ((double)alreadyTransferred + (double)currentWrite) /
((double)alreadyTransferred + (double)currentWrite + (double)bytesRemaining);

View File

@ -43,7 +43,7 @@
<p>
<table>
<tr><td>Dest. name, hash, or full key:
<td><textarea name="peer" cols="44" rows="1" wrap="off"></textarea>
<td><textarea name="peer" cols="44" rows="1" style="height: 3em;" wrap="off"></textarea>
<tr><td align="right">Session Key:
<td><input type="text" size="55" name="key" />
<tr><td><td><input type="submit" name="action" value="Add key" />

View File

@ -155,7 +155,7 @@ public class SAMUtils {
String token, param;
Properties props = new Properties();
StringBuffer value = new StringBuffer();
StringBuilder value = new StringBuilder();
for (int i = 0; i < ntoks; ++i) {
token = tok.nextToken();

View File

@ -899,7 +899,7 @@ public class Connection {
if (_log.shouldLog(Log.WARN))
_log.warn("Closing connection due to inactivity");
if (_log.shouldLog(Log.DEBUG)) {
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
buf.append("last sent was: ").append(_context.clock().now() - _lastSendTime);
buf.append("ms ago, last received was: ").append(_context.clock().now()-_lastReceivedOn);
buf.append("ms ago, inactivity timeout is: ").append(_options.getInactivityTimeout());
@ -934,7 +934,7 @@ public class Connection {
@Override
public String toString() {
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
buf.append("[Connection ");
if (_receiveStreamId > 0)
buf.append(Packet.toId(_receiveStreamId));

View File

@ -475,7 +475,7 @@ public class ConnectionOptions extends I2PSocketOptionsImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
buf.append("conDelay=").append(_connectDelay);
buf.append(" maxSize=").append(_maxMessageSize);
buf.append(" rtt=").append(_rtt);

View File

@ -174,7 +174,7 @@ public class MessageInputStream extends InputStream {
public void closeReceived() {
synchronized (_dataLock) {
if (_log.shouldLog(Log.DEBUG)) {
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
buf.append("Close received, ready bytes: ");
long available = 0;
for (int i = 0; i < _readyDataBlocks.size(); i++)

View File

@ -598,12 +598,12 @@ public class Packet {
@Override
public String toString() {
StringBuffer str = formatAsString();
StringBuilder str = formatAsString();
return str.toString();
}
protected StringBuffer formatAsString() {
StringBuffer buf = new StringBuffer(64);
protected StringBuilder formatAsString() {
StringBuilder buf = new StringBuilder(64);
buf.append(toId(_sendStreamId));
//buf.append("<-->");
buf.append(toId(_receiveStreamId)).append(": #").append(_sequenceNum);
@ -629,7 +629,7 @@ public class Packet {
}
private final String toFlagString() {
StringBuffer buf = new StringBuffer(32);
StringBuilder buf = new StringBuilder(32);
if (isFlagSet(FLAG_CLOSE)) buf.append(" CLOSE");
if (isFlagSet(FLAG_DELAY_REQUESTED)) buf.append(" DELAY ").append(_optionDelay);
if (isFlagSet(FLAG_ECHO)) buf.append(" ECHO");

View File

@ -112,7 +112,7 @@ public class PacketHandler {
private static final SimpleDateFormat _fmt = new SimpleDateFormat("HH:mm:ss.SSS");
void displayPacket(Packet packet, String prefix, String suffix) {
if (!_log.shouldLog(Log.INFO)) return;
StringBuffer buf = new StringBuffer(256);
StringBuilder buf = new StringBuilder(256);
synchronized (_fmt) {
buf.append(_fmt.format(new Date()));
}
@ -198,7 +198,7 @@ public class PacketHandler {
// someone is sending us a packet on the wrong stream
if (_log.shouldLog(Log.ERROR)) {
Set cons = _manager.listConnections();
StringBuffer buf = new StringBuffer(512);
StringBuilder buf = new StringBuilder(512);
buf.append("Received a packet on the wrong stream: ");
buf.append(packet);
buf.append(" connection: ");
@ -275,7 +275,7 @@ public class PacketHandler {
_log.warn("Packet belongs to no other cons, putting on the syn queue: " + packet);
}
if (_log.shouldLog(Log.DEBUG)) {
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
Set cons = _manager.listConnections();
for (Iterator iter = cons.iterator(); iter.hasNext(); ) {
Connection con = (Connection)iter.next();

View File

@ -133,8 +133,8 @@ public class PacketLocal extends Packet implements MessageOutputStream.WriteStat
public void setResendPacketEvent(SimpleTimer2.TimedEvent evt) { _resendEvent = evt; }
@Override
public StringBuffer formatAsString() {
StringBuffer buf = super.formatAsString();
public StringBuilder formatAsString() {
StringBuilder buf = super.formatAsString();
Connection con = _connection;
if (con != null)

View File

@ -83,7 +83,7 @@ public class ConfigBean implements Serializable {
{
File file = new File( configFileName );
if( file != null && file.isFile() ) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
BufferedReader br = null;
try {
br = new BufferedReader( new FileReader( file ) );

View File

@ -86,7 +86,7 @@ public class SubscriptionsBean
{
File file = new File( getFileName() );
if( file != null && file.isFile() ) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
BufferedReader br = null;
try {
br = new BufferedReader( new FileReader( file ) );

View File

@ -143,7 +143,7 @@
<td class="names"><a href="http://${addr.name}/">${addr.name}</a> -
<span class="addrhlpr"><a href="http://${addr.name}/?i2paddresshelper=${addr.destination}">(addrhlpr)</a></span>
</td>
<td class="destinations"><textarea rows="1" cols="40" wrap="off" readonly="readonly" name="dest_${addr.name}" >${addr.destination}</textarea></td>
<td class="destinations"><textarea rows="1" style="height: 3em;" cols="40" wrap="off" readonly="readonly" name="dest_${addr.name}" >${addr.destination}</textarea></td>
</tr>
</c:forEach>
</table>
@ -168,7 +168,7 @@
<p class="add">
<h3>Add new destination:</h3>
<b>Hostname:</b> <input type="text" name="hostname" value="${book.hostname}" size="20">
<b>Destination:</b> <textarea name="destination" rows="1" cols="40" wrap="off" >${book.destination}</textarea><br/>
<b>Destination:</b> <textarea name="destination" rows="1" style="height: 3em;" cols="40" wrap="off" >${book.destination}</textarea><br/>
</p><p>
<input type="image" name="action" value="add" src="images/add.png" alt="Add destination" />
</p>

View File

@ -142,7 +142,7 @@ public class Mail {
}
return ok;
}
public static void appendRecipients( StringBuffer buf, ArrayList recipients, String prefix )
public static void appendRecipients( StringBuilder buf, ArrayList recipients, String prefix )
{
for( Iterator it = recipients.iterator(); it.hasNext(); ) {
buf.append( prefix );

View File

@ -444,7 +444,7 @@ public class WebMail extends HttpServlet
boolean showBody = false;
boolean prepareAttachment = false;
String reason = "";
StringBuffer body = null;
StringBuilder body = null;
String ident = quoteHTML(
( mailPart.description != null ? mailPart.description + ", " : "" ) +
@ -485,7 +485,7 @@ public class WebMail extends HttpServlet
try {
ReadBuffer decoded = e.decode( mailPart.buffer.content, mailPart.beginBody, mailPart.end - mailPart.beginBody );
BufferedReader reader = new BufferedReader( new InputStreamReader( new ByteArrayInputStream( decoded.content, decoded.offset, decoded.length ), charset ) );
body = new StringBuffer();
body = new StringBuilder();
String line;
while( ( line = reader.readLine() ) != null ) {
body.append( quoteHTML( line ) );
@ -782,7 +782,7 @@ public class WebMail extends HttpServlet
/*
* extract additional recipients
*/
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
String pad = "";
if( mail.to != null ) {
for( int i = 0; i < mail.to.length; i++ ) {
@ -1429,7 +1429,7 @@ public class WebMail extends HttpServlet
}
if( ok ) {
StringBuffer body = new StringBuffer();
StringBuilder body = new StringBuilder();
body.append( "From: " + from + "\r\n" );
Mail.appendRecipients( body, toList, "To: " );
Mail.appendRecipients( body, ccList, "To: " );

View File

@ -70,7 +70,7 @@ public class Base64 implements Encoding {
*/
private String encode( InputStream in ) throws IOException, EncodingException
{
StringBuffer strBuf = new StringBuffer();
StringBuilder strBuf = new StringBuilder();
int buf[] = new int[3];
int out[] = new int[4];

View File

@ -55,7 +55,7 @@ public class HeaderLine implements Encoding {
private static final int BUFSIZE = 2;
private String encode(InputStream in) throws IOException
{
StringBuffer out = new StringBuffer();
StringBuilder out = new StringBuilder();
int l = 0, buffered = 0, tmp[] = new int[BUFSIZE];
boolean quoting = false;
boolean quote = false;

View File

@ -69,7 +69,7 @@ public class QuotedPrintable implements Encoding {
*/
private static int BUFSIZE = 2;
private String encode( InputStream in ) throws EncodingException, IOException {
StringBuffer out = new StringBuffer();
StringBuilder out = new StringBuilder();
int l = 0;
int read = 0, buffered = 0, tmp[] = new int[BUFSIZE];
while( true ) {

View File

@ -323,7 +323,7 @@ private static long bytesToLong(byte[] b) {
if(null == extensions || extensions.isEmpty())
return "";
StringBuffer result = new StringBuffer();
StringBuilder result = new StringBuilder();
List<String> tempList;
boolean first = true;

View File

@ -74,7 +74,7 @@ public class CPUID {
private static String getCPUVendorID()
{
CPUIDResult c = doCPUID(0);
StringBuffer sb= new StringBuffer(13);
StringBuilder sb= new StringBuilder(13);
sb.append((char)( c.EBX & 0xFF));
sb.append((char)((c.EBX >> 8) & 0xFF));
sb.append((char)((c.EBX >> 16) & 0xFF));

View File

@ -124,7 +124,7 @@ public class PetName {
@Override
public String toString() {
StringBuffer buf = new StringBuffer(256);
StringBuilder buf = new StringBuilder(256);
if (_name != null) buf.append(_name.trim());
buf.append(':');
if (_network != null) buf.append(_network.trim());

View File

@ -130,7 +130,7 @@ public class ElGamalEngine {
System.arraycopy(dbytes, 0, out, (dbytes.length < 257 ? 514 - dbytes.length : 257),
(dbytes.length > 257 ? 257 : dbytes.length));
/*
StringBuffer buf = new StringBuffer(1024);
StringBuilder buf = new StringBuilder(1024);
buf.append("Timing\n");
buf.append("0-1: ").append(t1 - t0).append('\n');
buf.append("1-2: ").append(t2 - t1).append('\n');

View File

@ -179,7 +179,7 @@ public class SHA1Test {
}
private static final String toHex(final byte[] bytes) {
StringBuffer buf = new StringBuffer(bytes.length * 2);
StringBuilder buf = new StringBuilder(bytes.length * 2);
for (int i = 0; i < bytes.length; i++) {
if ((i & 3) == 0 && i != 0)
buf.append(' ');

View File

@ -452,12 +452,12 @@ public class TransientSessionKeyManager extends SessionKeyManager {
int removed = 0;
int remaining = 0;
long now = _context.clock().now();
StringBuffer buf = null;
StringBuffer bufSummary = null;
StringBuilder buf = null;
StringBuilder bufSummary = null;
if (_log.shouldLog(Log.DEBUG)) {
buf = new StringBuffer(128);
buf = new StringBuilder(128);
buf.append("Expiring inbound: ");
bufSummary = new StringBuffer(1024);
bufSummary = new StringBuilder(1024);
}
synchronized (_inboundTagSets) {
for (Iterator<SessionTag> iter = _inboundTagSets.keySet().iterator(); iter.hasNext();) {
@ -500,7 +500,7 @@ public class TransientSessionKeyManager extends SessionKeyManager {
}
public String renderStatusHTML() {
StringBuffer buf = new StringBuffer(1024);
StringBuilder buf = new StringBuilder(1024);
buf.append("<h2>Inbound sessions</h2>");
buf.append("<table border=\"1\">");
Set<TagSet> inbound = getInboundTagSets();

View File

@ -255,16 +255,16 @@ D8usM7Dxp5yrDrCYZ5AIijc=
}
private static final String sanitize(String versionString) {
StringBuffer versionStringBuffer = new StringBuffer(versionString);
StringBuilder versionStringBuilder = new StringBuilder(versionString);
for (int i = 0; i < versionStringBuffer.length(); i++) {
if (VALID_VERSION_CHARS.indexOf(versionStringBuffer.charAt(i)) == -1) {
versionStringBuffer.deleteCharAt(i);
for (int i = 0; i < versionStringBuilder.length(); i++) {
if (VALID_VERSION_CHARS.indexOf(versionStringBuilder.charAt(i)) == -1) {
versionStringBuilder.deleteCharAt(i);
i--;
}
}
return versionStringBuffer.toString();
return versionStringBuilder.toString();
}
private static final void showUsageCLI() {
@ -328,7 +328,7 @@ D8usM7Dxp5yrDrCYZ5AIijc=
* delimited by CR LF line breaks.
*/
public String getTrustedKeysString() {
StringBuffer buf = new StringBuffer(1024);
StringBuilder buf = new StringBuilder(1024);
for (int i = 0; i < _trustedKeys.size(); i++) {
// If something already buffered, first add line break.
if (buf.length() > 0) buf.append("\r\n");

View File

@ -73,7 +73,7 @@ public class Address extends DataStructureImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer(64);
StringBuilder buf = new StringBuilder(64);
buf.append("[Address: ");
buf.append("\n\tHostname: ").append(getHostname());
buf.append("\n\tDestination: ").append(getDestination());

View File

@ -137,7 +137,7 @@ public class Base32 {
}
public static String encode(byte[] source) {
StringBuffer buf = new StringBuffer((source.length + 7) * 8 / 5);
StringBuilder buf = new StringBuilder((source.length + 7) * 8 / 5);
encodeBytes(source, buf);
return buf.toString();
}
@ -149,7 +149,7 @@ public class Base32 {
*
* @param source The data to convert
*/
private static void encodeBytes(byte[] source, StringBuffer out) {
private static void encodeBytes(byte[] source, StringBuilder out) {
int usedbits = 0;
for (int i = 0; i < source.length; ) {
int fivebits;

View File

@ -330,7 +330,7 @@ public class Base64 {
} // end switch
} // end encode3to4
private static void encode3to4(byte[] source, int srcOffset, int numSigBytes, StringBuffer buf, byte alpha[]) {
private static void encode3to4(byte[] source, int srcOffset, int numSigBytes, StringBuilder buf, byte alpha[]) {
// 1 2 3
// 01234567890123456789012345678901 Bit position
// --------000000001111111122222222 Array position from threeBytes
@ -394,7 +394,7 @@ public class Base64 {
private static String safeEncode(byte[] source, int off, int len, boolean useStandardAlphabet) {
if (len + off > source.length)
throw new ArrayIndexOutOfBoundsException("Trying to encode too much! source.len=" + source.length + " off=" + off + " len=" + len);
StringBuffer buf = new StringBuffer(len * 4 / 3);
StringBuilder buf = new StringBuilder(len * 4 / 3);
if (useStandardAlphabet)
encodeBytes(source, off, len, false, buf, ALPHABET);
else
@ -446,7 +446,7 @@ public class Base64 {
******/
private static String encodeBytes(byte[] source, int off, int len, boolean breakLines) {
StringBuffer buf = new StringBuffer( (len*4)/3 );
StringBuilder buf = new StringBuilder( (len*4)/3 );
encodeBytes(source, off, len, breakLines, buf, ALPHABET);
return buf.toString();
}
@ -460,7 +460,7 @@ public class Base64 {
* @param breakLines Break lines at 80 characters or less.
* @since 1.4
*/
private static void encodeBytes(byte[] source, int off, int len, boolean breakLines, StringBuffer out, byte alpha[]) {
private static void encodeBytes(byte[] source, int off, int len, boolean breakLines, StringBuilder out, byte alpha[]) {
//int len43 = len * 4 / 3;
//byte[] outBuff = new byte[(len43) // Main 4:3
// + ((len % 3) > 0 ? 4 : 0) // Account for padding

View File

@ -149,7 +149,7 @@ public class Certificate extends DataStructureImpl {
}
@Override
public String toString() {
StringBuffer buf = new StringBuffer(64);
StringBuilder buf = new StringBuilder(64);
buf.append("[Certificate: type: ");
if (getCertificateType() == CERTIFICATE_TYPE_NULL)
buf.append("Null certificate");

View File

@ -196,7 +196,7 @@ public class DataHelper {
*
*/
public static String toString(Properties options) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
if (options != null) {
for (Iterator iter = options.keySet().iterator(); iter.hasNext();) {
String key = (String) iter.next();
@ -273,7 +273,7 @@ public class DataHelper {
*
*/
public static String toString(Collection col) {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
if (col != null) {
for (Iterator iter = col.iterator(); iter.hasNext();) {
Object o = iter.next();
@ -296,17 +296,17 @@ public class DataHelper {
public static String toString(byte buf[], int len) {
if (buf == null) buf = EMPTY_BUFFER;
StringBuffer out = new StringBuffer();
StringBuilder out = new StringBuilder();
if (len > buf.length) {
for (int i = 0; i < len - buf.length; i++)
out.append("00");
}
for (int i = 0; i < buf.length && i < len; i++) {
StringBuffer temp = new StringBuffer(Integer.toHexString(buf[i]));
StringBuilder temp = new StringBuilder(Integer.toHexString(buf[i]));
while (temp.length() < 2) {
temp.insert(0, '0');
}
temp = new StringBuffer(temp.substring(temp.length() - 2));
temp = new StringBuilder(temp.substring(temp.length() - 2));
out.append(temp.toString());
}
return out.toString();
@ -775,19 +775,27 @@ public class DataHelper {
/**
* Read a newline delimited line from the stream, returning the line (without
* the newline), or null if EOF reached before the newline was found
* Warning - strips \n but not \r
*/
public static String readLine(InputStream in) throws IOException { return readLine(in, (Sha256Standalone)null); }
/** update the hash along the way */
/**
* update the hash along the way
* Warning - strips \n but not \r
*/
public static String readLine(InputStream in, Sha256Standalone hash) throws IOException {
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
boolean ok = readLine(in, buf, hash);
if (ok)
return buf.toString();
else
return null;
}
/**
* Read in a line, placing it into the buffer (excluding the newline).
* Warning - strips \n but not \r
* @deprecated use StringBuilder version
*
* @return true if the line was read, false if eof was reached before a
* newline was found
@ -795,7 +803,12 @@ public class DataHelper {
public static boolean readLine(InputStream in, StringBuffer buf) throws IOException {
return readLine(in, buf, null);
}
/** update the hash along the way */
/**
* update the hash along the way
* Warning - strips \n but not \r
* @deprecated use StringBuilder version
*/
public static boolean readLine(InputStream in, StringBuffer buf, Sha256Standalone hash) throws IOException {
int c = -1;
while ( (c = in.read()) != -1) {
@ -810,6 +823,32 @@ public class DataHelper {
return true;
}
/**
* Read in a line, placing it into the buffer (excluding the newline).
* Warning - strips \n but not \r
*
* @return true if the line was read, false if eof was reached before a
* newline was found
*/
public static boolean readLine(InputStream in, StringBuilder buf) throws IOException {
return readLine(in, buf, null);
}
/**
* update the hash along the way
* Warning - strips \n but not \r
*/
public static boolean readLine(InputStream in, StringBuilder buf, Sha256Standalone hash) throws IOException {
int c = -1;
while ( (c = in.read()) != -1) {
if (hash != null) hash.update((byte)c);
if (c == '\n')
break;
buf.append((char)c);
}
return c != -1;
}
public static void write(OutputStream out, byte data[], Sha256Standalone hash) throws IOException {
hash.update(data);
out.write(data);

View File

@ -145,7 +145,7 @@ public class Destination extends DataStructureImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
buf.append("[Destination: ");
buf.append("\n\tHash: ").append(calculateHash().toBase64());
buf.append("\n\tPublic Key: ").append(getPublicKey());

View File

@ -104,7 +104,7 @@ public class Hash extends DataStructureImpl {
}
if (_log.shouldLog(Log.DEBUG)) {
// explicit buffer, since the compiler can't guess how long it'll be
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
buf.append("miss [").append(cached).append("] from ");
buf.append(DataHelper.toHexString(getData())).append(" to ");
buf.append(DataHelper.toHexString(key.getData()));
@ -113,7 +113,7 @@ public class Hash extends DataStructureImpl {
} else {
if (_log.shouldLog(Log.DEBUG)) {
// explicit buffer, since the compiler can't guess how long it'll be
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
buf.append("hit from ");
buf.append(DataHelper.toHexString(getData())).append(" to ");
buf.append(DataHelper.toHexString(key.getData()));
@ -155,7 +155,7 @@ public class Hash extends DataStructureImpl {
@Override
public String toString() {
if (_stringified == null) {
StringBuffer buf = new StringBuffer(64);
StringBuilder buf = new StringBuilder(64);
buf.append("[Hash: ");
if (_data == null) {
buf.append("null hash");

View File

@ -147,7 +147,7 @@ public class Lease extends DataStructureImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
buf.append("[Lease: ");
buf.append("\n\tEnd Date: ").append(getEndDate());
buf.append("\n\tGateway: ").append(getGateway());

View File

@ -355,7 +355,7 @@ public class LeaseSet extends DataStructureImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
buf.append("[LeaseSet: ");
buf.append("\n\tDestination: ").append(getDestination());
buf.append("\n\tEncryptionKey: ").append(getEncryptionKey());

View File

@ -108,7 +108,7 @@ public class Payload extends DataStructureImpl {
@Override
public String toString() {
if (true) return "[Payload]";
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
buf.append("[Payload: ");
if (getUnencryptedData() != null)
buf.append("\n\tData: ").append(DataHelper.toString(getUnencryptedData(), 16));

View File

@ -77,7 +77,7 @@ public class PrivateKey extends DataStructureImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer(64);
StringBuilder buf = new StringBuilder(64);
buf.append("[PrivateKey: ");
if (_data == null) {
buf.append("null key");

View File

@ -263,7 +263,7 @@ public class PrivateKeyFile {
}
public String toString() {
StringBuffer s = new StringBuffer(128);
StringBuilder s = new StringBuilder(128);
s.append("Dest: ");
s.append(this.dest != null ? this.dest.toBase64() : "null");
s.append("\nContains: ");

View File

@ -79,7 +79,7 @@ public class PublicKey extends DataStructureImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer(64);
StringBuilder buf = new StringBuilder(64);
buf.append("[PublicKey: ");
if (_data == null) {
buf.append("null key");

View File

@ -138,7 +138,7 @@ public class RouterAddress extends DataStructureImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer(64);
StringBuilder buf = new StringBuilder(64);
buf.append("[RouterAddress: ");
buf.append("\n\tTransportStyle: ").append(getTransportStyle());
buf.append("\n\tCost: ").append(getCost());

View File

@ -109,7 +109,7 @@ public class RouterIdentity extends DataStructureImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer(64);
StringBuilder buf = new StringBuilder(64);
buf.append("[RouterIdentity: ");
buf.append("\n\tHash: ").append(getHash().toBase64());
buf.append("\n\tCertificate: ").append(getCertificate());

View File

@ -382,7 +382,7 @@ public class RouterInfo extends DataStructureImpl {
} else if ((idx = caps.indexOf(cap)) == -1) {
return;
} else {
StringBuffer buf = new StringBuffer(caps);
StringBuilder buf = new StringBuilder(caps);
while ( (idx = buf.indexOf(""+cap)) != -1)
buf.deleteCharAt(idx);
_options.setProperty(PROP_CAPABILITIES, buf.toString());
@ -555,7 +555,7 @@ public class RouterInfo extends DataStructureImpl {
@Override
public String toString() {
if (_stringified != null) return _stringified;
StringBuffer buf = new StringBuffer(5*1024);
StringBuilder buf = new StringBuilder(5*1024);
buf.append("[RouterInfo: ");
buf.append("\n\tIdentity: ").append(getIdentity());
buf.append("\n\tSignature: ").append(getSignature());

View File

@ -84,7 +84,7 @@ public class SessionKey extends DataStructureImpl {
@Override
public String toString() {
if (true) return super.toString();
StringBuffer buf = new StringBuffer(64);
StringBuilder buf = new StringBuilder(64);
buf.append("[SessionKey: ");
if (_data == null) {
buf.append("null key");

View File

@ -69,7 +69,7 @@ public class Signature extends DataStructureImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer(64);
StringBuilder buf = new StringBuilder(64);
buf.append("[Signature: ");
if (_data == null) {
buf.append("null signature");

View File

@ -75,7 +75,7 @@ public class SigningPrivateKey extends DataStructureImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer(64);
StringBuilder buf = new StringBuilder(64);
buf.append("[SigningPrivateKey: ");
if (_data == null) {
buf.append("null key");

View File

@ -74,7 +74,7 @@ public class SigningPublicKey extends DataStructureImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer(64);
StringBuilder buf = new StringBuilder(64);
buf.append("[SigningPublicKey: ");
if (_data == null) {
buf.append("null key");

View File

@ -155,7 +155,7 @@ public class VerifiedDestination extends Destination {
@Override
public String toString() {
StringBuffer buf = new StringBuffer(128);
StringBuilder buf = new StringBuilder(128);
buf.append(super.toString());
buf.append("\n\tVerified Certificate? ").append(verifyCert(true));
return buf.toString();

View File

@ -91,7 +91,7 @@ public class BandwidthLimitsMessage extends I2CPMessageImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("[BandwidthLimitsMessage");
buf.append("\n\tIn: ").append(data[0]);
buf.append("\n\tOut: ").append(data[1]);

View File

@ -128,7 +128,7 @@ public class CreateLeaseSetMessage extends I2CPMessageImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("[CreateLeaseSetMessage: ");
buf.append("\n\tLeaseSet: ").append(getLeaseSet());
buf.append("\n\tSigningPrivateKey: ").append(getSigningPrivateKey());

View File

@ -84,7 +84,7 @@ public class CreateSessionMessage extends I2CPMessageImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("[CreateSessionMessage: ");
buf.append("\n\tConfig: ").append(getSessionConfig());
buf.append("]");

View File

@ -67,7 +67,7 @@ public class DestLookupMessage extends I2CPMessageImpl {
}
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("[DestLookupMessage: ");
buf.append("\n\tHash: ").append(_hash);
buf.append("]");

View File

@ -69,7 +69,7 @@ public class DestReplyMessage extends I2CPMessageImpl {
}
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("[DestReplyMessage: ");
buf.append("\n\tDestination: ").append(_dest);
buf.append("]");

View File

@ -80,7 +80,7 @@ public class DestroySessionMessage extends I2CPMessageImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("[DestroySessionMessage: ");
buf.append("\n\tSessionId: ").append(getSessionId());
buf.append("]");

View File

@ -76,7 +76,7 @@ public class DisconnectMessage extends I2CPMessageImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("[DisconnectMessage: ");
buf.append("\n\tReason: ").append(getReason());
buf.append("]");

View File

@ -49,7 +49,7 @@ public class GetBandwidthLimitsMessage extends I2CPMessageImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("[GetBandwidthLimitsMessage]");
return buf.toString();
}

View File

@ -52,7 +52,7 @@ public class GetDateMessage extends I2CPMessageImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("[GetDateMessage]");
return buf.toString();
}

View File

@ -123,7 +123,7 @@ public class MessagePayloadMessage extends I2CPMessageImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("[MessagePayloadMessage: ");
buf.append("\n\tSessionId: ").append(getSessionId());
buf.append("\n\tMessageId: ").append(getMessageId());

View File

@ -168,7 +168,7 @@ public class MessageStatusMessage extends I2CPMessageImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("[MessageStatusMessage: ");
buf.append("\n\tSessionId: ").append(getSessionId());
buf.append("\n\tNonce: ").append(getNonce());

View File

@ -102,7 +102,7 @@ public class ReceiveMessageBeginMessage extends I2CPMessageImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("[ReceiveMessageBeginMessage: ");
buf.append("\n\tSessionId: ").append(getSessionId());
buf.append("\n\tMessageId: ").append(getMessageId());

View File

@ -86,7 +86,7 @@ public class ReceiveMessageEndMessage extends I2CPMessageImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("[ReceiveMessageEndMessage: ");
buf.append("\n\tSessionId: ").append(getSessionId());
buf.append("\n\tMessageId: ").append(getMessageId());

View File

@ -93,7 +93,7 @@ public class ReconfigureSessionMessage extends I2CPMessageImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("[ReconfigureSessionMessage: ");
buf.append("\n\tSessionId: ").append(getSessionId());
buf.append("\n\tSessionConfig: ").append(getSessionConfig());

View File

@ -123,7 +123,7 @@ public class ReportAbuseMessage extends I2CPMessageImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("[ReportAbuseMessage: ");
buf.append("\n\tSessionID: ").append(getSessionId());
buf.append("\n\tSeverity: ").append(getSeverity());

View File

@ -143,7 +143,7 @@ public class RequestLeaseSetMessage extends I2CPMessageImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("[RequestLeaseMessage: ");
buf.append("\n\tSessionId: ").append(getSessionId());
buf.append("\n\tTunnels:");

View File

@ -104,7 +104,7 @@ public class SendMessageExpiresMessage extends SendMessageMessage {
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("[SendMessageMessage: ");
buf.append("\n\tSessionId: ").append(getSessionId());
buf.append("\n\tNonce: ").append(getNonce());

View File

@ -149,7 +149,7 @@ public class SendMessageMessage extends I2CPMessageImpl {
@Override
public String toString() {
StringBuffer buf = new StringBuffer();
StringBuilder buf = new StringBuilder();
buf.append("[SendMessageMessage: ");
buf.append("\n\tSessionId: ").append(getSessionId());
buf.append("\n\tNonce: ").append(getNonce());

Some files were not shown because too many files have changed in this diff Show More