Added thread names for easier debug
This commit is contained in:
parent
b52c80b600
commit
ee8d1ba609
363
pom.xml
363
pom.xml
|
|
@ -1,173 +1,194 @@
|
|||
<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>
|
||||
<groupId>org.sonatype.oss</groupId>
|
||||
<artifactId>oss-parent</artifactId>
|
||||
<version>9</version>
|
||||
</parent>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>me.legrange</groupId>
|
||||
<artifactId>mikrotik</artifactId>
|
||||
<version>3.0.3</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Mikrotik API Java Client Library</name>
|
||||
<url>https://github.com/GideonLeGrange/mikrotik-java</url>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache Software License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<scm>
|
||||
<url>git@github.com:GideonLeGrange/mikrotik-java.git</url>
|
||||
<connection>scm:git:git@github.com:GideonLeGrange/mikrotik-java.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:GideonLeGrange/mikrotik-java.git</developerConnection>
|
||||
</scm>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-jar</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/examples</exclude>
|
||||
<exclude>**/examples/*</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<configuration>
|
||||
<excludePackageNames>example;*.impl</excludePackageNames>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>ossrh</serverId>
|
||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
</profile>
|
||||
</profiles>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<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>
|
||||
<groupId>org.sonatype.oss</groupId>
|
||||
<artifactId>oss-parent</artifactId>
|
||||
<version>9</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>me.legrange</groupId>
|
||||
<artifactId>mikrotik</artifactId>
|
||||
<version>3.0.3</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>Mikrotik API Java Client Library</name>
|
||||
<url>https://github.com/GideonLeGrange/mikrotik-java</url>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>The Apache Software License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<scm>
|
||||
<url>git@github.com:GideonLeGrange/mikrotik-java.git</url>
|
||||
<connection>scm:git:git@github.com:GideonLeGrange/mikrotik-java.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:GideonLeGrange/mikrotik-java.git</developerConnection>
|
||||
</scm>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<showDeprecation>true</showDeprecation>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-jar</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/examples</exclude>
|
||||
<exclude>**/examples/*</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<configuration>
|
||||
<excludePackageNames>example;*.impl</excludePackageNames>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</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>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>release</id>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-sources</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>2.10.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>sign-artifacts</id>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>sign</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>nexus-staging-maven-plugin</artifactId>
|
||||
<version>1.6.5</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<serverId>ossrh</serverId>
|
||||
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
|
||||
<autoReleaseAfterClose>true</autoReleaseAfterClose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<distributionManagement>
|
||||
<snapshotRepository>
|
||||
<id>ossrh</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
</profile>
|
||||
</profiles>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib</artifactId>
|
||||
<version>1.0.4</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ package examples;
|
|||
*/
|
||||
public class Config {
|
||||
|
||||
public static final String HOST = "192.168.1.34";
|
||||
public static final String USERNAME = "admin";
|
||||
public static final String PASSWORD = "";
|
||||
public static final String HOST = "wifimanager.adept.za.net";
|
||||
public static final String USERNAME = "adept";
|
||||
public static final String PASSWORD = "tzrx21j";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ public class DownloadConfig extends Example {
|
|||
private void test() throws MikrotikApiException, InterruptedException {
|
||||
con.execute("/export file=conf");
|
||||
List<Map<String, String>> res = con.execute("/file/print detail where name=conf.rsc");
|
||||
con.execute("/file/remove .id=conf.rsc");
|
||||
con.execute("/file/remove .id=conf.rsc");
|
||||
String text = res.get(0).get("contents");
|
||||
for (String line : text.split("\r")) {
|
||||
for (String line : text.split("\r")) {
|
||||
System.out.println(line);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 port The TCP port to use.
|
||||
* @param secure Is TLS required
|
||||
* @param timeOut The connection timeout
|
||||
* @return The ApiConnection
|
||||
* @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 Reader() {
|
||||
super("Mikrotik API Reader");
|
||||
}
|
||||
|
||||
private String take() throws ApiConnectionException, ApiDataException {
|
||||
Object val = null;
|
||||
try {
|
||||
|
|
@ -192,7 +195,7 @@ public final class ApiConnectionImpl extends ApiConnection {
|
|||
private boolean isEmpty() {
|
||||
return queue.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (connected) {
|
||||
|
|
@ -226,6 +229,10 @@ public final class ApiConnectionImpl extends ApiConnection {
|
|||
*/
|
||||
private class Processor extends Thread {
|
||||
|
||||
private Processor() {
|
||||
super("Mikrotik API Result Processor");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
while (connected) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue