From 047cd4246be74e91c3f0b3590cc1878e5374386b Mon Sep 17 00:00:00 2001 From: GideonLeGrange Date: Mon, 22 Dec 2014 12:55:59 +0200 Subject: [PATCH] Added trim() to cope with spaces around host nameS --- src/main/java/examples/Example9.java | 28 +++++++++++++++++++ .../mikrotik/impl/ApiConnectionImpl.java | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/main/java/examples/Example9.java diff --git a/src/main/java/examples/Example9.java b/src/main/java/examples/Example9.java new file mode 100644 index 0000000..37ef4eb --- /dev/null +++ b/src/main/java/examples/Example9.java @@ -0,0 +1,28 @@ +package examples; + +import java.util.List; +import java.util.Map; +import me.legrange.mikrotik.MikrotikApiException; + +/** + * Example 7: Dump your complete config + * + * @author gideon + */ +public class Example8 extends Example { + + public static void main(String... args) throws Exception { + Example8 ex = new Example8(); + ex.connect(); + ex.test(); + ex.disconnect(); + } + + private void test() throws MikrotikApiException, InterruptedException { + List> res = con.execute("/ip/hotspot/user/print where uptime!=1"); + for (Map r : res) { + System.out.println(r); + } +// con.execute("/ip/firewall/filter/add chain=forward hotspot=!auth protocol=tcp src-port=8000-8084"); + } +} diff --git a/src/main/java/me/legrange/mikrotik/impl/ApiConnectionImpl.java b/src/main/java/me/legrange/mikrotik/impl/ApiConnectionImpl.java index 072473e..00767fd 100644 --- a/src/main/java/me/legrange/mikrotik/impl/ApiConnectionImpl.java +++ b/src/main/java/me/legrange/mikrotik/impl/ApiConnectionImpl.java @@ -164,7 +164,7 @@ public final class ApiConnectionImpl extends ApiConnection { */ private void open(String host, int port, boolean secure) throws ApiConnectionException { try { - InetAddress ia = InetAddress.getByName(host); + InetAddress ia = InetAddress.getByName(host.trim()); if (secure) { sock = openSSLSocket(ia, port); } else {