Package net.i2p.sam
Class SAMv3Handler
java.lang.Object
net.i2p.sam.SAMHandler
net.i2p.sam.SAMv1Handler
net.i2p.sam.SAMv3Handler
- All Implemented Interfaces:
Runnable,Handler,SAMDatagramReceiver,SAMRawReceiver,SAMStreamReceiver
class SAMv3Handler extends SAMv1Handler
Class able to handle a SAM version 3 client connection.
- Author:
- mkvore
-
Field Summary
Fields Modifier and Type Field Description static SessionsDBsSessionsHashFields inherited from class net.i2p.sam.SAMv1Handler
_id, datagramSession, rawSession, SESSION_ERROR, streamSessionFields inherited from class net.i2p.sam.SAMHandler
_log, bridge, i2cpProps, socket, stopHandler, stopLock, thread, verMajor, verMinor -
Constructor Summary
Constructors Constructor 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. -
Method Summary
Modifier and Type Method Description protected booleanexecSessionMessage(String opcode, Properties props)protected booleanexecStreamConnect(Properties props)protected booleanexecStreamMessage(String opcode, Properties props)(package private) SAMBridgegetBridge()For SAMv3StreamSessionStringgetClientIP()(package private) SessiongetSession()For SAMv3DatagramServervoidhandle()Actually handle the SAM protocol.static voidnotifyStreamIncomingConnection(SocketChannel client, Destination d)static voidnotifyStreamIncomingConnection(SocketChannel client, Destination d, int fromPort, int toPort)voidnotifyStreamIncomingConnection(Destination d, int fromPort, int toPort)voidnotifyStreamResult(boolean verbose, String result, String message)(package private) voidsetSession(SAMv3DatagramSession sess)For subsessions created by MasterSession(package private) voidsetSession(SAMv3RawSession sess)For subsessions created by MasterSession(package private) voidsetSession(SAMv3StreamSession sess)For subsessions created by MasterSessionvoidstealSocket()For SAMv3StreamSession connect and acceptvoidstopHandling()Stop the SAM handler, close the socket, unregister with the bridge.booleanverifVersion()Methods inherited from class net.i2p.sam.SAMv1Handler
createMessageString, execDatagramMessage, execDestMessage, execNamingMessage, execRawMessage, execStreamClose, execStreamSend, getDatagramSession, getRawSession, getStreamSession, notifyStreamDisconnection, notifyStreamIncomingConnection, notifyStreamOutgoingConnection, notifyStreamSendBufferFree, receiveDatagramBytes, receiveRawBytes, receiveStreamBytes, stopDatagramReceiving, stopRawReceiving, stopStreamReceiving, streamSendAnswer, writeStringMethods inherited from class net.i2p.sam.SAMHandler
closeClientSocket, getClientSocket, getWriteLock, run, shouldStop, startHandling, toString, writeBytes, writeString, writeString
-
Field Details
-
Constructor Details
-
SAMv3Handler
public SAMv3Handler(SocketChannel s, int verMajor, int verMinor, SAMBridge parent) throws SAMException, IOExceptionCreate a new SAM version 3 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 clientverMajor- SAM major version to manage (should be 3)verMinor- SAM minor version to manage- Throws:
SAMExceptionIOException
-
SAMv3Handler
public SAMv3Handler(SocketChannel s, int verMajor, int verMinor, Properties i2cpProps, SAMBridge parent) throws SAMException, IOExceptionCreate a new SAM version 3 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 clientverMajor- SAM major version to manage (should be 3)verMinor- SAM minor version to managei2cpProps- properties to configure the I2CP connection (host, port, etc)- Throws:
SAMExceptionIOException
-
-
Method Details
-
verifVersion
public boolean verifVersion()- Overrides:
verifVersionin classSAMv1Handler
-
getClientIP
-
stealSocket
public void stealSocket()For SAMv3StreamSession connect and accept -
getBridge
SAMBridge getBridge()For SAMv3StreamSession- Since:
- 0.9.20
-
getSession
Session getSession()For SAMv3DatagramServer- Returns:
- may be null
- Since:
- 0.9.24
-
setSession
For subsessions created by MasterSession- Since:
- 0.9.25
-
setSession
For subsessions created by MasterSession- Since:
- 0.9.25
-
setSession
For subsessions created by MasterSession- Since:
- 0.9.25
-
handle
public void handle()Description copied from class:SAMHandlerActually handle the SAM protocol.- Overrides:
handlein classSAMv1Handler
-
stopHandling
public void stopHandling()Stop the SAM handler, close the socket, unregister with the bridge. Overridden to not close the client socket if stolen.- Specified by:
stopHandlingin interfaceHandler- Overrides:
stopHandlingin classSAMHandler- Since:
- 0.9.20
-
execSessionMessage
- Overrides:
execSessionMessagein classSAMv1Handler
-
execStreamMessage
- Overrides:
execStreamMessagein classSAMv1Handler
-
execStreamConnect
- Overrides:
execStreamConnectin classSAMv1Handler
-
notifyStreamResult
- Parameters:
verbose- if false, does nothingresult- non-nullmessage- may be null- Throws:
IOException
-
notifyStreamIncomingConnection
public void notifyStreamIncomingConnection(Destination d, int fromPort, int toPort) throws IOException- Throws:
IOException
-
notifyStreamIncomingConnection
public static void notifyStreamIncomingConnection(SocketChannel client, Destination d) throws IOException- Throws:
IOException
-
notifyStreamIncomingConnection
public static void notifyStreamIncomingConnection(SocketChannel client, Destination d, int fromPort, int toPort) throws IOException- Throws:
IOException- Since:
- 0.9.24
-