forked from I2P_Developers/i2p.i2p
test tweaks
This commit is contained in:
@@ -364,11 +364,11 @@ class SAMStreamSession implements SAMMessageSess {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Unsupported
|
* Unsupported
|
||||||
* @throws DataFormatException always
|
* @throws I2PSessionException always
|
||||||
* @since 0.9.25 moved from subclass SAMv3StreamSession to implement SAMMessageSess
|
* @since 0.9.25 moved from subclass SAMv3StreamSession to implement SAMMessageSess
|
||||||
*/
|
*/
|
||||||
public boolean sendBytes(String s, byte[] b, int pr, int fp, int tp) throws DataFormatException {
|
public boolean sendBytes(String s, byte[] b, int pr, int fp, int tp) throws I2PSessionException {
|
||||||
throw new DataFormatException(null);
|
throw new I2PSessionException("Unsupported in stream or master session");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -56,18 +56,20 @@ public class SAMStreamSend {
|
|||||||
|
|
||||||
private static final int STREAM=0, DG=1, V1DG=2, RAW=3, V1RAW=4;
|
private static final int STREAM=0, DG=1, V1DG=2, RAW=3, V1RAW=4;
|
||||||
private static final int MASTER=8;
|
private static final int MASTER=8;
|
||||||
private static final String USAGE = "Usage: SAMStreamSend [-s] [-x] [-m mode] [-v version] [-b samHost] [-p samPort] [-o opt=val] [-u user] [-w password] peerDestFile dataDir\n" +
|
private static final String USAGE = "Usage: SAMStreamSend [-s] [-x] [-m mode] [-v version] [-b samHost] [-p samPort]\n" +
|
||||||
|
" [-o opt=val] [-u user] [-w password] peerDestFile dataDir\n" +
|
||||||
" modes: stream: 0; datagram: 1; v1datagram: 2; raw: 3; v1raw: 4\n" +
|
" modes: stream: 0; datagram: 1; v1datagram: 2; raw: 3; v1raw: 4\n" +
|
||||||
|
" default is stream\n" +
|
||||||
" -s: use SSL\n" +
|
" -s: use SSL\n" +
|
||||||
" -x: use master session (forces -v 3.3)\n" +
|
" -x: use master session (forces -v 3.3)\n" +
|
||||||
" multiple -o session options are allowed";
|
" multiple -o session options are allowed";
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
Getopt g = new Getopt("SAM", args, "sxb:m:o:p:u:v:w:");
|
Getopt g = new Getopt("SAM", args, "sxhb:m:o:p:u:v:w:");
|
||||||
boolean isSSL = false;
|
boolean isSSL = false;
|
||||||
boolean isMaster = false;
|
boolean isMaster = false;
|
||||||
int mode = STREAM;
|
int mode = STREAM;
|
||||||
String version = "1.0";
|
String version = "3.3";
|
||||||
String host = "127.0.0.1";
|
String host = "127.0.0.1";
|
||||||
String port = "7656";
|
String port = "7656";
|
||||||
String user = null;
|
String user = null;
|
||||||
@@ -292,10 +294,12 @@ public class SAMStreamSend {
|
|||||||
style = "STREAM";
|
style = "STREAM";
|
||||||
else if (mode == DG || mode == V1DG)
|
else if (mode == DG || mode == V1DG)
|
||||||
style = "DATAGRAM";
|
style = "DATAGRAM";
|
||||||
else
|
else // RAW or V1RAW
|
||||||
style = "RAW";
|
style = "RAW";
|
||||||
|
|
||||||
if (masterMode) {
|
if (masterMode) {
|
||||||
|
if (mode == V1DG || mode == V1RAW)
|
||||||
|
throw new IllegalArgumentException("v1 dg/raw incompatible with master session");
|
||||||
String req = "SESSION CREATE DESTINATION=TRANSIENT STYLE=MASTER ID=masterSend " + opts + '\n';
|
String req = "SESSION CREATE DESTINATION=TRANSIENT STYLE=MASTER ID=masterSend " + opts + '\n';
|
||||||
samOut.write(req.getBytes("UTF-8"));
|
samOut.write(req.getBytes("UTF-8"));
|
||||||
samOut.flush();
|
samOut.flush();
|
||||||
@@ -306,6 +310,9 @@ public class SAMStreamSend {
|
|||||||
throw new IOException("SESSION CREATE STYLE=MASTER failed");
|
throw new IOException("SESSION CREATE STYLE=MASTER failed");
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("SESSION CREATE STYLE=MASTER reply found: " + ok);
|
_log.debug("SESSION CREATE STYLE=MASTER reply found: " + ok);
|
||||||
|
// PORT required even if we aren't listening for this test
|
||||||
|
if (mode != STREAM)
|
||||||
|
opts += " PORT=9999";
|
||||||
}
|
}
|
||||||
String req = "SESSION " + command + " STYLE=" + style + ' ' + _conOptions + ' ' + opts + '\n';
|
String req = "SESSION " + command + " STYLE=" + style + ' ' + _conOptions + ' ' + opts + '\n';
|
||||||
samOut.write(req.getBytes("UTF-8"));
|
samOut.write(req.getBytes("UTF-8"));
|
||||||
|
@@ -64,6 +64,7 @@ public class SAMStreamSink {
|
|||||||
" modes: stream: 0; datagram: 1; v1datagram: 2;\n" +
|
" modes: stream: 0; datagram: 1; v1datagram: 2;\n" +
|
||||||
" raw: 3; v1raw: 4; raw-with-headers: 5;\n" +
|
" raw: 3; v1raw: 4; raw-with-headers: 5;\n" +
|
||||||
" stream-forward: 6; stream-forward-ssl: 7\n" +
|
" stream-forward: 6; stream-forward-ssl: 7\n" +
|
||||||
|
" default is stream\n" +
|
||||||
" -s: use SSL to connect to bridge\n" +
|
" -s: use SSL to connect to bridge\n" +
|
||||||
" -x: use master session (forces -v 3.3)\n" +
|
" -x: use master session (forces -v 3.3)\n" +
|
||||||
" multiple -o session options are allowed";
|
" multiple -o session options are allowed";
|
||||||
@@ -71,11 +72,11 @@ public class SAMStreamSink {
|
|||||||
private static final int V3DGPORT=9999;
|
private static final int V3DGPORT=9999;
|
||||||
|
|
||||||
public static void main(String args[]) {
|
public static void main(String args[]) {
|
||||||
Getopt g = new Getopt("SAM", args, "sxb:m:p:u:v:w:");
|
Getopt g = new Getopt("SAM", args, "sxhb:m:p:u:v:w:");
|
||||||
boolean isSSL = false;
|
boolean isSSL = false;
|
||||||
boolean isMaster = false;
|
boolean isMaster = false;
|
||||||
int mode = STREAM;
|
int mode = STREAM;
|
||||||
String version = "1.0";
|
String version = "3.3";
|
||||||
String host = "127.0.0.1";
|
String host = "127.0.0.1";
|
||||||
String port = "7656";
|
String port = "7656";
|
||||||
String user = null;
|
String user = null;
|
||||||
@@ -682,6 +683,8 @@ public class SAMStreamSink {
|
|||||||
style = "RAW HEADER=true PORT=" + V3DGPORT;
|
style = "RAW HEADER=true PORT=" + V3DGPORT;
|
||||||
|
|
||||||
if (masterMode) {
|
if (masterMode) {
|
||||||
|
if (mode == V1DG || mode == V1RAW)
|
||||||
|
throw new IllegalArgumentException("v1 dg/raw incompatible with master session");
|
||||||
String req = "SESSION CREATE DESTINATION=" + dest + " STYLE=MASTER ID=masterSink " + sopts + '\n';
|
String req = "SESSION CREATE DESTINATION=" + dest + " STYLE=MASTER ID=masterSink " + sopts + '\n';
|
||||||
samOut.write(req.getBytes("UTF-8"));
|
samOut.write(req.getBytes("UTF-8"));
|
||||||
samOut.flush();
|
samOut.flush();
|
||||||
|
Reference in New Issue
Block a user