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 9c36091d02619e75c37c4d008b67e9f0a2b583aa..c031ea8c690ac133da50793eb1e2f8e33372b696 100644 --- a/apps/sam/java/src/net/i2p/sam/client/SAMStreamSend.java +++ b/apps/sam/java/src/net/i2p/sam/client/SAMStreamSend.java @@ -227,7 +227,13 @@ public class SAMStreamSend { _context.statManager().createRateStat("send." + _connectionId + ".started", "When we start", "swarm", new long[] { 5*60*1000 }); _context.statManager().createRateStat("send." + _connectionId + ".lifetime", "How long we talk to a peer", "swarm", new long[] { 5*60*1000 }); - byte msg[] = ("STREAM CONNECT ID=" + _connectionId + " DESTINATION=" + _remoteDestination + "\n").getBytes(); + StringBuilder buf = new StringBuilder(1024); + buf.append("STREAM CONNECT ID=").append(_connectionId).append(" DESTINATION=").append(_remoteDestination); + // not supported until 3.2 but 3.0-3.1 will ignore + if (_isV3) + buf.append(" FROM_PORT=1234 TO_PORT=5678"); + buf.append('\n'); + byte[] msg = DataHelper.getASCII(buf.toString()); synchronized (_samOut) { _samOut.write(msg); _samOut.flush(); 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 1289691ea6384bf004ac8110b85e76e8b743c257..24500eb62d889029bbfbeece66a51ffd4f8620ce 100644 --- a/apps/sam/java/src/net/i2p/sam/client/SAMStreamSink.java +++ b/apps/sam/java/src/net/i2p/sam/client/SAMStreamSink.java @@ -258,7 +258,8 @@ public class SAMStreamSink { if (!isMaster) { // only for v3 //String req = "STREAM ACCEPT SILENT=true ID=" + _v3ID + "\n"; - String req = "STREAM ACCEPT SILENT=false ID=" + _v3ID + "\n"; + // TO_PORT not supported until 3.2 but 3.0-3.1 will ignore + String req = "STREAM ACCEPT SILENT=false TO_PORT=5678 ID=" + _v3ID + "\n"; samOut.write(req.getBytes()); samOut.flush(); if (_log.shouldLog(Log.DEBUG)) @@ -268,7 +269,7 @@ public class SAMStreamSink { //if (!ok) // throw new IOException("Stream status failed"); if (_log.shouldLog(Log.DEBUG)) - _log.debug("got STREAM STATUS, awaiting connetion"); + _log.debug("got STREAM STATUS, awaiting connection"); return "OK"; } _isV3 = VersionComparator.comp(hisVersion, "3") >= 0;