diff --git a/apps/sam/java/src/net/i2p/sam/SAMBridge.java b/apps/sam/java/src/net/i2p/sam/SAMBridge.java index d3fffb7c64..df7528c330 100644 --- a/apps/sam/java/src/net/i2p/sam/SAMBridge.java +++ b/apps/sam/java/src/net/i2p/sam/SAMBridge.java @@ -709,7 +709,9 @@ public class SAMBridge implements Runnable, ClientApp { changeState(RUNNING); if (_mgr != null) _mgr.register(this); - I2PAppContext.getGlobalContext().portMapper().register(PortMapper.SVC_SAM, _listenPort); + I2PAppContext.getGlobalContext().portMapper().register(_useSSL ? PortMapper.SVC_SAM_SSL : PortMapper.SVC_SAM, + _listenHost != null ? _listenHost : "127.0.0.1", + _listenPort); try { while (acceptConnections) { SocketChannel s = serverSocket.accept(); @@ -775,7 +777,7 @@ public class SAMBridge implements Runnable, ClientApp { if (serverSocket != null) serverSocket.close(); } catch (IOException e) {} - I2PAppContext.getGlobalContext().portMapper().unregister(PortMapper.SVC_SAM); + I2PAppContext.getGlobalContext().portMapper().unregister(_useSSL ? PortMapper.SVC_SAM_SSL : PortMapper.SVC_SAM); stopHandlers(); changeState(STOPPED); } diff --git a/apps/sam/java/src/net/i2p/sam/SAMUtils.java b/apps/sam/java/src/net/i2p/sam/SAMUtils.java index 2fede075db..e0b0debff2 100644 --- a/apps/sam/java/src/net/i2p/sam/SAMUtils.java +++ b/apps/sam/java/src/net/i2p/sam/SAMUtils.java @@ -167,7 +167,7 @@ class SAMUtils { * Parse SAM parameters, and put them into a Propetries object * * Modified from EepGet. - * All keys, major, and minor are mapped to upper case. + * COMMAND and OPCODE are mapped to upper case; keys, values, and ping data are not. * Double quotes around values are stripped. * * Possible input: @@ -241,8 +241,9 @@ class SAMUtils { key = null; } else if (buf.length() > 0) { // key without value - String k = buf.toString().trim().toUpperCase(Locale.US); + String k = buf.toString(); if (rv.isEmpty()) { + k = k.toUpperCase(Locale.US); rv.setProperty(COMMAND, k); if (k.equals("PING") || k.equals("PONG")) { // eat the rest of the line @@ -254,7 +255,7 @@ class SAMUtils { i = length + 1; } } else if (rv.size() == 1) { - rv.setProperty(OPCODE, k); + rv.setProperty(OPCODE, k.toUpperCase(Locale.US)); } else { if (rv.setProperty(k, "true") != null) throw new SAMException("Duplicate parameter " + k); @@ -273,7 +274,7 @@ class SAMUtils { } else { if (buf.length() == 0) throw new SAMException("Empty parameter name"); - key = buf.toString().toUpperCase(Locale.US); + key = buf.toString(); buf.setLength(0); } break; diff --git a/apps/sam/java/src/net/i2p/sam/SAMv3DatagramServer.java b/apps/sam/java/src/net/i2p/sam/SAMv3DatagramServer.java index a2395e4df1..e23f4e066d 100644 --- a/apps/sam/java/src/net/i2p/sam/SAMv3DatagramServer.java +++ b/apps/sam/java/src/net/i2p/sam/SAMv3DatagramServer.java @@ -24,6 +24,7 @@ import net.i2p.client.I2PSession; import net.i2p.data.DataHelper; import net.i2p.util.I2PAppThread; import net.i2p.util.Log; +import net.i2p.util.PortMapper; /** * This is the thread listening on 127.0.0.1:7655 or as specified by @@ -90,7 +91,7 @@ class SAMv3DatagramServer implements Handler { /** @since 0.9.24 */ public int getPort() { return _port; } - private static class Listener implements Runnable { + private class Listener implements Runnable { private final DatagramChannel server; @@ -98,8 +99,17 @@ class SAMv3DatagramServer implements Handler { { this.server = server ; } - public void run() - { + + public void run() { + I2PAppContext.getGlobalContext().portMapper().register(PortMapper.SVC_SAM_UDP, _host, _port); + try { + run2(); + } finally { + I2PAppContext.getGlobalContext().portMapper().unregister(PortMapper.SVC_SAM_UDP); + } + } + + private void run2() { ByteBuffer inBuf = ByteBuffer.allocateDirect(SAMRawSession.RAW_SIZE_MAX+1024); while (!Thread.interrupted()) diff --git a/apps/sam/java/src/net/i2p/sam/client/SAMStreamSend.java b/apps/sam/java/src/net/i2p/sam/client/SAMStreamSend.java index 8b912f4019..761e50e814 100644 --- a/apps/sam/java/src/net/i2p/sam/client/SAMStreamSend.java +++ b/apps/sam/java/src/net/i2p/sam/client/SAMStreamSend.java @@ -69,7 +69,7 @@ public class SAMStreamSend { String port = "7656"; String user = null; String password = null; - String opts = ""; + String opts = "inbound.length=0 outbound.length=0"; int c; while ((c = g.getopt()) != -1) { switch (c) { diff --git a/apps/sam/java/src/net/i2p/sam/client/SAMStreamSink.java b/apps/sam/java/src/net/i2p/sam/client/SAMStreamSink.java index 56492162e8..d59ebb0a37 100644 --- a/apps/sam/java/src/net/i2p/sam/client/SAMStreamSink.java +++ b/apps/sam/java/src/net/i2p/sam/client/SAMStreamSink.java @@ -77,7 +77,7 @@ public class SAMStreamSink { String port = "7656"; String user = null; String password = null; - String opts = ""; + String opts = "inbound.length=0 outbound.length=0"; int c; while ((c = g.getopt()) != -1) { switch (c) { diff --git a/core/java/src/net/i2p/util/PortMapper.java b/core/java/src/net/i2p/util/PortMapper.java index e73399b19c..28127dd0e5 100644 --- a/core/java/src/net/i2p/util/PortMapper.java +++ b/core/java/src/net/i2p/util/PortMapper.java @@ -30,6 +30,10 @@ public class PortMapper { public static final String SVC_SMTP = "SMTP"; public static final String SVC_POP = "POP3"; public static final String SVC_SAM = "SAM"; + /** @since 0.9.24 */ + public static final String SVC_SAM_UDP = "SAM-UDP"; + /** @since 0.9.24 */ + public static final String SVC_SAM_SSL = "SAM-SSL"; public static final String SVC_BOB = "BOB"; /** not necessary, already in config? */ public static final String SVC_I2CP = "I2CP"; diff --git a/history.txt b/history.txt index f949b517cd..31be99462d 100644 --- a/history.txt +++ b/history.txt @@ -1,7 +1,33 @@ +2015-12-01 zzz + * i2psnark: + - Consolidate default tunnel length definition + - Increase max peers and uploaders per torrent + - Increase default max total uploaders + - Increase max peers sent and returned in DHT +* SAM: + - Don't map keys to upper case in parser, corrupts I2CP options + - Register SSL and UDP ports with PortMapper +* SSU: Allow IP and port in relay request if it matches the source +* Transport: Interrupt DH refiller thread when pool is empty, + to speed refilling and reduce pumper stalls + +2015-11-30 zzz + * SAM: + - Timeout for first command after HELLO + - Send error message if no NAME key in LOOKUP + - Destination caching enhancements + - Client: Add SSL forward support, handle header line in forwarded stream + +2015-11-29 zzz + * i2ptunnel: + - Change preferred sig type to Ed + - Set permissions on backup tunnel keys file + 2015-11-28 zzz * i2psnark: - Fix NPE caused by URL-to-URI conversion in -2 (ticket #1715) - Increase max pieces to 32K + - BEP 21 support (upload_only) * SAM: - Fix parser to allow spaces in quoted values (tickets #1325, #1488) - Handle UTF-8 in ReadLine (ticket #1488) diff --git a/router/java/src/net/i2p/router/RouterVersion.java b/router/java/src/net/i2p/router/RouterVersion.java index 4e28a2c8d2..c10128fe62 100644 --- a/router/java/src/net/i2p/router/RouterVersion.java +++ b/router/java/src/net/i2p/router/RouterVersion.java @@ -18,7 +18,7 @@ public class RouterVersion { /** deprecated */ public final static String ID = "Monotone"; public final static String VERSION = CoreVersion.VERSION; - public final static long BUILD = 5; + public final static long BUILD = 6; /** for example "-test" */ public final static String EXTRA = "";