SAMv3: stream session stop listening when the forwarding session closes. Doc has to be changed to reflect this.
This commit is contained in:
@ -62,9 +62,8 @@ public class SAMv3DatagramSession extends SAMDatagramSession implements SAMv3Han
|
|||||||
|
|
||||||
String host = props.getProperty("HOST");
|
String host = props.getProperty("HOST");
|
||||||
if ( host==null ) {
|
if ( host==null ) {
|
||||||
_log.debug("no host specified. Take from the client socket");
|
|
||||||
|
|
||||||
host = rec.getHandler().getClientIP();
|
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 stolenSocket = false ;
|
||||||
|
|
||||||
|
boolean streamForwardingSocket = false ;
|
||||||
|
|
||||||
public void stealSocket()
|
public void stealSocket()
|
||||||
{
|
{
|
||||||
stolenSocket = true ;
|
stolenSocket = true ;
|
||||||
@ -414,6 +416,20 @@ public class SAMv3Handler extends SAMv1Handler
|
|||||||
_log.error("Error closing socket: " + e.getMessage());
|
_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();
|
die();
|
||||||
}
|
}
|
||||||
@ -692,9 +708,10 @@ public class SAMv3Handler extends SAMv1Handler
|
|||||||
protected boolean execStreamForwardIncoming( Properties props ) {
|
protected boolean execStreamForwardIncoming( Properties props ) {
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
|
streamForwardingSocket = true ;
|
||||||
streamSession.startForwardingIncoming(props);
|
streamSession.startForwardingIncoming(props);
|
||||||
notifyStreamResult( true, "OK", null );
|
notifyStreamResult( true, "OK", null );
|
||||||
return false ;
|
return true ;
|
||||||
} catch (SAMException e) {
|
} catch (SAMException e) {
|
||||||
_log.debug("Forwarding STREAM connections failed: " + e.getMessage());
|
_log.debug("Forwarding STREAM connections failed: " + e.getMessage());
|
||||||
notifyStreamResult ( true, "I2P_ERROR", "Forwarding 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");
|
String host = props.getProperty("HOST");
|
||||||
if ( host==null ) {
|
if ( host==null ) {
|
||||||
_log.debug("no host specified. Take from the client socket");
|
|
||||||
|
|
||||||
host = rec.getHandler().getClientIP();
|
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");
|
String host = props.getProperty("HOST");
|
||||||
if ( host==null ) {
|
if ( host==null ) {
|
||||||
_log.debug("no host specified. Take from the client socket");
|
|
||||||
|
|
||||||
host = rec.getHandler().getClientIP();
|
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
|
* Close the stream session
|
||||||
|
Reference in New Issue
Block a user