forked from I2P_Developers/i2p.i2p
Made all the ministreaming-based apps aware of the new exceptions thrown by
I2PSocketManager.connect() (human)
This commit is contained in:
@@ -49,11 +49,11 @@ public class I2PTunnelClient extends I2PTunnelClientBase {
|
|||||||
try {
|
try {
|
||||||
I2PSocket i2ps = createI2PSocket(dest);
|
I2PSocket i2ps = createI2PSocket(dest);
|
||||||
new I2PTunnelRunner(s, i2ps, sockLock, null);
|
new I2PTunnelRunner(s, i2ps, sockLock, null);
|
||||||
} catch (I2PException ex) {
|
} catch (Exception ex) {
|
||||||
_log.info("Error connecting", ex);
|
_log.info("Error connecting", ex);
|
||||||
l.log("Unable to reach peer");
|
l.log(ex.getMessage());
|
||||||
// s has been initialized before the try block...
|
// s has been initialized before the try block...
|
||||||
closeSocket(s);
|
closeSocket(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,9 @@
|
|||||||
package net.i2p.i2ptunnel;
|
package net.i2p.i2ptunnel;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.net.ConnectException;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
import java.net.NoRouteToHostException;
|
||||||
import java.net.ServerSocket;
|
import java.net.ServerSocket;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
@@ -155,7 +157,7 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
|||||||
* @param dest The destination to connect to
|
* @param dest The destination to connect to
|
||||||
* @return a new I2PSocket
|
* @return a new I2PSocket
|
||||||
*/
|
*/
|
||||||
public I2PSocket createI2PSocket(Destination dest) throws I2PException {
|
public I2PSocket createI2PSocket(Destination dest) throws I2PException, ConnectException, NoRouteToHostException, InterruptedException {
|
||||||
return createI2PSocket(dest, getDefaultOptions());
|
return createI2PSocket(dest, getDefaultOptions());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,8 +169,13 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
|||||||
* @param dest The destination to connect to
|
* @param dest The destination to connect to
|
||||||
* @param opt Option to be used to open when opening the socket
|
* @param opt Option to be used to open when opening the socket
|
||||||
* @return a new I2PSocket
|
* @return a new I2PSocket
|
||||||
|
*
|
||||||
|
* @throws ConnectException if the peer refuses the connection
|
||||||
|
* @throws NoRouteToHostException if the peer is not found or not reachable
|
||||||
|
* @throws InterruptedException if the connection timeouts
|
||||||
|
* @throws I2PException if there is some other I2P-related problem
|
||||||
*/
|
*/
|
||||||
public I2PSocket createI2PSocket(Destination dest, I2PSocketOptions opt) throws I2PException {
|
public I2PSocket createI2PSocket(Destination dest, I2PSocketOptions opt) throws I2PException, ConnectException, NoRouteToHostException, InterruptedException {
|
||||||
I2PSocket i2ps;
|
I2PSocket i2ps;
|
||||||
|
|
||||||
synchronized (sockLock) {
|
synchronized (sockLock) {
|
||||||
@@ -283,4 +290,4 @@ public abstract class I2PTunnelClientBase extends I2PTunnelTask implements Runna
|
|||||||
* you do not override manageConnection()
|
* you do not override manageConnection()
|
||||||
*/
|
*/
|
||||||
protected abstract void clientConnectionRun(Socket s);
|
protected abstract void clientConnectionRun(Socket s);
|
||||||
}
|
}
|
||||||
|
@@ -8,6 +8,7 @@ import java.io.IOException;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import java.net.SocketException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import net.i2p.I2PException;
|
import net.i2p.I2PException;
|
||||||
@@ -188,15 +189,28 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
|||||||
I2PTunnelRunner runner = new I2PTunnelRunner(s, i2ps, sockLock, data);
|
I2PTunnelRunner runner = new I2PTunnelRunner(s, i2ps, sockLock, data);
|
||||||
timeoutThread = new InactivityTimeoutThread(runner, out, targetRequest, usingWWWProxy, s);
|
timeoutThread = new InactivityTimeoutThread(runner, out, targetRequest, usingWWWProxy, s);
|
||||||
timeoutThread.start();
|
timeoutThread.start();
|
||||||
|
} catch (SocketException ex) {
|
||||||
|
if (timeoutThread != null) timeoutThread.disable();
|
||||||
|
_log.info("Error trying to connect", ex);
|
||||||
|
l.log(ex.getMessage());
|
||||||
|
handleHTTPClientException(ex, out, targetRequest, usingWWWProxy, wwwProxy);
|
||||||
|
closeSocket(s);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
if (timeoutThread != null) timeoutThread.disable();
|
if (timeoutThread != null) timeoutThread.disable();
|
||||||
_log.error("Error sending syn", ex);
|
_log.info("Error trying to connect", ex);
|
||||||
|
l.log(ex.getMessage());
|
||||||
|
handleHTTPClientException(ex, out, targetRequest, usingWWWProxy, wwwProxy);
|
||||||
|
closeSocket(s);
|
||||||
|
} catch (InterruptedException ex) {
|
||||||
|
if (timeoutThread != null) timeoutThread.disable();
|
||||||
|
_log.info("Error trying to connect", ex);
|
||||||
|
l.log(ex.getMessage());
|
||||||
handleHTTPClientException(ex, out, targetRequest, usingWWWProxy, wwwProxy);
|
handleHTTPClientException(ex, out, targetRequest, usingWWWProxy, wwwProxy);
|
||||||
closeSocket(s);
|
closeSocket(s);
|
||||||
} catch (I2PException ex) {
|
} catch (I2PException ex) {
|
||||||
if (timeoutThread != null) timeoutThread.disable();
|
if (timeoutThread != null) timeoutThread.disable();
|
||||||
_log.info("Error sending syn", ex);
|
_log.info("Error trying to connect", ex);
|
||||||
l.log("Unable to reach peer");
|
l.log(ex.getMessage());
|
||||||
handleHTTPClientException(ex, out, targetRequest, usingWWWProxy, wwwProxy);
|
handleHTTPClientException(ex, out, targetRequest, usingWWWProxy, wwwProxy);
|
||||||
closeSocket(s);
|
closeSocket(s);
|
||||||
}
|
}
|
||||||
@@ -342,4 +356,4 @@ public class I2PTunnelHTTPClient extends I2PTunnelClientBase implements Runnable
|
|||||||
|
|
||||||
return protocol.equalsIgnoreCase("http://");
|
return protocol.equalsIgnoreCase("http://");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,9 @@
|
|||||||
*/
|
*/
|
||||||
package net.i2p.i2ptunnel.socks;
|
package net.i2p.i2ptunnel.socks;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import java.net.SocketException;
|
||||||
|
|
||||||
import net.i2p.I2PException;
|
import net.i2p.I2PException;
|
||||||
import net.i2p.client.streaming.I2PSocket;
|
import net.i2p.client.streaming.I2PSocket;
|
||||||
@@ -88,10 +90,20 @@ public abstract class SOCKSServer {
|
|||||||
}
|
}
|
||||||
} catch (DataFormatException e) {
|
} catch (DataFormatException e) {
|
||||||
throw new SOCKSException("Error in destination format");
|
throw new SOCKSException("Error in destination format");
|
||||||
|
} catch (SocketException e) {
|
||||||
|
throw new SOCKSException("Error connecting ("
|
||||||
|
+ e.getMessage() + ")");
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new SOCKSException("Error connecting ("
|
||||||
|
+ e.getMessage() + ")");
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new SOCKSException("Error connecting ("
|
||||||
|
+ e.getMessage() + ")");
|
||||||
} catch (I2PException e) {
|
} catch (I2PException e) {
|
||||||
throw new SOCKSException("I2P error (" + e.getMessage() + ")");
|
throw new SOCKSException("Error connecting ("
|
||||||
|
+ e.getMessage() + ")");
|
||||||
}
|
}
|
||||||
|
|
||||||
return destSock;
|
return destSock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user