Fixed to not check for router reachability before connecting
This commit is contained in:
parent
fb0c084f99
commit
044e4e76a0
|
|
@ -130,3 +130,4 @@ Licence
|
|||
=======
|
||||
|
||||
This library is released under the Apache 2.0 licence. See the Licence.md file
|
||||
|
||||
|
|
|
|||
4
pom.xml
4
pom.xml
|
|
@ -34,8 +34,8 @@
|
|||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import me.legrange.mikrotik.ApiConnection;
|
|||
abstract class Example {
|
||||
|
||||
protected void connect() throws Exception {
|
||||
con = ApiConnection.connect(Config.HOST);
|
||||
con = ApiConnection.connectTLS(Config.HOST);
|
||||
con.login(Config.USERNAME, Config.PASSWORD);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,6 @@ public final class ApiConnectionImpl extends ApiConnection {
|
|||
private void open(String host, int port, boolean secure) throws ApiConnectionException {
|
||||
try {
|
||||
InetAddress ia = InetAddress.getByName(host);
|
||||
if (ia.isReachable(1000)) {
|
||||
if (secure) {
|
||||
sock = openSSLSocket(ia, port);
|
||||
} else {
|
||||
|
|
@ -161,9 +160,6 @@ public final class ApiConnectionImpl extends ApiConnection {
|
|||
processor = new Processor();
|
||||
processor.setDaemon(true);
|
||||
processor.start();
|
||||
} else {
|
||||
throw new ApiConnectionException(String.format("Host '%s' port %d is uncreachable", host, port));
|
||||
}
|
||||
} catch (UnknownHostException ex) {
|
||||
connected = false;
|
||||
throw new ApiConnectionException(String.format("Unknown host '%s'", host), ex);
|
||||
|
|
@ -182,7 +178,9 @@ public final class ApiConnectionImpl extends ApiConnection {
|
|||
// not happy with this code. Without it, SSL throws a "Remote host closed connection during handshake" error
|
||||
// caused by a "SSL peer shut down incorrectly" error
|
||||
for (String s : ssl.getSupportedCipherSuites()) {
|
||||
if (s.startsWith("TLS_DH_anon")) cs.add(s);
|
||||
if (s.startsWith("TLS_DH_anon")) {
|
||||
cs.add(s);
|
||||
}
|
||||
}
|
||||
ssl.setEnabledCipherSuites(cs.toArray(new String[]{}));
|
||||
return ssl;
|
||||
|
|
|
|||
Loading…
Reference in New Issue