diff --git a/README.md b/README.md
index 1027933..f439385 100644
--- a/README.md
+++ b/README.md
@@ -130,3 +130,4 @@ Licence
=======
This library is released under the Apache 2.0 licence. See the Licence.md file
+
diff --git a/pom.xml b/pom.xml
index 9965a92..ef1a771 100644
--- a/pom.xml
+++ b/pom.xml
@@ -34,8 +34,8 @@
2.3.2
true
- 1.5
- 1.5
+ 1.7
+ 1.7
diff --git a/src/main/java/examples/Example.java b/src/main/java/examples/Example.java
index 33dea60..7c55df4 100644
--- a/src/main/java/examples/Example.java
+++ b/src/main/java/examples/Example.java
@@ -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);
}
diff --git a/src/main/java/me/legrange/mikrotik/impl/ApiConnectionImpl.java b/src/main/java/me/legrange/mikrotik/impl/ApiConnectionImpl.java
index 320517a..0b7013a 100644
--- a/src/main/java/me/legrange/mikrotik/impl/ApiConnectionImpl.java
+++ b/src/main/java/me/legrange/mikrotik/impl/ApiConnectionImpl.java
@@ -146,24 +146,20 @@ 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 {
- sock = new Socket(ia, port);
- }
- in = new DataInputStream(sock.getInputStream());
- out = new DataOutputStream(sock.getOutputStream());
- connected = true;
- reader = new Reader();
- reader.setDaemon(true);
- reader.start();
- processor = new Processor();
- processor.setDaemon(true);
- processor.start();
+ if (secure) {
+ sock = openSSLSocket(ia, port);
} else {
- throw new ApiConnectionException(String.format("Host '%s' port %d is uncreachable", host, port));
+ sock = new Socket(ia, port);
}
+ in = new DataInputStream(sock.getInputStream());
+ out = new DataOutputStream(sock.getOutputStream());
+ connected = true;
+ reader = new Reader();
+ reader.setDaemon(true);
+ reader.start();
+ processor = new Processor();
+ processor.setDaemon(true);
+ processor.start();
} catch (UnknownHostException ex) {
connected = false;
throw new ApiConnectionException(String.format("Unknown host '%s'", host), ex);
@@ -182,9 +178,11 @@ 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[]{}));
+ ssl.setEnabledCipherSuites(cs.toArray(new String[]{}));
return ssl;
}
@@ -478,4 +476,4 @@ public final class ApiConnectionImpl extends ApiConnection {
private List