java.lang.Object
net.i2p.sam.SAMHandlerFactory

class SAMHandlerFactoryextends Object
SAM handler factory class.
  • Field Details

    • VERSION

      private static final String VERSION
      SAM protocol version announced in the hello message
      See Also:
    • HELLO_TIMEOUT

      private static final int HELLO_TIMEOUT
      Milliseconds to wait for the hello command
      See Also:
  • Constructor Details

  • Method Details

    • createSAMHandler

      public static SAMHandler createSAMHandler(SocketChannel s, Properties i2cpProps, SAMBridge parent) throws SAMException
      Return the right SAM handler depending on the protocol version required by the client.
      Parameters:
      s - Socket attached to SAM client
      i2cpProps - config options for our i2cp connection
      parent - the bridge owning this session, supplying the secure session for authentication
      Returns:
      A SAM protocol handler, or null if the client closed before the handshake
      Throws:
      SAMException - if the connection handshake (HELLO message) was malformed
    • chooseBestVersion

      private static String chooseBestVersion(String minVer, String maxVer)
      Choose the best SAM protocol version supported by both client and server.
      Parameters:
      minVer - minimum version the client supports
      maxVer - maximum version the client supports
      Returns:
      "x.y" the best version we can use, or null on failure
    • getMajor

      private static int getMajor(String ver)
      Get the major protocol version from a version string.
      Parameters:
      ver - version string in "major.minor" format
      Returns:
      the major version number, or -1 on error
    • getMinor

      private static int getMinor(String ver)
      Get the minor protocol version from a version string.
      Parameters:
      ver - version string in "major.minor" format
      Returns:
      the minor version number, or -1 on error