Changeset ceb7791


Ignore:
Timestamp:
Feb 6, 2016 3:08:23 PM (4 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
edde533
Parents:
68c6179
Message:

test tweaks

Location:
apps/sam/java/src/net/i2p/sam
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • apps/sam/java/src/net/i2p/sam/SAMStreamSession.java

    r68c6179 rceb7791  
    365365    /**
    366366     *  Unsupported
    367      *  @throws DataFormatException always
     367     *  @throws I2PSessionException always
    368368     *  @since 0.9.25 moved from subclass SAMv3StreamSession to implement SAMMessageSess
    369369     */
    370     public boolean sendBytes(String s, byte[] b, int pr, int fp, int tp) throws DataFormatException {
    371         throw new DataFormatException(null);
     370    public boolean sendBytes(String s, byte[] b, int pr, int fp, int tp) throws I2PSessionException {
     371        throw new I2PSessionException("Unsupported in stream or master session");
    372372    }
    373373
  • apps/sam/java/src/net/i2p/sam/client/SAMStreamSend.java

    r68c6179 rceb7791  
    5757    private static final int STREAM=0, DG=1, V1DG=2, RAW=3, V1RAW=4;
    5858    private static final int MASTER=8;
    59     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" +
     59    private static final String USAGE = "Usage: SAMStreamSend [-s] [-x] [-m mode] [-v version] [-b samHost] [-p samPort]\n" +
     60                                        "                     [-o opt=val] [-u user] [-w password] peerDestFile dataDir\n" +
    6061                                        "       modes: stream: 0; datagram: 1; v1datagram: 2; raw: 3; v1raw: 4\n" +
     62                                        "              default is stream\n" +
    6163                                        "       -s: use SSL\n" +
    6264                                        "       -x: use master session (forces -v 3.3)\n" +
     
    6466
    6567    public static void main(String args[]) {
    66         Getopt g = new Getopt("SAM", args, "sxb:m:o:p:u:v:w:");
     68        Getopt g = new Getopt("SAM", args, "sxhb:m:o:p:u:v:w:");
    6769        boolean isSSL = false;
    6870        boolean isMaster = false;
    6971        int mode = STREAM;
    70         String version = "1.0";
     72        String version = "3.3";
    7173        String host = "127.0.0.1";
    7274        String port = "7656";
     
    293295                else if (mode == DG || mode == V1DG)
    294296                    style = "DATAGRAM";
    295                 else
     297                else   // RAW or V1RAW
    296298                    style = "RAW";
    297299
    298300                if (masterMode) {
     301                    if (mode == V1DG || mode == V1RAW)
     302                        throw new IllegalArgumentException("v1 dg/raw incompatible with master session");
    299303                    String req = "SESSION CREATE DESTINATION=TRANSIENT STYLE=MASTER ID=masterSend " + opts + '\n';
    300304                    samOut.write(req.getBytes("UTF-8"));
     
    307311                    if (_log.shouldLog(Log.DEBUG))
    308312                        _log.debug("SESSION CREATE STYLE=MASTER reply found: " + ok);
     313                    // PORT required even if we aren't listening for this test
     314                    if (mode != STREAM)
     315                        opts += " PORT=9999";
    309316                }
    310317                String req = "SESSION " + command + " STYLE=" + style + ' ' + _conOptions + ' ' + opts + '\n';
  • apps/sam/java/src/net/i2p/sam/client/SAMStreamSink.java

    r68c6179 rceb7791  
    6565                                        "              raw: 3; v1raw: 4; raw-with-headers: 5;\n" +
    6666                                        "              stream-forward: 6; stream-forward-ssl: 7\n" +
     67                                        "              default is stream\n" +
    6768                                        "       -s: use SSL to connect to bridge\n" +
    6869                                        "       -x: use master session (forces -v 3.3)\n" +
     
    7273
    7374    public static void main(String args[]) {
    74         Getopt g = new Getopt("SAM", args, "sxb:m:p:u:v:w:");
     75        Getopt g = new Getopt("SAM", args, "sxhb:m:p:u:v:w:");
    7576        boolean isSSL = false;
    7677        boolean isMaster = false;
    7778        int mode = STREAM;
    78         String version = "1.0";
     79        String version = "3.3";
    7980        String host = "127.0.0.1";
    8081        String port = "7656";
     
    683684
    684685                if (masterMode) {
     686                    if (mode == V1DG || mode == V1RAW)
     687                        throw new IllegalArgumentException("v1 dg/raw incompatible with master session");
    685688                    String req = "SESSION CREATE DESTINATION=" + dest + " STYLE=MASTER ID=masterSink " + sopts + '\n';
    686689                    samOut.write(req.getBytes("UTF-8"));
Note: See TracChangeset for help on using the changeset viewer.