This is needed for the Android GUI to detect the idle/keepalive interval in a cross-protocol way.
if (!strcmp(buf + 7, "Keepalive")) {
vpninfo->ssl_times.keepalive = atol(colon);
+ } else if (!strcmp(buf + 7, "Idle-Timeout")) {
+ vpninfo->idle_timeout = atol(colon);
} else if (!strcmp(buf + 7, "DPD")) {
int j = atol(colon);
if (j && (!vpninfo->ssl_times.dpd || j < vpninfo->ssl_times.dpd))
else if (!xmlnode_get_text(xml_node, "mtu", &s)) {
vpninfo->ip_info.mtu = atoi(s);
free(s);
+ } else if (!xmlnode_get_text(xml_node, "disconnect-on-idle", &s)) {
+ int sec = atoi(s);
+ vpn_progress(vpninfo, PRG_INFO, _("Idle timeout is %d minutes.\n"), sec/60);
+ vpninfo->idle_timeout = sec;
+ free(s);
} else if (!xmlnode_get_text(xml_node, "ssl-tunnel-url", &s)) {
free(vpninfo->urlpath);
vpninfo->urlpath = s;
if (lib.makeCSTPConnection() != 0)
die("Error establishing VPN link");
+ int idleTimeout = lib.getIdleTimeout();
+ System.out.println("Idle Timeout: " + idleTimeout + " seconds");
printIPInfo(lib.getIPInfo());
if (lib.setupDTLS(60) != 0)
public synchronized native String getCSTPCompression();
public synchronized native String getDTLSCompression();
public synchronized native String getProtocol();
+ public synchronized native int getIdleTimeout();
/* certificate info */
public String proxyPac;
public String gatewayAddr;
public int MTU;
+ public int idleTimeoutSec;
public ArrayList<String> splitDNS = new ArrayList<String>();
public ArrayList<String> splitIncludes = new ArrayList<String>();
openconnect_set_xmlpost(ctx->vpninfo, arg);
}
+JNIEXPORT jint JNICALL Java_org_infradead_libopenconnect_LibOpenConnect_getIdleTimeout(
+ JNIEnv *jenv, jobject jobj)
+{
+ struct libctx *ctx = getctx(jenv, jobj);
+
+ if (!ctx)
+ return -EINVAL;
+ return openconnect_get_idle_timeout(ctx->vpninfo);
+}
+
/* simple cases: return a const string (no need to free it) */
#define RETURN_STRING_START \
OPENCONNECT_5_5 {
global:
+ openconnect_get_idle_timeout;
openconnect_get_protocol;
openconnect_get_supported_protocols;
openconnect_free_supported_protocols;
vpninfo->dtls_times.dpd = vpninfo->ssl_times.dpd = 2;
}
+int openconnect_get_idle_timeout(struct openconnect_info *vpninfo)
+{
+ return vpninfo->idle_timeout;
+}
+
int openconnect_get_ip_info(struct openconnect_info *vpninfo,
const struct oc_ip_info **info,
const struct oc_vpn_option **cstp_options,
struct oc_ip_info ip_info;
int cstp_basemtu; /* Returned by server */
+ int idle_timeout; /* Returned by server */
#ifdef _WIN32
long dtls_monitored, ssl_monitored, cmd_monitored, tun_monitored;
* - Add openconnect_get_supported_protocols()
* - Add openconnect_free_supported_protocols()
* - Add openconnect_get_protocol()
+ * - Add openconnect_get_idle_timeout()
*
* API version 5.4 (v7.08; 2016-12-13):
* - Add openconnect_set_pass_tos()
const char *openconnect_get_ifname(struct openconnect_info *);
void openconnect_set_reqmtu(struct openconnect_info *, int reqmtu);
void openconnect_set_dpd(struct openconnect_info *, int min_seconds);
+int openconnect_get_idle_timeout(struct openconnect_info *);
/* The returned structures are owned by the library and may be freed/replaced
due to rekey or reconnect. Assume that once the mainloop starts, the