aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/handbook/chapters/developer.texi8
-rw-r--r--src/namestore/gnunet-namestore-fcfsd.c60
2 files changed, 46 insertions, 22 deletions
diff --git a/doc/handbook/chapters/developer.texi b/doc/handbook/chapters/developer.texi
index f8eebbb58..3d9493cec 100644
--- a/doc/handbook/chapters/developer.texi
+++ b/doc/handbook/chapters/developer.texi
@@ -8760,14 +8760,14 @@ return a HTML document, and two other HTML documents which will be served when
8760certain errors are encountered, like when requesting an unknown endpoint. 8760certain errors are encountered, like when requesting an unknown endpoint.
8761 8761
8762@menu 8762@menu
8763* Obtaining informations from the daemon:: 8763* Obtaining information from the daemon::
8764* Submitting data to the daemon:: 8764* Submitting data to the daemon::
8765* Customizing the HTML output:: 8765* Customizing the HTML output::
8766@end menu 8766@end menu
8767 8767
8768@cindex FCFSD GET requests 8768@cindex FCFSD GET requests
8769@node Obtaining informations from the daemon 8769@node Obtaining information from the daemon
8770@subsubsection Obtaining informations from the daemon 8770@subsubsection Obtaining information from the daemon
8771 8771
8772To query the daemon, a GET request must be sent to these endpoints, placing 8772To query the daemon, a GET request must be sent to these endpoints, placing
8773parameters in the address as per the HTTP specification, like so: 8773parameters in the address as per the HTTP specification, like so:
@@ -8860,7 +8860,7 @@ Within the provided path, the daemon will search for these three files:
8860@end itemize 8860@end itemize
8861 8861
8862The @file{fcfsd-index.html} file is the daemon's ``homepage'': operators might 8862The @file{fcfsd-index.html} file is the daemon's ``homepage'': operators might
8863want to provide informations about the service here, or provide a form with 8863want to provide information about the service here, or provide a form with
8864which it is possible to register a name. 8864which it is possible to register a name.
8865 8865
8866The @file{fcfsd-notfound.html} file is used primarily to let users know they 8866The @file{fcfsd-notfound.html} file is used primarily to let users know they
diff --git a/src/namestore/gnunet-namestore-fcfsd.c b/src/namestore/gnunet-namestore-fcfsd.c
index e1fa0a0a6..847f7cb64 100644
--- a/src/namestore/gnunet-namestore-fcfsd.c
+++ b/src/namestore/gnunet-namestore-fcfsd.c
@@ -207,6 +207,7 @@ do_shutdown (void *cls)
207 } 207 }
208} 208}
209 209
210
210/** 211/**
211 * Called when the HTTP server has some pending operations. 212 * Called when the HTTP server has some pending operations.
212 * 213 *
@@ -259,6 +260,7 @@ run_httpd (void)
259 GNUNET_NETWORK_fdset_destroy (ges); 260 GNUNET_NETWORK_fdset_destroy (ges);
260} 261}
261 262
263
262/** 264/**
263 * Called when the HTTP server has some pending operations. 265 * Called when the HTTP server has some pending operations.
264 * 266 *
@@ -272,6 +274,7 @@ do_httpd (void *cls)
272 run_httpd (); 274 run_httpd ();
273} 275}
274 276
277
275static void 278static void
276run_httpd_now (void) 279run_httpd_now (void)
277{ 280{
@@ -283,6 +286,7 @@ run_httpd_now (void)
283 httpd_task = GNUNET_SCHEDULER_add_now (&do_httpd, NULL); 286 httpd_task = GNUNET_SCHEDULER_add_now (&do_httpd, NULL);
284} 287}
285 288
289
286/** 290/**
287 * Generate a JSON object. 291 * Generate a JSON object.
288 * 292 *
@@ -295,12 +299,12 @@ static char *
295make_json (const char *key, const char *value, ...) 299make_json (const char *key, const char *value, ...)
296{ 300{
297 va_list args; 301 va_list args;
298 va_start(args, value); 302 va_start (args, value);
299 303
300 json_t *obj = NULL; 304 json_t *obj = NULL;
301 305
302 obj = json_object (); 306 obj = json_object ();
303 if (NULL == key || NULL == value) 307 if ((NULL == key) || (NULL == value))
304 { 308 {
305 va_end (args); 309 va_end (args);
306 return json_dumps (obj, JSON_COMPACT); 310 return json_dumps (obj, JSON_COMPACT);
@@ -339,6 +343,7 @@ make_json (const char *key, const char *value, ...)
339 return json; 343 return json;
340} 344}
341 345
346
342/** 347/**
343 * The namestore search task failed. 348 * The namestore search task failed.
344 * 349 *
@@ -358,6 +363,7 @@ search_error_cb (void *cls)
358 run_httpd_now (); 363 run_httpd_now ();
359} 364}
360 365
366
361/** 367/**
362 * The lookup terminated with some results. 368 * The lookup terminated with some results.
363 * 369 *
@@ -390,6 +396,7 @@ search_done_cb (void *cls,
390 run_httpd_now (); 396 run_httpd_now ();
391} 397}
392 398
399
393/** 400/**
394 * An error occurred while registering a name. 401 * An error occurred while registering a name.
395 * 402 *
@@ -410,6 +417,7 @@ register_error_cb (void *cls)
410 run_httpd_now (); 417 run_httpd_now ();
411} 418}
412 419
420
413/** 421/**
414 * A name/key pair has been successfully registered, or maybe not. 422 * A name/key pair has been successfully registered, or maybe not.
415 * 423 *
@@ -427,7 +435,7 @@ register_done_cb (void *cls,
427 MHD_resume_connection (rd->c); 435 MHD_resume_connection (rd->c);
428 rd->searching = NULL; 436 rd->searching = NULL;
429 437
430 if (GNUNET_SYSERR == status || GNUNET_NO == status) 438 if ((GNUNET_SYSERR == status) || (GNUNET_NO == status))
431 { 439 {
432 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 440 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
433 _ ("Failed to create record for `%s': %s\n"), 441 _ ("Failed to create record for `%s': %s\n"),
@@ -451,6 +459,7 @@ register_done_cb (void *cls,
451 run_httpd_now (); 459 run_httpd_now ();
452} 460}
453 461
462
454/** 463/**
455 * Attempt to register the requested name. 464 * Attempt to register the requested name.
456 * 465 *
@@ -528,6 +537,7 @@ register_do_cb (void *cls,
528 GNUNET_free (gdraw); 537 GNUNET_free (gdraw);
529} 538}
530 539
540
531/** 541/**
532 * An error occurred while iterating the namestore. 542 * An error occurred while iterating the namestore.
533 * 543 *
@@ -548,6 +558,7 @@ iterate_error_cb (void *cls)
548 run_httpd_now (); 558 run_httpd_now ();
549} 559}
550 560
561
551/** 562/**
552 * A block was received from the namestore. 563 * A block was received from the namestore.
553 * 564 *
@@ -592,6 +603,7 @@ iterate_do_cb (void *cls,
592 GNUNET_NAMESTORE_zone_iterator_next (rd->iterating, 1); 603 GNUNET_NAMESTORE_zone_iterator_next (rd->iterating, 1);
593} 604}
594 605
606
595/** 607/**
596 * All entries in the namestore have been iterated over. 608 * All entries in the namestore have been iterated over.
597 * 609 *
@@ -614,6 +626,7 @@ iterate_done_cb (void *cls)
614 rd); 626 rd);
615} 627}
616 628
629
617/** 630/**
618 * Generate a response containing JSON and send it to the client. 631 * Generate a response containing JSON and send it to the client.
619 * 632 *
@@ -638,6 +651,7 @@ serve_json (struct MHD_Connection *c,
638 return r; 651 return r;
639} 652}
640 653
654
641/** 655/**
642 * Send a response back to a connected client. 656 * Send a response back to a connected client.
643 * 657 *
@@ -732,7 +746,7 @@ create_response (void *cls,
732 if (0 == strcmp ("/register", url)) 746 if (0 == strcmp ("/register", url))
733 { 747 {
734 /* Handle a previously suspended request */ 748 /* Handle a previously suspended request */
735 if (NULL != rd && NULL != rd->body) 749 if ((NULL != rd) && (NULL != rd->body))
736 { 750 {
737 return serve_json (rd->c, rd->body, rd->body_length, rd->code); 751 return serve_json (rd->c, rd->body, rd->body_length, rd->code);
738 } 752 }
@@ -781,9 +795,11 @@ create_response (void *cls,
781 795
782 /* POST data has been read in its entirety */ 796 /* POST data has been read in its entirety */
783 797
784 const char *name = json_string_value(json_object_get(json, "name")); 798 const char *name = json_string_value (json_object_get (json, "name"));
785 const char *key = json_string_value(json_object_get(json, "key")); 799 const char *key = json_string_value (json_object_get (json, "key"));
786 if (NULL == name || NULL == key || 0 == strlen (name) || 0 == strlen (key)) 800 if ((NULL == name) || (NULL == key) || (0 == strlen (name)) || (0 ==
801 strlen (
802 key)))
787 { 803 {
788 json_decref (json); 804 json_decref (json);
789 rd->body = make_json ("error", "true", 805 rd->body = make_json ("error", "true",
@@ -800,8 +816,8 @@ create_response (void *cls,
800 json_decref (json); 816 json_decref (json);
801 GNUNET_JSON_post_parser_cleanup (rd->ptr); 817 GNUNET_JSON_post_parser_cleanup (rd->ptr);
802 818
803 if (NULL != strchr (rd->register_name, '.') || 819 if ((NULL != strchr (rd->register_name, '.')) ||
804 NULL != strchr (rd->register_name, '+')) 820 (NULL != strchr (rd->register_name, '+')))
805 { 821 {
806 rd->body = make_json ("error", "true", 822 rd->body = make_json ("error", "true",
807 "message", _ ("invalid name"), 823 "message", _ ("invalid name"),
@@ -850,6 +866,7 @@ create_response (void *cls,
850 forbidden_page->response); 866 forbidden_page->response);
851} 867}
852 868
869
853/** 870/**
854 * Called when a request is completed. 871 * Called when a request is completed.
855 * 872 *
@@ -903,6 +920,7 @@ completed_cb (void *cls,
903 GNUNET_free (rd); 920 GNUNET_free (rd);
904} 921}
905 922
923
906/** 924/**
907 * Called for each ego provided by the identity service. 925 * Called for each ego provided by the identity service.
908 * 926 *
@@ -920,7 +938,7 @@ identity_cb (void *cls,
920 (void) cls; 938 (void) cls;
921 (void) ctx; 939 (void) ctx;
922 940
923 if (NULL == name || 0 != strcmp (name, zone)) 941 if ((NULL == name) || (0 != strcmp (name, zone)))
924 { 942 {
925 return; 943 return;
926 } 944 }
@@ -961,6 +979,7 @@ identity_cb (void *cls,
961 run_httpd (); 979 run_httpd ();
962} 980}
963 981
982
964/** 983/**
965 * Open a file on disk and generate a response object for it. 984 * Open a file on disk and generate a response object for it.
966 * 985 *
@@ -1009,6 +1028,7 @@ open_static_page (const char *name, const char *basedir)
1009 return page; 1028 return page;
1010} 1029}
1011 1030
1031
1012/** 1032/**
1013 * Called after the service is up. 1033 * Called after the service is up.
1014 * 1034 *
@@ -1073,7 +1093,8 @@ run_service (void *cls,
1073 1093
1074 GNUNET_free (basedir); 1094 GNUNET_free (basedir);
1075 1095
1076 if (NULL == main_page || NULL == notfound_page || NULL == forbidden_page) 1096 if ((NULL == main_page) || (NULL == notfound_page) || (NULL ==
1097 forbidden_page) )
1077 { 1098 {
1078 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1099 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1079 _ ("Unable to set up the daemon\n")); 1100 _ ("Unable to set up the daemon\n"));
@@ -1082,11 +1103,12 @@ run_service (void *cls,
1082 } 1103 }
1083} 1104}
1084 1105
1106
1085/** 1107/**
1086 * The main function of the fcfs daemon. 1108 * The main function of the fcfs daemon.
1087 * 1109 *
1088 * @param argc number of arguments from the command line 1110 * @param argc number of arguments from the command line
1089 * @parsm argv the command line argumens 1111 * @parsm argv the command line arguments
1090 * @return 0 successful exit, a different value otherwise 1112 * @return 0 successful exit, a different value otherwise
1091 */ 1113 */
1092int 1114int
@@ -1094,18 +1116,20 @@ main (int argc, char *const *argv)
1094{ 1116{
1095 struct GNUNET_GETOPT_CommandLineOption options[] = { 1117 struct GNUNET_GETOPT_CommandLineOption options[] = {
1096 GNUNET_GETOPT_option_mandatory 1118 GNUNET_GETOPT_option_mandatory
1097 (GNUNET_GETOPT_option_string ('z', 1119 (GNUNET_GETOPT_option_string ('z',
1098 "zone", 1120 "zone",
1099 "EGO", 1121 "EGO",
1100 gettext_noop ("name of the zone managed by FCFSD"), 1122 gettext_noop (
1101 &zone)), 1123 "name of the zone managed by FCFSD"),
1124 &zone)),
1102 GNUNET_GETOPT_OPTION_END 1125 GNUNET_GETOPT_OPTION_END
1103 }; 1126 };
1104 1127
1105 return ((GNUNET_OK == GNUNET_PROGRAM_run (argc, 1128 return ((GNUNET_OK == GNUNET_PROGRAM_run (argc,
1106 argv, 1129 argv,
1107 "gnunet-namestore-fcfsd", 1130 "gnunet-namestore-fcfsd",
1108 _ ("GNU Name System First-Come-First-Served name registration service"), 1131 _ (
1132 "GNU Name System First-Come-First-Served name registration service"),
1109 options, 1133 options,
1110 &run_service, 1134 &run_service,
1111 NULL)) ? 1135 NULL)) ?