Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
-
#include "platform.h"
-#include <gnunet_util_lib.h>
-#include <gnunet_gns_service.h>
#include <microhttpd.h>
#include <curl/curl.h>
-#include <regex.h>
-#include "gns_proxy_proto.h"
-#include "gns.h"
-
-/** SSL **/
#include <gnutls/gnutls.h>
#include <gnutls/x509.h>
#include <gnutls/abstract.h>
#include <gnutls/crypto.h>
-#include <time.h>
+#include <regex.h>
+#include "gnunet_util_lib.h"
+#include "gnunet_gns_service.h"
+#include "gns_proxy_proto.h"
+#include "gns.h"
#define HAVE_MHD_NO_LISTEN_SOCKET MHD_VERSION >= 0x00091401
#define POSTBUFFERSIZE 4096
/* MHD/cURL defines */
-#define BUF_WAIT_FOR_CURL 0
-#define BUF_WAIT_FOR_MHD 1
-#define BUF_WAIT_FOR_PP 2
+enum BufferStatus
+ {
+ BUF_WAIT_FOR_CURL,
+ BUF_WAIT_FOR_MHD,
+ BUF_WAIT_FOR_PP
+ };
+
#define HTML_HDR_CONTENT "Content-Type: text/html"
/* buffer padding for proper RE matching */
/* DLL for tasks */
struct ProxyCurlTask *next;
- /* Already accepted */
- int accepted;
-
/* Handle to cURL */
CURL *curl;
- /* is curl running? */
- int curl_running;
-
/* Optional header replacements for curl (LEHO) */
struct curl_slist *headers;
/* Write pos in the buffer */
char *buffer_write_ptr;
- /* The buffer status (BUF_WAIT_FOR_CURL or BUF_WAIT_FOR_MHD) */
- int buf_status;
+ /* connection */
+ struct MHD_Connection *connection;
- /* Number of bytes in buffer */
- unsigned int bytes_in_buffer;
+ /*put*/
+ size_t put_read_offset;
+ size_t put_read_size;
- /* Indicates wheather the download is in progress */
- int download_in_progress;
+ /*post*/
+ struct MHD_PostProcessor *post_handler;
- /* Indicates wheather the download was successful */
- int download_is_finished;
+ /* post data */
+ struct ProxyUploadData *upload_data_head;
+ struct ProxyUploadData *upload_data_tail;
- /* Indicates wheather the download failed */
- int download_error;
+ /* the type of POST encoding */
+ char* post_type;
- /* Indicates wheather we need to parse HTML */
- int parse_content;
+ struct curl_httppost *httppost;
- /* Indicates wheather we are postprocessing the HTML right now */
- int is_postprocessing;
+ struct curl_httppost *httppost_last;
- /* Indicates wheather postprocessing has finished */
- int pp_finished;
+ /* Number of bytes in buffer */
+ unsigned int bytes_in_buffer;
/* PP task */
GNUNET_SCHEDULER_TaskIdentifier pp_task;
/* PP match list */
struct ProxyREMatch *pp_match_tail;
- /* The authority of the corresponding host (site of origin) */
- char authority[256];
-
- /* The hostname (Host header field) */
- char host[256];
-
- /* The port */
- uint16_t port;
-
- /* The LEgacy HOstname (can be empty) */
- char leho[256];
-
/* The associated daemon list entry */
struct MhdHttpList *mhd;
/* Cookies to set */
struct ProxySetCookieHeader *set_cookies_tail;
+ /* The authority of the corresponding host (site of origin) */
+ char authority[256];
+
+ /* The hostname (Host header field) */
+ char host[256];
+
+ /* The LEgacy HOstname (can be empty) */
+ char leho[256];
+
+ /* The port */
+ uint16_t port;
+
+ /* The buffer status (BUF_WAIT_FOR_CURL or BUF_WAIT_FOR_MHD) */
+ enum BufferStatus buf_status;
+
/* connection status */
int ready_to_queue;
+
+ /* is curl running? */
+ int curl_running;
/* are we done */
int fin;
- /* connection */
- struct MHD_Connection *connection;
+ /* Already accepted */
+ int accepted;
- /*put*/
- size_t put_read_offset;
- size_t put_read_size;
+ /* Indicates wheather the download is in progress */
+ int download_in_progress;
- /*post*/
- struct MHD_PostProcessor *post_handler;
+ /* Indicates wheather the download was successful */
+ int download_is_finished;
- /* post data */
- struct ProxyUploadData *upload_data_head;
- struct ProxyUploadData *upload_data_tail;
+ /* Indicates wheather the download failed */
+ int download_error;
- int post_done;
+ /* Indicates wheather we need to parse HTML */
+ int parse_content;
- /* the type of POST encoding */
- char* post_type;
+ /* Indicates wheather we are postprocessing the HTML right now */
+ int is_postprocessing;
- struct curl_httppost *httppost;
+ /* Indicates wheather postprocessing has finished */
+ int pp_finished;
- struct curl_httppost *httppost_last;
+ int post_done;
int is_httppost;
/* DLL */
struct ProxyREMatch *prev;
+ /* start of match in buffer */
+ char* start;
+
+ /* end of match in buffer */
+ char* end;
+
+ /* associated proxycurltask */
+ struct ProxyCurlTask *ctask;
+
/* hostname found */
char hostname[255];
/* are we done */
int done;
- /* start of match in buffer */
- char* start;
-
- /* end of match in buffer */
- char* end;
+ /* is SSL */
+ int is_ssl;
- /* associated proxycurltask */
- struct ProxyCurlTask *ctask;
};
/**
static struct GNUNET_NETWORK_Handle *lsock;
/* The listen task ID */
-GNUNET_SCHEDULER_TaskIdentifier ltask;
+static GNUNET_SCHEDULER_TaskIdentifier ltask;
/* The cURL download task */
-GNUNET_SCHEDULER_TaskIdentifier curl_download_task;
+static GNUNET_SCHEDULER_TaskIdentifier curl_download_task;
/* The non SSL httpd daemon handle */
static struct MHD_Daemon *httpd;
static struct ProxyCA proxy_ca;
/* UNIX domain socket for mhd */
-struct GNUNET_NETWORK_Handle *mhd_unix_socket;
+#if !HAVE_MHD_NO_LISTEN_SOCKET
+static struct GNUNET_NETWORK_Handle *mhd_unix_socket;
+#endif
/* Shorten zone private key */
-struct GNUNET_CRYPTO_RsaPrivateKey *shorten_zonekey;
+static struct GNUNET_CRYPTO_RsaPrivateKey *shorten_zonekey;
+
/**
* Checks if name is in tld
*
- * @param name the name to check
- * @param tld the TLD to check for
+ * @param name the name to check
+ * @param tld the TLD to check for (must NOT begin with ".")
* @return GNUNET_YES or GNUNET_NO
*/
-int
-is_tld(const char* name, const char* tld)
+static int
+is_tld (const char* name, const char* tld)
{
- size_t offset;
-
- if (strlen(name) <= strlen(tld))
- return GNUNET_NO;
-
- offset = strlen(name) - strlen(tld);
- if (0 != strcmp (name+offset, tld))
- {
- GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
- "%s is not in .%s TLD\n", name, tld);
- return GNUNET_NO;
- }
-
- return GNUNET_YES;
+ size_t name_len = strlen (name);
+ size_t tld_len = strlen (tld);
+
+ GNUNET_break ('.' != tld[0]);
+ return ( (tld_len < name_len) &&
+ ( ('.' == name[name_len - tld_len - 1]) || (name_len == tld_len) ) &&
+ (0 == memcmp (tld,
+ name + (name_len - tld_len),
+ tld_len)) );
}
+
/**
* convert integer to string representation
*
* @param i integer
* @return the character
*/
-char i_to_hexchar (char i)
+static char
+i_to_hexchar (unsigned char i)
{
static char hexmap[] = "0123456789abcdef";
+
GNUNET_assert (sizeof (hexmap) > (i & 15));
return hexmap[i & 15];
}
+
/**
+// FIXME: use cURL API
* Escape given 0-terminated string
*
* @param to_esc string to escapse
return res;
}
+
static int
con_post_data_iter (void *cls,
enum MHD_ValueKind kind,
char* new_value;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Got POST data: '%s : %s' at offset %llu size %lld\n",
- key, data, off, size);
-
+ "Got POST data (file: %s, content type: %s): '%s=%.*s' at offset %llu size %llu\n",
+ filename, content_type,
+ key, (int) size, data,
+ (unsigned long long) off,
+ (unsigned long long) size);
GNUNET_assert (NULL != ctask->post_type);
if (0 == strcasecmp (MHD_HTTP_POST_ENCODING_MULTIPART_FORMDATA,
if (0 == off)
{
pdata = GNUNET_malloc (sizeof (struct ProxyUploadData));
- pdata->key = strdup (key);
-
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Copied %lld\n");
+ pdata->key = GNUNET_strdup (key);
if (NULL != filename)
- {
- pdata->filename = strdup (filename);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Filename %s\n", filename);
- }
-
+ pdata->filename = GNUNET_strdup (filename);
if (NULL != content_type)
- {
- pdata->content_type = strdup (content_type);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Content-Type %s\n", content_type);
- }
-
+ pdata->content_type = GNUNET_strdup (content_type);
pdata->value = GNUNET_malloc (size);
pdata->total_bytes = size;
memcpy (pdata->value, data, size);
pdata);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Copied %lld bytes of POST Data\n", size);
+ "Copied %llu bytes of POST Data\n",
+ (unsigned long long) size);
return MHD_YES;
}
memcpy (new_value, pdata->value, pdata->total_bytes);
memcpy (new_value+off, data, size);
GNUNET_free (pdata->value);
+ pdata->value = new_value;
pdata->total_bytes += size;
return MHD_YES;
-
}
if (0 != strcasecmp (MHD_HTTP_POST_ENCODING_FORM_URLENCODED,
if (0 == strcmp ("Host", key))
{
- port = strstr (value, ":");
+ port = strchr (value, ':');
if (NULL != port)
{
strncpy (buf, value, port-value);
return MHD_YES;
}
- if (0 == strcmp ("Accept-Encoding", key))
+ if (0 == strcmp (MHD_HTTP_HEADER_ACCEPT_ENCODING, key))
hdr_val = "";
else
hdr_val = value;
* Ask cURL for the select sets and schedule download
*/
static void
-curl_download_prepare ();
+curl_download_prepare (void);
/**
* Callback to free content
if (NULL != ctask->post_handler)
MHD_destroy_post_processor (ctask->post_handler);
+ if (GNUNET_SCHEDULER_NO_TASK != ctask->pp_task)
+ GNUNET_SCHEDULER_cancel (ctask->pp_task);
+
for (pdata = ctask->upload_data_head; NULL != pdata; pdata = ctask->upload_data_head)
{
GNUNET_CONTAINER_DLL_remove (ctask->upload_data_head,
struct ProxyCurlTask *ctask = cls;
struct ProxyREMatch *re_match;
ssize_t copied = 0;
- long long int bytes_to_copy = ctask->buffer_write_ptr - ctask->buffer_read_ptr;
+ size_t bytes_to_copy = ctask->buffer_write_ptr - ctask->buffer_read_ptr;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "MHD: content cb for %s. To copy: %lld\n",
- ctask->url, bytes_to_copy);
- GNUNET_assert (bytes_to_copy >= 0);
-
+ "MHD: content cb for %s. To copy: %u\n",
+ ctask->url, (unsigned int) bytes_to_copy);
if ((GNUNET_YES == ctask->download_is_finished) &&
(GNUNET_NO == ctask->download_error) &&
- (0 == bytes_to_copy)) /* &&
- (BUF_WAIT_FOR_CURL == ctask->buf_status))*/
+ (0 == bytes_to_copy))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"MHD: sending response for %s\n", ctask->url);
if ((GNUNET_YES == ctask->download_error) &&
(GNUNET_YES == ctask->download_is_finished) &&
- (0 == bytes_to_copy)) /* &&
- (BUF_WAIT_FOR_CURL == ctask->buf_status))*/
+ (0 == bytes_to_copy))
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"MHD: sending error response\n");
"MHD: Processing PP %s\n",
re_match->hostname);
bytes_to_copy = re_match->start - ctask->buffer_read_ptr;
- GNUNET_assert (bytes_to_copy >= 0);
-
if (bytes_to_copy+copied > max)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "MHD: buffer in response too small for %d. Using available space (%d). (%s)\n",
- bytes_to_copy,
- max,
- ctask->url);
+ "MHD: buffer in response too small for %u. Using available space (%d). (%s)\n",
+ (unsigned int) bytes_to_copy,
+ max,
+ ctask->url);
memcpy (buf+copied, ctask->buffer_read_ptr, max-copied);
ctask->buffer_read_ptr += max-copied;
copied = max;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "MHD: copied %d bytes\n", copied);
+ "MHD: copied %d bytes\n", (int) copied);
return copied;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "MHD: copying %d bytes to mhd response at offset %d\n",
- bytes_to_copy, ctask->buffer_read_ptr);
+ "MHD: copying %u bytes to mhd response at offset %d\n",
+ (unsigned int) bytes_to_copy, ctask->buffer_read_ptr);
memcpy (buf+copied, ctask->buffer_read_ptr, bytes_to_copy);
copied += bytes_to_copy;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"MHD: Waiting for PP of %s\n", re_match->hostname);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "MHD: copied %d bytes\n", copied);
+ "MHD: copied %d bytes\n", (int) copied);
ctask->buffer_read_ptr += bytes_to_copy;
return copied;
}
re_match->result,
ctask->url);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "MHD: copied %d bytes\n", copied);
+ "MHD: copied %d bytes\n", (int) copied);
ctask->buffer_read_ptr += bytes_to_copy;
return copied;
}
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"MHD: Adding PP result %s to buffer\n",
re_match->result);
- memcpy (buf+copied, re_match->result, strlen (re_match->result));
+ memcpy (buf + copied, re_match->result, strlen (re_match->result));
copied += strlen (re_match->result);
ctask->buffer_read_ptr = re_match->end;
GNUNET_CONTAINER_DLL_remove (ctask->pp_match_head,
bytes_to_copy = ctask->buffer_write_ptr - ctask->buffer_read_ptr;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "MHD: copied: %d left: %d, space left in buf: %d\n",
+ "MHD: copied: %d left: %u, space left in buf: %d\n",
copied,
- bytes_to_copy, max-copied);
+ (unsigned int) bytes_to_copy, (int) (max - copied));
- GNUNET_assert (0 <= bytes_to_copy);
-
if (GNUNET_NO == ctask->download_is_finished)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
ctask->buffer[bytes_to_copy] = '\0';
}
- if (bytes_to_copy+copied > max)
+ if (bytes_to_copy + copied > max)
bytes_to_copy = max-copied;
if (0 > bytes_to_copy)
curl_easy_pause (ctask->curl, CURLPAUSE_CONT);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "MHD: copied %d bytes\n", copied);
+ "MHD: copied %d bytes\n", (int) copied);
run_mhd_now (ctask->mhd);
return copied;
}
re_match->hostname,
result);
- if (re_match->ctask->mhd->is_ssl)
+ if (re_match->is_ssl)
sprintf (re_match->result, "href=\"https://%s", result);
else
sprintf (re_match->result, "href=\"http://%s", result);
memset (re_hostname, 0, sizeof (re_hostname));
memcpy (re_hostname, re_ptr+m[1].rm_so, (m[3].rm_eo-m[1].rm_so));
+
re_match = GNUNET_malloc (sizeof (struct ProxyREMatch));
re_match->start = re_ptr + m[0].rm_so;
re_match->end = re_ptr + m[3].rm_eo;
re_match->done = GNUNET_NO;
re_match->ctask = ctask;
+
+ if ('s' == *(re_ptr+m[1].rm_so-strlen("://")-1)) //FIXME strcmp
+ re_match->is_ssl = GNUNET_YES;
+ else
+ re_match->is_ssl = GNUNET_NO;
+
strcpy (re_match->hostname, re_hostname);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"PP: Got hostname %s\n", re_hostname);
}
num_ctasks=0;
- for (ctask=ctasks_head; NULL != ctask; ctask = ctask->next)
- {
- num_ctasks++;
- }
+ for (ctask=ctasks_head; NULL != ctask; ctask = ctask->next)
+ num_ctasks++;
if (num_ctasks != running)
{
ctask = GNUNET_malloc (sizeof (struct ProxyCurlTask));
strcpy (ctask->url, url);
- ctask->accepted = GNUNET_NO;
return ctask;
}
+
/**
* Main MHD callback for handling requests.
*
void **con_cls)
{
struct MhdHttpList* hd = cls;
- const char* page = "<html><head><title>gnoxy</title>"\
+ const char* page = "<html><head><title>gnunet-gns-proxy</title>"
"</head><body>cURL fail</body></html>";
char curlurl[MAX_HTTP_URI_LENGTH]; // buffer overflow!
int ret = MHD_YES;
int i;
-
struct ProxyCurlTask *ctask = *con_cls;
struct ProxyUploadData *fin_post;
struct curl_forms forms[5];
{
if (GNUNET_YES == ctask->is_httppost)
{
- i = 0;
for (upload_data_iter = ctask->upload_data_head;
NULL != upload_data_iter;
upload_data_iter = upload_data_iter->next)
{
+ i = 0;
if (NULL != upload_data_iter->filename)
{
forms[i].option = CURLFORM_FILENAME;
}
+
+#define UNSIGNED_MHD_LONG_LONG unsigned MHD_LONG_LONG
+
+
/**
* schedule mhd
*
struct GNUNET_NETWORK_FDSet *wes;
int max;
int haveto;
- unsigned MHD_LONG_LONG timeout;
+ UNSIGNED_MHD_LONG_LONG timeout;
struct GNUNET_TIME_Relative tv;
FD_ZERO (&rs);
if (GNUNET_SCHEDULER_NO_TASK != s5r->fwdwtask)
GNUNET_SCHEDULER_cancel (s5r->fwdwtask);
if (GNUNET_SCHEDULER_NO_TASK != s5r->fwdrtask)
- GNUNET_SCHEDULER_cancel (s5r->fwdrtask);
-
+ GNUNET_SCHEDULER_cancel (s5r->fwdrtask);
if (NULL != s5r->remote_sock)
GNUNET_NETWORK_socket_close (s5r->remote_sock);
if ((NULL != s5r->sock) && (s5r->cleanup_sock == GNUNET_YES))
*
* @param filename file to read
* @param size pointer where filesize is stored
- * @return data
+ * @return NULL on error
*/
-static char*
+static void*
load_file (const char* filename,
unsigned int* size)
{
- char *buffer;
+ void *buffer;
uint64_t fsize;
if (GNUNET_OK !=
gnutls_datum_t key_data;
int ret;
- key_data.data = (unsigned char*) load_file (keyfile, &key_data.size);
+ key_data.data = load_file (keyfile, &key_data.size);
ret = gnutls_x509_privkey_import (key, &key_data,
GNUTLS_X509_FMT_PEM);
if (GNUTLS_E_SUCCESS != ret)
load_cert_from_file (gnutls_x509_crt_t crt, char* certfile)
{
gnutls_datum_t cert_data;
- cert_data.data = NULL;
int ret;
- cert_data.data = (unsigned char*) load_file (certfile, &cert_data.size);
+ cert_data.data = load_file (certfile, &cert_data.size);
ret = gnutls_x509_crt_import (crt, &cert_data,
GNUTLS_X509_FMT_PEM);
if (GNUTLS_E_SUCCESS != ret)
static struct ProxyGNSCertificate *
generate_gns_certificate (const char *name)
{
-
int ret;
unsigned int serial;
size_t key_buf_size;
GNUNET_break (0);
}
- ret = gnutls_x509_crt_set_key (request, proxy_ca.key);
-
- if (GNUTLS_E_SUCCESS != ret)
- {
- GNUNET_break (0);
- }
+ GNUNET_break (GNUTLS_E_SUCCESS == gnutls_x509_crt_set_key (request, proxy_ca.key));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Generating cert\n");
gnutls_x509_crt_set_dn_by_oid (request, GNUTLS_OID_X520_COUNTRY_NAME,
0, "DE", 2);
-
gnutls_x509_crt_set_dn_by_oid (request, GNUTLS_OID_X520_ORGANIZATION_NAME,
- 0, "GNUnet", 6);
-
+ 0, "GADS", 4);
gnutls_x509_crt_set_dn_by_oid (request, GNUTLS_OID_X520_COMMON_NAME,
0, name, strlen (name));
-
- ret = gnutls_x509_crt_set_version (request, 3);
+ GNUNET_break (GNUTLS_E_SUCCESS == gnutls_x509_crt_set_version (request, 3));
ret = gnutls_rnd (GNUTLS_RND_NONCE, &serial, sizeof (serial));
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"No previous SSL instance found... starting new one for %s\n",
domain);
- hd->daemon = MHD_start_daemon (MHD_USE_DEBUG
- | MHD_USE_SSL
#if HAVE_MHD_NO_LISTEN_SOCKET
- | MHD_USE_NO_LISTEN_SOCKET,
+ hd->daemon = MHD_start_daemon (MHD_USE_DEBUG | MHD_USE_SSL | MHD_USE_NO_LISTEN_SOCKET,
0,
+ &accept_cb, NULL,
+ &create_response, hd,
+ MHD_OPTION_CONNECTION_LIMIT,
+ MHD_MAX_CONNECTIONS,
+ MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16,
+ MHD_OPTION_NOTIFY_COMPLETED, NULL, NULL,
+ MHD_OPTION_HTTPS_MEM_KEY, pgc->key,
+ MHD_OPTION_HTTPS_MEM_CERT, pgc->cert,
+ MHD_OPTION_URI_LOG_CALLBACK, &mhd_log_callback,
+ NULL,
+ MHD_OPTION_END);
#else
- , 4444, //Dummy
-#endif
+ hd->daemon = MHD_start_daemon (MHD_USE_DEBUG | MHD_USE_SSL,
+ 4444 /* dummy port */,
&accept_cb, NULL,
&create_response, hd,
-#if !HAVE_MHD_NO_LISTEN_SOCKET
- MHD_OPTION_LISTEN_SOCKET, GNUNET_NETWORK_get_fd (mhd_unix_socket),
-#endif
+ MHD_OPTION_LISTEN_SOCKET, GNUNET_NETWORK_get_fd (mhd_unix_socket),
MHD_OPTION_CONNECTION_LIMIT,
MHD_MAX_CONNECTIONS,
- MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16,
- MHD_OPTION_NOTIFY_COMPLETED, NULL, NULL,
- MHD_OPTION_HTTPS_MEM_KEY, pgc->key,
- MHD_OPTION_HTTPS_MEM_CERT, pgc->cert,
- MHD_OPTION_URI_LOG_CALLBACK, &mhd_log_callback,
- NULL,
- MHD_OPTION_END);
+ MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16,
+ MHD_OPTION_NOTIFY_COMPLETED, NULL, NULL,
+ MHD_OPTION_HTTPS_MEM_KEY, pgc->key,
+ MHD_OPTION_HTTPS_MEM_CERT, pgc->cert,
+ MHD_OPTION_URI_LOG_CALLBACK, &mhd_log_callback,
+ NULL,
+ MHD_OPTION_END);
GNUNET_assert (hd->daemon != NULL);
hd->httpd_task = GNUNET_SCHEDULER_NO_TASK;
mhd_httpd_head = NULL;
mhd_httpd_tail = NULL;
total_mhd_connections = 0;
-#ifndef HAVE_MHD_NO_LISTEN_SOCKET
+#if ! HAVE_MHD_NO_LISTEN_SOCKET
if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "gns-proxy",
"PROXY_UNIXPATH",
&proxy_sockfile))
hd = GNUNET_malloc (sizeof (struct MhdHttpList));
hd->is_ssl = GNUNET_NO;
strcpy (hd->domain, "");
- httpd = MHD_start_daemon (MHD_USE_DEBUG
+
#if HAVE_MHD_NO_LISTEN_SOCKET
- | MHD_USE_NO_LISTEN_SOCKET,
+ httpd = MHD_start_daemon (MHD_USE_DEBUG | MHD_USE_NO_LISTEN_SOCKET,
0,
+ &accept_cb, NULL,
+ &create_response, hd,
+ MHD_OPTION_CONNECTION_LIMIT, MHD_MAX_CONNECTIONS,
+ MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16,
+ MHD_OPTION_NOTIFY_COMPLETED,
+ NULL, NULL,
+ MHD_OPTION_URI_LOG_CALLBACK, &mhd_log_callback, NULL,
+ MHD_OPTION_END);
#else
- , 4444, //Dummy port
-#endif
- &accept_cb, NULL,
- &create_response, hd,
-#if !HAVE_MHD_NO_LISTEN_SOCKET
- MHD_OPTION_LISTEN_SOCKET, GNUNET_NETWORK_get_fd (mhd_unix_socket),
+ httpd = MHD_start_daemon (MHD_USE_DEBUG,
+ 4444 /* Dummy port */,
+ &accept_cb, NULL,
+ &create_response, hd,
+ MHD_OPTION_LISTEN_SOCKET, GNUNET_NETWORK_get_fd (mhd_unix_socket),
+ MHD_OPTION_CONNECTION_LIMIT, MHD_MAX_CONNECTIONS,
+ MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16,
+ MHD_OPTION_NOTIFY_COMPLETED,
+ NULL, NULL,
+ MHD_OPTION_URI_LOG_CALLBACK, &mhd_log_callback, NULL,
+ MHD_OPTION_END);
#endif
- MHD_OPTION_CONNECTION_LIMIT, MHD_MAX_CONNECTIONS,
- MHD_OPTION_CONNECTION_TIMEOUT, (unsigned int) 16,
- MHD_OPTION_NOTIFY_COMPLETED,
- NULL, NULL,
- MHD_OPTION_URI_LOG_CALLBACK, &mhd_log_callback, NULL,
- MHD_OPTION_END);
GNUNET_assert (httpd != NULL);
hd->daemon = httpd;
{
static const struct GNUNET_GETOPT_CommandLineOption options[] = {
{'p', "port", NULL,
- gettext_noop ("listen on specified port"), 1,
- &GNUNET_GETOPT_set_string, &port},
+ gettext_noop ("listen on specified port (default: 7777)"), 1,
+ &GNUNET_GETOPT_set_ulong, &port},
{'a', "authority", NULL,
gettext_noop ("pem file to use as CA"), 1,
&GNUNET_GETOPT_set_string, &cafile_opt},