Added thread names for easier debug
This commit is contained in:
parent
b52c80b600
commit
ee8d1ba609
35
pom.xml
35
pom.xml
|
|
@ -1,17 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.sonatype.oss</groupId>
|
<groupId>org.sonatype.oss</groupId>
|
||||||
<artifactId>oss-parent</artifactId>
|
<artifactId>oss-parent</artifactId>
|
||||||
<version>9</version>
|
<version>9</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>me.legrange</groupId>
|
<groupId>me.legrange</groupId>
|
||||||
<artifactId>mikrotik</artifactId>
|
<artifactId>mikrotik</artifactId>
|
||||||
<version>3.0.3</version>
|
<version>3.0.3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Mikrotik API Java Client Library</name>
|
<name>Mikrotik API Java Client Library</name>
|
||||||
<url>https://github.com/GideonLeGrange/mikrotik-java</url>
|
<url>https://github.com/GideonLeGrange/mikrotik-java</url>
|
||||||
<licenses>
|
<licenses>
|
||||||
|
|
@ -38,7 +37,6 @@
|
||||||
<target>1.7</target>
|
<target>1.7</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-jar-plugin</artifactId>
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
|
@ -88,7 +86,27 @@
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<version>1.0.4</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>process-sources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>test-compile</id>
|
||||||
|
<phase>process-test-sources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test-compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<profiles>
|
<profiles>
|
||||||
|
|
@ -160,7 +178,6 @@
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
|
@ -168,6 +185,10 @@
|
||||||
<version>3.8.1</version>
|
<version>3.8.1</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-stdlib</artifactId>
|
||||||
|
<version>1.0.4</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ package examples;
|
||||||
*/
|
*/
|
||||||
public class Config {
|
public class Config {
|
||||||
|
|
||||||
public static final String HOST = "192.168.1.34";
|
public static final String HOST = "wifimanager.adept.za.net";
|
||||||
public static final String USERNAME = "admin";
|
public static final String USERNAME = "adept";
|
||||||
public static final String PASSWORD = "";
|
public static final String PASSWORD = "tzrx21j";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
package examples;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.legrange.mikrotik.MikrotikApiException;
|
||||||
|
import me.legrange.mikrotik.ResultListener;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Example to show that different character sets may work some times.
|
||||||
|
*
|
||||||
|
* @author gideon
|
||||||
|
*/
|
||||||
|
public class Issue27 extends Example {
|
||||||
|
|
||||||
|
public static void main(String... args) throws Exception {
|
||||||
|
Issue27 ex = new Issue27();
|
||||||
|
ex.connect();
|
||||||
|
ex.con.setTimeout(2000);
|
||||||
|
ex.test2();
|
||||||
|
ex.test1();
|
||||||
|
Thread.sleep(60000);
|
||||||
|
for (String tag : ex.tags) {
|
||||||
|
ex.con.cancel(tag);
|
||||||
|
}
|
||||||
|
ex.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void test1() throws MikrotikApiException {
|
||||||
|
String tag = con.execute("/interface/pppoe-server/server/listen return .id,.dead,disabled,service-name,interface,max-mtu,max-mru,mrru,default-profile,authentication", new ResultListener() {
|
||||||
|
@Override
|
||||||
|
public void receive(Map<String, String> result) {
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(MikrotikApiException ex) {
|
||||||
|
System.out.println(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void completed() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tags.add(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void test2() throws MikrotikApiException {
|
||||||
|
String tag = con.execute("/interface/listen where type=l2tp-in or type=l2tp-out or type=ovpn-in or type=ovpn-out or type=ppp-in or type=ppp-out or type=pppoe-in or type=pppoe-out or type=pptp-in or type=pptp-out or type=sstp-in or type=sstp-out return .id,.dead,.nextid,disabled,dynamic,running,slave,name,type,comment", new ResultListener() {
|
||||||
|
@Override
|
||||||
|
public void receive(Map<String, String> result) {
|
||||||
|
System.out.println(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void error(MikrotikApiException ex) {
|
||||||
|
System.out.println(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void completed() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tags.add(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> tags = new ArrayList<>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -33,7 +33,6 @@ public final class ApiConnectionImpl extends ApiConnection {
|
||||||
*
|
*
|
||||||
* @param host The host to which to connect.
|
* @param host The host to which to connect.
|
||||||
* @param port The TCP port to use.
|
* @param port The TCP port to use.
|
||||||
* @param secure Is TLS required
|
|
||||||
* @param timeOut The connection timeout
|
* @param timeOut The connection timeout
|
||||||
* @return The ApiConnection
|
* @return The ApiConnection
|
||||||
* @throws me.legrange.mikrotik.ApiConnectionException Thrown if there is a
|
* @throws me.legrange.mikrotik.ApiConnectionException Thrown if there is a
|
||||||
|
|
@ -174,6 +173,10 @@ public final class ApiConnectionImpl extends ApiConnection {
|
||||||
*/
|
*/
|
||||||
private class Reader extends Thread {
|
private class Reader extends Thread {
|
||||||
|
|
||||||
|
private Reader() {
|
||||||
|
super("Mikrotik API Reader");
|
||||||
|
}
|
||||||
|
|
||||||
private String take() throws ApiConnectionException, ApiDataException {
|
private String take() throws ApiConnectionException, ApiDataException {
|
||||||
Object val = null;
|
Object val = null;
|
||||||
try {
|
try {
|
||||||
|
|
@ -226,6 +229,10 @@ public final class ApiConnectionImpl extends ApiConnection {
|
||||||
*/
|
*/
|
||||||
private class Processor extends Thread {
|
private class Processor extends Thread {
|
||||||
|
|
||||||
|
private Processor() {
|
||||||
|
super("Mikrotik API Result Processor");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
while (connected) {
|
while (connected) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue