forked from I2P_Developers/i2p.i2p
SAM: Set keepalive on sockets (ticket #1573)
Also on both sides of I2CP. BOB already does it.
This commit is contained in:
@ -46,6 +46,7 @@ class SAMHandlerFactory {
|
|||||||
try {
|
try {
|
||||||
Socket sock = s.socket();
|
Socket sock = s.socket();
|
||||||
sock.setSoTimeout(HELLO_TIMEOUT);
|
sock.setSoTimeout(HELLO_TIMEOUT);
|
||||||
|
sock.setKeepAlive(true);
|
||||||
String line = DataHelper.readLine(sock.getInputStream());
|
String line = DataHelper.readLine(sock.getInputStream());
|
||||||
sock.setSoTimeout(0);
|
sock.setSoTimeout(0);
|
||||||
if (line == null) {
|
if (line == null) {
|
||||||
|
@ -263,6 +263,7 @@ class SAMv3StreamSession extends SAMStreamSession implements SAMv3Handler.Sessi
|
|||||||
|
|
||||||
// build pipes between both sockets
|
// build pipes between both sockets
|
||||||
try {
|
try {
|
||||||
|
clientServerSock.socket().setKeepAlive(true);
|
||||||
if (this.verbose)
|
if (this.verbose)
|
||||||
SAMv3Handler.notifyStreamIncomingConnection(
|
SAMv3Handler.notifyStreamIncomingConnection(
|
||||||
clientServerSock, i2ps.getPeerDestination());
|
clientServerSock, i2ps.getPeerDestination());
|
||||||
|
@ -488,6 +488,7 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2
|
|||||||
try {
|
try {
|
||||||
I2PSSLSocketFactory fact = new I2PSSLSocketFactory(_context, false, "certificates/i2cp");
|
I2PSSLSocketFactory fact = new I2PSSLSocketFactory(_context, false, "certificates/i2cp");
|
||||||
_socket = fact.createSocket(_hostname, _portNum);
|
_socket = fact.createSocket(_hostname, _portNum);
|
||||||
|
_socket.setKeepAlive(true);
|
||||||
} catch (GeneralSecurityException gse) {
|
} catch (GeneralSecurityException gse) {
|
||||||
IOException ioe = new IOException("SSL Fail");
|
IOException ioe = new IOException("SSL Fail");
|
||||||
ioe.initCause(gse);
|
ioe.initCause(gse);
|
||||||
@ -495,6 +496,7 @@ public abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
_socket = new Socket(_hostname, _portNum);
|
_socket = new Socket(_hostname, _portNum);
|
||||||
|
_socket.setKeepAlive(true);
|
||||||
}
|
}
|
||||||
// _socket.setSoTimeout(1000000); // Uhmmm we could really-really use a real timeout, and handle it.
|
// _socket.setSoTimeout(1000000); // Uhmmm we could really-really use a real timeout, and handle it.
|
||||||
OutputStream out = _socket.getOutputStream();
|
OutputStream out = _socket.getOutputStream();
|
||||||
|
@ -89,6 +89,7 @@ class I2PSimpleSession extends I2PSessionImpl2 {
|
|||||||
} else {
|
} else {
|
||||||
_socket = new Socket(_hostname, _portNum);
|
_socket = new Socket(_hostname, _portNum);
|
||||||
}
|
}
|
||||||
|
_socket.setKeepAlive(true);
|
||||||
OutputStream out = _socket.getOutputStream();
|
OutputStream out = _socket.getOutputStream();
|
||||||
out.write(I2PClient.PROTOCOL_BYTE);
|
out.write(I2PClient.PROTOCOL_BYTE);
|
||||||
out.flush();
|
out.flush();
|
||||||
|
@ -93,6 +93,7 @@ class ClientListenerRunner implements Runnable {
|
|||||||
if (validate(socket)) {
|
if (validate(socket)) {
|
||||||
if (_log.shouldLog(Log.DEBUG))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.debug("Connection received");
|
_log.debug("Connection received");
|
||||||
|
socket.setKeepAlive(true);
|
||||||
runConnection(socket);
|
runConnection(socket);
|
||||||
} else {
|
} else {
|
||||||
if (_log.shouldLog(Log.WARN))
|
if (_log.shouldLog(Log.WARN))
|
||||||
|
Reference in New Issue
Block a user