All Implemented Interfaces:
Runnable, Handler, SAMDatagramReceiver, SAMRawReceiver, SAMStreamReceiver

class SAMv2Handlerextends SAMv1Handler implements SAMRawReceiver, SAMDatagramReceiver, SAMStreamReceiver
SAM version 2 handler.
  • Constructor Details

    • SAMv2Handler

      public SAMv2Handler(SocketChannel s, int verMajor, int verMinor, SAMBridge parent) throws SAMException, IOException
      Create a new SAM version 2 handler with default I2CP properties. This constructor expects that the SAM HELLO message has been still answered (and stripped) from the socket input stream.
      Parameters:
      s - Socket attached to a SAM client
      verMajor - SAM major version to manage (should be 2)
      verMinor - SAM minor version to manage
      parent - bridge holding the shared SAM server state this handler joins
      Throws:
      SAMException - if the version is not supported
      IOException - if an I/O error occurs
    • SAMv2Handler

      public SAMv2Handler(SocketChannel s, int verMajor, int verMinor, Properties i2cpProps, SAMBridge parent) throws SAMException, IOException
      Create a new SAM version 2 handler. This constructor expects that the SAM HELLO message has been still answered (and stripped) from the socket input stream.
      Parameters:
      s - Socket attached to a SAM client
      verMajor - SAM major version to manage (should be 2)
      verMinor - SAM minor version to manage
      i2cpProps - properties to configure the I2CP connection (host, port, etc)
      parent - bridge holding the shared SAM server state this handler joins
      Throws:
      SAMException - if the version is not supported
      IOException - if an I/O error occurs
  • Method Details

    • verifVersion

      public boolean verifVersion()
      Verify the SAM protocol version is supported by this handler.
      Overrides:
      verifVersion in class SAMv1Handler
      Returns:
      true if the major version matches this handler's version
    • newSAMv2StreamSession

      SAMStreamSession newSAMv2StreamSession(String destKeystream, String direction, Properties props) throws IOException, DataFormatException, SAMException
      New SAMv2 stream session.
      Parameters:
      destKeystream - the destination and private key stream of the peer
      direction - the STREAM connection direction, "INBOUND" or "OUTBOUND"
      props - the parsed STREAM message properties, including the port and options
      Returns:
      the newly created STREAM session
      Throws:
      IOException - if the destination cannot be read from the keystream
      DataFormatException - if the keystream is not in the expected key file format
      SAMException - if a session with this nickname is already registered
    • execStreamMessage

      protected boolean execStreamMessage(String opcode, Properties props)
      Parse and execute a STREAM message.
      Overrides:
      execStreamMessage in class SAMv1Handler
      Parameters:
      opcode - the STREAM sub-command
      props - the parsed message properties
      Returns:
      true if the handler should continue processing commands
    • execStreamReceive

      private boolean execStreamReceive(Properties props)
      Execute STREAM RECEIVE message.
      Parameters:
      props - the parameters parsed from the message
      Returns:
      true if the receive was set up, false if the parameters were bad