Skip to content

Commit

Permalink
nx: Implement logout
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Gnau <rondom@rondom.de>
  • Loading branch information
Rondom committed May 24, 2020
1 parent 17ca697 commit 6b2e8bb
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions nx.c
Expand Up @@ -390,6 +390,32 @@ int nx_connect(struct openconnect_info *vpninfo)

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;
}

0 comments on commit 6b2e8bb

Please sign in to comment.