HTTP server to create GNS business cards. More...
#include "platform.h"
#include <microhttpd.h>
#include "gnunet_util_lib.h"
#include "gnunet_mhd_compat.h"
Go to the source code of this file.
Data Structures | |
struct | StaticResource |
struct | ParameterMap |
Functions | |
static void | do_shutdown (void *cls) |
Task ran at shutdown to clean up everything. More... | |
static void | do_httpd (void *cls) |
Called when the HTTP server has some pending operations. More... | |
static void | run_httpd (void) |
Schedule a task to run MHD. More... | |
static MHD_RESULT | create_response (void *cls, struct MHD_Connection *connection, const char *url, const char *method, const char *version, const char *upload_data, size_t *upload_data_size, void **ptr) |
Send a response back to a connected client. More... | |
static struct StaticResource * | open_static_resource (const char *name, const char *basedir) |
Open a file on disk and generate a response for it. More... | |
static void | run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) |
Main function that will be run. More... | |
int | main (int argc, char *const *argv) |
The main function for gnunet-gns. More... | |
Variables | |
static struct MHD_Daemon * | httpd = NULL |
Handle to the HTTP server as provided by libmicrohttpd. More... | |
static struct GNUNET_SCHEDULER_Task * | httpd_task = NULL |
Our primary task for the HTTPD. More... | |
static struct StaticResource * | index_simple = NULL |
Index file resource (simple result). More... | |
static struct StaticResource * | index_full = NULL |
Index file resource (full result). More... | |
static struct StaticResource * | key_error = NULL |
Error: invalid gns key. More... | |
static struct StaticResource * | notfound_error = NULL |
Error: 404. More... | |
static struct StaticResource * | internal_error = NULL |
Errors after receiving the form data. More... | |
static struct StaticResource * | forbidden_error = NULL |
Other errors. More... | |
static char * | tex_file_simple = NULL |
Full path to the TeX template file (simple result) More... | |
static char * | tex_file_full = NULL |
Full path to the TeX template file (full result) More... | |
static char * | tex_file_png = NULL |
Full path to the TeX template file (PNG result) More... | |
static int | continue_100 = 100 |
Used as a sort of singleton to send exactly one 100 CONTINUE per request. More... | |
static const struct ParameterMap | pmap [] |
Map of names with TeX definitions, used during PDF generation. More... | |
static uint16_t | port = 8888 |
Port number. More... | |
HTTP server to create GNS business cards.
Definition in file gnunet-bcd.c.
|
static |
Task ran at shutdown to clean up everything.
cls | unused |
Definition at line 154 of file gnunet-bcd.c.
References forbidden_error, GNUNET_free, GNUNET_SCHEDULER_cancel(), StaticResource::handle, httpd, httpd_task, index_full, index_simple, internal_error, key_error, notfound_error, and StaticResource::response.
Referenced by run().
|
static |
Called when the HTTP server has some pending operations.
cls | unused |
Definition at line 268 of file gnunet-bcd.c.
References httpd, httpd_task, and run_httpd().
Referenced by run_httpd().
|
static |
Schedule a task to run MHD.
Definition at line 221 of file gnunet-bcd.c.
References do_httpd(), GNUNET_assert, GNUNET_NETWORK_fdset_copy_native(), GNUNET_NETWORK_fdset_create(), GNUNET_NETWORK_fdset_destroy(), GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_PRIORITY_HIGH, GNUNET_TIME_relative_multiply(), GNUNET_TIME_UNIT_FOREVER_REL, GNUNET_TIME_UNIT_MILLISECONDS, httpd, httpd_task, max, and timeout.
Referenced by do_httpd(), and run().
|
static |
Send a response back to a connected client.
cls | unused |
connection | the connection with the client |
url | the requested address |
method | the HTTP method used |
version | the protocol version (including the "HTTP/" part) |
upload_data | data sent with a POST request |
upload_data_size | length in bytes of the POST data |
ptr | used to pass data between request handling phases |
Definition at line 290 of file gnunet-bcd.c.
References continue_100, DIR_SEPARATOR_STR, forbidden_error, GNUNET_asprintf(), GNUNET_assert, GNUNET_break, GNUNET_CRYPTO_public_key_from_string(), GNUNET_DISK_directory_remove(), GNUNET_DISK_mkdtemp(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_log_strerror_file, GNUNET_OK, GNUNET_strdup, GNUNET_strndup, index_full, index_simple, internal_error, key_error, MHD_HTTP_BAD_REQUEST, MHD_HTTP_INTERNAL_SERVER_ERROR, MHD_HTTP_NOT_FOUND, MHD_HTTP_NOT_IMPLEMENTED, MHD_HTTP_OK, MHD_RESULT, name, ParameterMap::name, notfound_error, pk, pmap, StaticResource::response, ret, tex_file_full, tex_file_png, tex_file_simple, and value.
Referenced by run().
|
static |
Open a file on disk and generate a response for it.
name | name of the file to open |
basedir | directory where the file is located |
Definition at line 524 of file gnunet-bcd.c.
References DIR_SEPARATOR_STR, removetrailingwhitespace::f, GNUNET_asprintf(), GNUNET_DISK_file_close(), GNUNET_DISK_file_handle_size(), GNUNET_DISK_file_open(), GNUNET_DISK_OPEN_READ, GNUNET_DISK_PERM_NONE, GNUNET_free, GNUNET_new, GNUNET_SYSERR, name, res, response, and size.
Referenced by run().
|
static |
Main function that will be run.
cls | closure |
args | remaining command-line arguments |
cfgfile | name of the configuration file used (for saving, can be NULL!) |
c | configuration |
Definition at line 576 of file gnunet-bcd.c.
References _, consensus-simulation::args, create_response(), DIR_SEPARATOR_STR, do_shutdown(), forbidden_error, GNUNET_asprintf(), GNUNET_assert, GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log, GNUNET_OS_installation_get_path(), GNUNET_OS_IPK_DATADIR, GNUNET_OS_project_data_gnunet(), GNUNET_SCHEDULER_add_shutdown(), GNUNET_SCHEDULER_shutdown(), httpd, index_full, index_simple, internal_error, key_error, notfound_error, open_static_resource(), port, run_httpd(), tex_file_full, tex_file_png, and tex_file_simple.
Referenced by main().
int main | ( | int | argc, |
char *const * | argv | ||
) |
The main function for gnunet-gns.
argc | number of arguments from the command line |
argv | command line arguments |
Definition at line 673 of file gnunet-bcd.c.
References _, gettext_noop, GNUNET_GETOPT_OPTION_END, GNUNET_GETOPT_option_uint16(), GNUNET_OK, GNUNET_OS_project_data_gnunet(), GNUNET_PROGRAM_run(), options, port, and run().
|
static |
Handle to the HTTP server as provided by libmicrohttpd.
Definition at line 66 of file gnunet-bcd.c.
Referenced by do_httpd(), do_shutdown(), run(), and run_httpd().
|
static |
Our primary task for the HTTPD.
Definition at line 71 of file gnunet-bcd.c.
Referenced by do_httpd(), do_shutdown(), and run_httpd().
|
static |
Index file resource (simple result).
Definition at line 76 of file gnunet-bcd.c.
Referenced by create_response(), do_shutdown(), and run().
|
static |
Index file resource (full result).
Definition at line 81 of file gnunet-bcd.c.
Referenced by create_response(), do_shutdown(), and run().
|
static |
Error: invalid gns key.
Definition at line 86 of file gnunet-bcd.c.
Referenced by create_response(), do_shutdown(), and run().
|
static |
Error: 404.
Definition at line 91 of file gnunet-bcd.c.
Referenced by create_response(), do_shutdown(), and run().
|
static |
Errors after receiving the form data.
Definition at line 96 of file gnunet-bcd.c.
Referenced by create_response(), do_shutdown(), and run().
|
static |
Other errors.
Definition at line 101 of file gnunet-bcd.c.
Referenced by create_response(), do_shutdown(), and run().
|
static |
Full path to the TeX template file (simple result)
Definition at line 106 of file gnunet-bcd.c.
Referenced by create_response(), and run().
|
static |
Full path to the TeX template file (full result)
Definition at line 111 of file gnunet-bcd.c.
Referenced by create_response(), and run().
|
static |
Full path to the TeX template file (PNG result)
Definition at line 116 of file gnunet-bcd.c.
Referenced by create_response(), and run().
|
static |
Used as a sort of singleton to send exactly one 100 CONTINUE per request.
Definition at line 121 of file gnunet-bcd.c.
Referenced by create_response().
|
static |
Map of names with TeX definitions, used during PDF generation.
Definition at line 126 of file gnunet-bcd.c.
Referenced by create_response(), and run().
|
static |
Port number.
Definition at line 146 of file gnunet-bcd.c.
Referenced by advertise_dns_exit(), client_release_ports(), connect_tunnel(), convert_messenger_key_to_port(), create_channel(), destroy_port_cb(), DHTU_ip_init(), dns_string_to_value(), extract_port(), GC_u2h(), GCCH_bind(), GCCH_channel_local_new(), GCCH_handle_channel_open_ack(), GCCH_hash_port(), get_cadet(), get_server_addresses(), GNUNET_CADET_channel_create(), GNUNET_CADET_open_port(), GNUNET_CLIENT_test(), GNUNET_GNS_service_port_number_to_name(), GNUNET_HOSTLIST_server_start(), GNUNET_NAT_mini_map_start(), GNUNET_NAT_stun_make_request(), GNUNET_NETWORK_test_port_free(), GNUNET_REGEX_ipv4toregexsearch(), GNUNET_REGEX_ipv6toregexsearch(), GNUNET_SOCKS_set_handshake_destination(), GNUNET_STRINGS_to_address_ipv4(), GNUNET_STRINGS_to_address_ipv6(), GNUNET_TESTBED_release_port(), GSC_bind(), GSF_cadet_start_server(), handle_channel_created(), handle_regex_result(), handle_register(), ip_try_connect(), lookup_hole_external(), main(), nat_server_read(), open_listen_socket(), open_port_cb(), open_srv_room(), process_icmp_response(), process_map_output(), reset_cadet(), run(), tcp_address_to_sockaddr(), tcp_address_to_sockaddr_numeric_v4(), tcp_address_to_sockaddr_numeric_v6(), tcp_address_to_sockaddr_port_only(), test_service_configuration(), try_open_exit(), and udp_address_to_sockaddr().