class SAMv3Handler extends SAMv1Handler
| Modifier and Type | Field and Description |
|---|---|
(package private) boolean | sendPortspackage-visible for SAMHandlerPool |
static SessionsDB | sSessionsHashsSessionsHash |
(package private) boolean | stolenSocketStolen socket. |
(package private) boolean | streamForwardingSocketStream forwarding socket. |
_id, datagramSession, rawSession, SESSION_ERROR, streamSession_log, bridge, i2cpProps, socket, stopHandler, stopLock, thread, verMajor, verMinor| Constructor and Description |
|---|
SAMv3Handler(SocketChannel s,
int verMajor,
int verMinor,
Properties i2cpProps,
SAMBridge parent)Create a new SAM version 3 handler. |
SAMv3Handler(SocketChannel s,
int verMajor,
int verMinor,
SAMBridge parent)Create a new SAM version 3 handler. |
| Modifier and Type | Method and Description |
|---|---|
protected boolean | execSessionMessage(String opcode,
Properties props)Parse and execute a SESSION message. |
protected boolean | execStreamConnect(Properties props)Parse and execute a STREAM CONNECT message. |
protected boolean | execStreamMessage(String opcode,
Properties props)Parse and execute a STREAM message. |
(package private) SAMBridge | getBridge()For SAMv3StreamSession |
String | getClientIP()Get the IP address of the connected SAM client. |
(package private) Session | getSession()For SAMv3DatagramServer |
void | handle()Legacy handle() method. |
(package private) boolean | hasActiveStream() |
void | notifyStreamIncomingConnection(Destination d,
int fromPort,
int toPort)notifyStreamIncomingConnection. |
static void | notifyStreamIncomingConnection(SocketChannel client,
Destination d)Notify the SAM client of an incoming stream connection on a static channel. |
static void | notifyStreamIncomingConnection(SocketChannel client,
Destination d,
int fromPort,
int toPort)Notify the SAM client of an incoming stream connection with port information. |
void | notifyStreamResult(boolean verbose,
String result,
String message) |
(package private) boolean | processLine(String line)Process a single complete command line dispatched by the pool
or the legacy handle() loop. |
(package private) void | setSession(SAMv3DatagramSession sess)For subsessions created by MasterSession |
(package private) void | setSession(SAMv3RawSession sess)For subsessions created by MasterSession |
(package private) void | setSession(SAMv3StreamSession sess)For subsessions created by MasterSession |
void | stealSocket()For SAMv3StreamSession connect and accept |
void | stopHandling()Stop the SAM handler, close the socket (unless stolen),
unregister from the bridge and the handler pool. |
boolean | verifVersion()Verify the SAM protocol version is supported by this handler. |
createMessageString, execDatagramMessage, execDestMessage, execNamingMessage, execRawMessage, execStreamClose, execStreamSend, getDatagramSession, getRawSession, getStreamSession, notifyStreamDisconnection, notifyStreamIncomingConnection, notifyStreamOutgoingConnection, notifyStreamSendBufferFree, receiveDatagramBytes, receiveRawBytes, receiveStreamBytes, stopDatagramReceiving, stopRawReceiving, stopStreamReceiving, streamSendAnswer, writeStringcloseClientSocket, getClientSocket, getWriteLock, run, shouldStop, startHandling, toString, writeBytes, writeString, writeStringfinal boolean sendPorts
SAMHandlerPoolpublic static final SessionsDB sSessionsHash
volatile boolean stolenSocket
volatile boolean streamForwardingSocket
public SAMv3Handler(SocketChannel s, int verMajor, int verMinor, Properties i2cpProps, SAMBridge parent) throws SAMException, IOException
s - Socket attached to a SAM clientverMajor - SAM major version to manage (should be 3)verMinor - SAM minor version to managei2cpProps - properties to configure the I2CP connection (host, port, etc)SAMException - if the version is not supportedIOException - if an I/O error occurspublic SAMv3Handler(SocketChannel s, int verMajor, int verMinor, SAMBridge parent) throws SAMException, IOException
s - Socket attached to a SAM clientverMajor - SAM major version to manage (should be 3)verMinor - SAM minor version to manageSAMException - if the version is not supportedIOException - if an I/O error occursprotected boolean execSessionMessage(String opcode, Properties props)
execSessionMessage in class SAMv1Handleropcode - the SESSION sub-command (e.g. CREATE, ADD, REMOVE)props - the parsed message propertiesprotected boolean execStreamConnect(Properties props)
execStreamConnect in class SAMv1Handlerprops - the parsed message propertiesprotected boolean execStreamMessage(String opcode, Properties props)
execStreamMessage in class SAMv1Handleropcode - the STREAM sub-command (e.g. CONNECT, ACCEPT, FORWARD)props - the parsed message propertiesSAMBridge getBridge()
public String getClientIP()
Session getSession()
public void handle()
SAMHandlerPool, which dispatches via processLine().
Retained to fulfill the abstract contract in SAMHandler.handle in class SAMv1Handlerboolean hasActiveStream()
public void notifyStreamIncomingConnection(Destination d, int fromPort, int toPort) throws IOException
IOExceptionpublic static void notifyStreamIncomingConnection(SocketChannel client, Destination d) throws IOException
client - the clientd - the destination of the remote peerIOException - if writing to the client socket failspublic static void notifyStreamIncomingConnection(SocketChannel client, Destination d, int fromPort, int toPort) throws IOException
client - the clientd - the destination of the remote peerfromPort - the source porttoPort - the destination portIOException - if writing to the client socket failspublic void notifyStreamResult(boolean verbose,
String result,
String message)
throws IOExceptionverbose - if false, does nothingresult - non-nullmessage - may be nullIOExceptionboolean processLine(String line)
line - the complete command line (without trailing newline)void setSession(SAMv3DatagramSession sess)
void setSession(SAMv3RawSession sess)
void setSession(SAMv3StreamSession sess)
public void stealSocket()
public void stopHandling()
stopHandling in interface HandlerstopHandling in class SAMHandlerpublic boolean verifVersion()
verifVersion in class SAMv1Handler