]> www.infradead.org Git - users/dwmw2/openconnect.git/commitdiff
nx: Implement logout f5
authorAndreas Gnau <rondom@rondom.de>
Sat, 23 May 2020 20:54:43 +0000 (22:54 +0200)
committerAndreas Gnau <rondom@rondom.de>
Sun, 24 May 2020 21:50:42 +0000 (23:50 +0200)
Signed-off-by: Andreas Gnau <rondom@rondom.de>
nx.c

diff --git a/nx.c b/nx.c
index acc68c49277be5c799e15c72b77e081bf6ad12f3..b637a3ba54f2f2c76931d1dd1d985dd7893c2c1d 100644 (file)
--- a/nx.c
+++ b/nx.c
@@ -390,6 +390,32 @@ out:
 
 int nx_bye(struct openconnect_info *vpninfo, const char *reason)
 {
-       // TODO: implement
-       return -EINVAL;
+       int ret = 0;
+       char *resp_buf = NULL;
+       struct oc_text_buf *request_body = NULL;
+       /* close tunnel */
+       openconnect_close_https(vpninfo, 0);
+
+       request_body = buf_alloc();
+       if (!request_body) {
+               ret = buf_error(request_body);
+               goto out;
+       }
+       append_opt(request_body, "userLogout", "1");
+       vpninfo->urlpath = strdup("cgi-bin/userLogout");
+       ret = do_https_request(vpninfo, "POST", "application/x-www-form-urlencoded", request_body, &resp_buf, 0);
+       free(vpninfo->urlpath);
+       vpninfo->urlpath = NULL;
+       printf("ret=%d\n", ret);
+       if (ret < 0)
+               vpn_progress(vpninfo, PRG_ERR, _("Logout failed.\n"));
+       else {
+               ret = 0;
+               vpn_progress(vpninfo, PRG_INFO, _("Logout successful.\n"));
+       }
+
+out:
+       free(resp_buf);
+       free(request_body);
+       return ret;
 }