java.lang.Object
net.i2p.sam.SAMHandlerFactory
SAM handler factory class.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intMilliseconds to wait for the hello commandprivate static final StringSAM protocol version announced in the hello messageConstructor Summary
ConstructorsConstructorDescriptioncreateSAMHandler(SocketChannel, Properties, SAMBridge)is static and the class holds only the protocol version and handshake timeout, so an instance carries nothing.Method Summary
Modifier and TypeMethodDescriptionprivate static StringchooseBestVersion(String minVer, String maxVer) Choose the best SAM protocol version supported by both client and server.static SAMHandlercreateSAMHandler(SocketChannel s, Properties i2cpProps, SAMBridge parent) Return the right SAM handler depending on the protocol version required by the client.private static intGet the major protocol version from a version string.private static intGet the minor protocol version from a version string.
Field Details
VERSION
SAM protocol version announced in the hello message- See Also:
HELLO_TIMEOUT
private static final int HELLO_TIMEOUTMilliseconds to wait for the hello command- See Also:
Constructor Details
SAMHandlerFactory
SAMHandlerFactory()createSAMHandler(SocketChannel, Properties, SAMBridge)is static and the class holds only the protocol version and handshake timeout, so an instance carries nothing.
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 clienti2cpProps- config options for our i2cp connectionparent- 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
Choose the best SAM protocol version supported by both client and server.- Parameters:
minVer- minimum version the client supportsmaxVer- maximum version the client supports- Returns:
- "x.y" the best version we can use, or null on failure
getMajor
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
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