Working on fix for issue #16

This commit is contained in:
Gideon le Grange 2015-03-29 13:05:50 +02:00
parent 60b1bd16f2
commit 5d05b76fe8
1 changed files with 31 additions and 0 deletions

View File

@ -11,6 +11,26 @@ import me.legrange.mikrotik.impl.ApiConnectionImpl;
* @author GideonLeGrange * @author GideonLeGrange
*/ */
public abstract class ApiConnection { public abstract class ApiConnection {
/** default TCP port used by Mikrotik API */
public static final int DEFAULT_PORT = 8728;
/** default TCP TLS port used by Mikrotik API */
public static final int DEFAULT_TLS_PORT = 8729;
/** default connection timeout to use when opening the connection */
public static final int DEFAULT_CONNECTION_TIMEOUT = 60000;
/**
* Create a new API connection to the give device on the supplied port, using anonymous TLS for encryption.
* @param host The host to which to connect.
* @param port The TCP port to use.
* @param timeOut The connection timeout to use when opening the connection.
* @return The ApiConnection
* @throws me.legrange.mikrotik.MikrotikApiException Thrown if there is a problem connecting
*/
public static ApiConnection connectTLS(String host, int port, int timeOut) throws MikrotikApiException {
return ApiConnectionImpl.connect(host, port, true, timeOut);
}
/** /**
* Create a new API connection to the give device on the supplied port, using anonymous TLS for encryption. * Create a new API connection to the give device on the supplied port, using anonymous TLS for encryption.
@ -34,6 +54,17 @@ public abstract class ApiConnection {
return ApiConnectionImpl.connect(host, DEFAULT_TLS_PORT, true, DEFAULT_CONNECTION_TIMEOUT); return ApiConnectionImpl.connect(host, DEFAULT_TLS_PORT, true, DEFAULT_CONNECTION_TIMEOUT);
} }
/**
* Create a new API connection to the give device on the supplied port
* @param host The host to which to connect.
* @param port The TCP port to use.
* @param timeOut The connection timeout to use when opening the connection.
* @return The ApiConnection
* @throws me.legrange.mikrotik.MikrotikApiException Thrown if there is a problem connecting
*/
public static ApiConnection connect(String host, int port, int timeOut) throws MikrotikApiException {
return ApiConnectionImpl.connect(host, port, false, timeOut);
}
/** /**
* Create a new API connection to the give device on the supplied port * Create a new API connection to the give device on the supplied port