merge of '354d421d8e1f234007967cec4461aedb532ae89e'

and '56635df32be529c80a40a3d84e01ef858c7346ec'
This commit is contained in:
z3d
2010-12-05 04:32:28 +00:00
5 changed files with 19 additions and 7 deletions

View File

@ -191,7 +191,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
l.log("Invalid I2CP configuration");
throw new IllegalArgumentException("Socket manager could not be created");
}
l.log("I2P session created");
l.log("Tunnels ready for client: " + handlerName);
} // else delay creating session until createI2PSocket() is called

View File

@ -384,7 +384,7 @@ public class NetDbRenderer {
}
buf.append("</td></tr>\n");
if (full) {
buf.append("<tr><td>" + _("Stats") + ": <br><code>\n");
buf.append("<tr><td>" + _("Stats") + ": <br><code>");
for (Iterator iter = info.getOptions().keySet().iterator(); iter.hasNext(); ) {
String key = (String)iter.next();
String val = info.getOption(key);

View File

@ -15,6 +15,7 @@ import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@ -426,6 +427,7 @@ public class DataHelper {
* @param rawStream stream to read from
* @param numBytes number of bytes to read and format into a number
* @throws DataFormatException if the stream doesn't contain a validly formatted number of that many bytes
* @throws EOFException since 0.8.2, if there aren't enough bytes to read the number
* @throws IOException if there is an IO error reading the number
* @return number
*/
@ -437,7 +439,8 @@ public class DataHelper {
long rv = 0;
for (int i = 0; i < numBytes; i++) {
long cur = rawStream.read();
if (cur == -1) throw new DataFormatException("Not enough bytes for the field");
// was DataFormatException
if (cur == -1) throw new EOFException("EOF reading " + numBytes + " byte value");
cur &= 0xFF;
// we loop until we find a nonzero byte (or we reach the end)
if (cur != 0) {
@ -449,8 +452,9 @@ public class DataHelper {
rv += cur;
if (j + 1 < remaining) {
cur = rawStream.read();
// was DataFormatException
if (cur == -1)
throw new DataFormatException("Not enough bytes for the field");
throw new EOFException("EOF reading " + numBytes + " byte value");
cur &= 0xFF;
}
}
@ -572,6 +576,7 @@ public class DataHelper {
*
* @param in stream to read from
* @throws DataFormatException if the stream doesn't contain a validly formatted string
* @throws EOFException since 0.8.2, if there aren't enough bytes to read the string
* @throws IOException if there is an IO error reading the string
* @return UTF-8 string
*/
@ -579,7 +584,8 @@ public class DataHelper {
int size = (int) readLong(in, 1);
byte raw[] = new byte[size];
int read = read(in, raw);
if (read != size) throw new DataFormatException("Not enough bytes to read the string");
// was DataFormatException
if (read != size) throw new EOFException("EOF reading string");
// the following constructor throws an UnsupportedEncodingException which is an IOException,
// but that's only if UTF-8 is not supported. Other encoding errors are not thrown.
return new String(raw, "UTF-8");

View File

@ -1,3 +1,9 @@
2010-12-05 zzz
* DataHelper: Have readLong() and readString() throw an
EOFException instead of a DataFormatException on EOF,
which should lower the log severity in I2CP and I2NP
when a client or peer disconnects.
2010-12-02 zzz
* Console: Format console refresh time
* I2NP: Allow message to be written more than once,

View File

@ -18,10 +18,10 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 30;
public final static long BUILD = 31;
/** for example "-test" */
public final static String EXTRA = "";
public final static String EXTRA = "-rc";
public final static String FULL_VERSION = VERSION + "-" + BUILD + EXTRA;
public static void main(String args[]) {
System.out.println("I2P Router version: " + FULL_VERSION);