I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 0c738e2c authored by mkvore-commit's avatar mkvore-commit
Browse files

SAMv3: stream session stop listening when the forwarding session closes. Doc...

SAMv3: stream session stop listening when the forwarding session closes. Doc has to be changed to reflect this.
parent 7cdfe45a
No related branches found
No related tags found
No related merge requests found
......@@ -61,10 +61,9 @@ public class SAMv3DatagramSession extends SAMDatagramSession implements SAMv3Han
int port = Integer.parseInt(portStr);
String host = props.getProperty("HOST");
if ( host==null ) {
_log.debug("no host specified. Take from the client socket");
if ( host==null ) {
host = rec.getHandler().getClientIP();
_log.debug("no host specified. Taken from the client socket : " + host+':'+port);
}
......
......@@ -323,6 +323,8 @@ public class SAMv3Handler extends SAMv1Handler
boolean stolenSocket = false ;
boolean streamForwardingSocket = false ;
public void stealSocket()
{
stolenSocket = true ;
......@@ -414,6 +416,20 @@ public class SAMv3Handler extends SAMv1Handler
_log.error("Error closing socket: " + e.getMessage());
}
}
if (streamForwardingSocket)
{
if (this.streamSession!=null) {
try {
this.streamSession.stopForwardingIncoming();
} catch (SAMException e) {
_log.error("Error while stopping forwarding connections: " + e.getMessage());
} catch (InterruptedIOException e) {
_log.error("Interrupted while stopping forwarding connections: " + e.getMessage());
}
}
}
die();
}
......@@ -692,9 +708,10 @@ public class SAMv3Handler extends SAMv1Handler
protected boolean execStreamForwardIncoming( Properties props ) {
try {
try {
streamForwardingSocket = true ;
streamSession.startForwardingIncoming(props);
notifyStreamResult( true, "OK", null );
return false ;
return true ;
} catch (SAMException e) {
_log.debug("Forwarding STREAM connections failed: " + e.getMessage());
notifyStreamResult ( true, "I2P_ERROR", "Forwarding failed : " + e.getMessage() );
......
......@@ -63,9 +63,9 @@ public class SAMv3RawSession extends SAMRawSession implements SAMv3Handler.Sess
String host = props.getProperty("HOST");
if ( host==null ) {
_log.debug("no host specified. Take from the client socket");
host = rec.getHandler().getClientIP();
_log.debug("no host specified. Taken from the client socket : " + host +':'+port);
}
......
......@@ -230,9 +230,8 @@ public class SAMv3StreamSession extends SAMStreamSession implements SAMv3Handle
String host = props.getProperty("HOST");
if ( host==null ) {
_log.debug("no host specified. Take from the client socket");
host = rec.getHandler().getClientIP();
_log.debug("no host specified. Taken from the client socket : " + host +':'+port);
}
......@@ -368,7 +367,32 @@ public class SAMv3StreamSession extends SAMStreamSession implements SAMv3Handle
}
}
/**
*
* @param props
* @throws SAMException
* @throws InterruptedIOException
*/
public void stopForwardingIncoming() throws SAMException, InterruptedIOException
{
SAMv3Handler.SessionRecord rec = SAMv3Handler.sSessionsHash.get(nick);
if ( rec==null ) throw new InterruptedIOException() ;
I2PServerSocket server = null ;
synchronized( this.socketServerLock )
{
if (this.socketServer==null) {
_log.debug("no socket server is defined for this destination");
throw new SAMException("no socket server is defined for this destination");
}
server = this.socketServer ;
this.socketServer = null ;
}
try {
server.close();
} catch ( I2PException e) {}
}
/**
* Close the stream session
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment