Added additional handlers for requested files.

This commit is contained in:
Nikos Mavrogiannopoulos
2013-07-08 00:07:42 +02:00
parent 190e1d7994
commit be84ddc6b8
3 changed files with 68 additions and 6 deletions

View File

@@ -98,6 +98,9 @@ struct stat st;
return 0;
}
#define VPN_VERSION "0,0,0000\n"
#define XML_START "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vpn rev=\"1.0\">\n</vpn>\n"
int get_string_handler(worker_st *ws, unsigned http_ver)
{
int ret;
@@ -105,11 +108,13 @@ const char *data;
int len;
oclog(ws, LOG_DEBUG, "requested fixed string: %s", ws->req.url);
if (!strcmp(ws->req.url, "/2/binaries/update.txt"))
data = "0,0,0000\n";
else
data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<vpn rev=\"1.0\">\n</vpn>\n";
len = strlen(data);
if (!strcmp(ws->req.url, "/2/binaries/update.txt")) {
data = VPN_VERSION;
len = sizeof(VPN_VERSION)-1;
} else {
data = XML_START;
len = sizeof(XML_START)-1;
}
tls_cork(ws->session);
ret = tls_printf(ws->session, "HTTP/1.%u 200 OK\r\n", http_ver);
@@ -143,6 +148,52 @@ int len;
return 0;
}
#define SH_SCRIPT "#!/bin/sh\n\n" \
"exit 0"
int get_dl_handler(worker_st *ws, unsigned http_ver)
{
int ret;
const char *data;
int len;
oclog(ws, LOG_DEBUG, "requested downloader: %s", ws->req.url);
data = SH_SCRIPT;
len = sizeof(SH_SCRIPT)-1;
tls_cork(ws->session);
ret = tls_printf(ws->session, "HTTP/1.%u 200 OK\r\n", http_ver);
if (ret < 0)
return -1;
ret = tls_puts(ws->session, "Connection: Keep-Alive\r\n");
if (ret < 0)
return -1;
ret = tls_puts(ws->session, "Content-Type: application/x-shellscript\r\n");
if (ret < 0)
return -1;
ret = tls_puts(ws->session, "X-Transcend-Version: 1\r\n");
if (ret < 0)
return -1;
ret = tls_printf(ws->session, "Content-Length: %d\r\n\r\n", len);
if (ret < 0)
return -1;
ret = tls_send(ws->session, data, len);
if (ret < 0)
return -1;
ret = tls_uncork(ws->session);
if (ret < 0)
return -1;
return 0;
}
int get_empty_handler(worker_st *ws, unsigned http_ver)
{
int ret;

View File

@@ -97,11 +97,21 @@ const static struct known_urls_st known_urls[] = {
LL("/", get_auth_handler, post_auth_handler),
LL("/auth", get_auth_handler, post_auth_handler),
#ifdef ANYCONNECT_CLIENT_COMPAT
LL("/1/index.html", get_empty_handler, NULL),
LL("/2/index.html", get_empty_handler, NULL),
LL("/2/Linux", get_empty_handler, NULL),
LL("/2/Linux_64", get_empty_handler, NULL),
LL("/2/Windows", get_empty_handler, NULL),
LL("/2/binaries/vpndownloader.sh", get_dl_handler, NULL),
LL("/2/VPNManifest.xml", get_string_handler, NULL),
LL("/2/binaries/update.txt", get_string_handler, NULL),
LL("/1/index.html", get_empty_handler, NULL),
LL("/1/Linux", get_empty_handler, NULL),
LL("/1/Linux_64", get_empty_handler, NULL),
LL("/1/Windows", get_empty_handler, NULL),
LL("/1/binaries/vpndownloader.sh", get_dl_handler, NULL),
LL("/1/VPNManifest.xml", get_string_handler, NULL),
LL("/1/binaries/update.txt", get_string_handler, NULL),
LL("/profiles", get_config_handler, NULL),
LL("/+CSCOT+/translation-table", get_string_handler, NULL),
#endif

View File

@@ -132,6 +132,7 @@ int post_auth_handler(worker_st *server, unsigned http_ver);
int get_empty_handler(worker_st *server, unsigned http_ver);
int get_config_handler(worker_st *ws, unsigned http_ver);
int get_string_handler(worker_st *ws, unsigned http_ver);
int get_dl_handler(worker_st *ws, unsigned http_ver);
void set_resume_db_funcs(gnutls_session_t);