[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-donau] branch master updated: cleanup
From: |
gnunet |
Subject: |
[taler-donau] branch master updated: cleanup |
Date: |
Tue, 02 Jan 2024 15:37:01 +0100 |
This is an automated email from the git hooks/post-receive script.
johannes-casaburi pushed a commit to branch master
in repository donau.
The following commit(s) were added to refs/heads/master by this push:
new af7199c cleanup
af7199c is described below
commit af7199cba6d9e3f4054ae11975d7bc3fb4c0156f
Author: Casaburi Johannes <johannes.casaburi@students.bfh.ch>
AuthorDate: Tue Jan 2 15:36:50 2024 +0100
cleanup
---
src/donau/donau-httpd.c | 381 +-----------------------------------------------
1 file changed, 1 insertion(+), 380 deletions(-)
diff --git a/src/donau/donau-httpd.c b/src/donau/donau-httpd.c
index 853af83..45d47fa 100644
--- a/src/donau/donau-httpd.c
+++ b/src/donau/donau-httpd.c
@@ -49,7 +49,7 @@
* Above what request latency do we start to log?
*/
#define WARN_LATENCY GNUNET_TIME_relative_multiply ( \
- GNUNET_TIME_UNIT_MILLISECONDS, 500)
+ GNUNET_TIME_UNIT_MILLISECONDS, 500)
/**
* Are clients allowed to request /keys for times other than the
@@ -220,25 +220,6 @@ typedef MHD_RESULT
const struct TALER_CoinSpendPublicKeyP *coin_pub,
const json_t *root);
-
-/**
- * Generate a 404 "not found" reply on @a connection with
- * the hint @a details.
- *
- * @param connection where to send the reply on
- * @param details details for the error message, can be NULL
- */
-// static MHD_RESULT
-// r404 (struct MHD_Connection *connection,
-// const char *details)
-// {
-// return TALER_MHD_reply_with_error (connection,
-// MHD_HTTP_NOT_FOUND,
-//
TALER_EC_EXCHANGE_GENERIC_OPERATION_UNKNOWN,
-// details);
-// }
-
-
/**
* Function called whenever MHD is done with a request. If the
* request was a POST, we may have stored a `struct Buffer *` in the
@@ -441,43 +422,6 @@ proceed_with_handler (struct DH_RequestContext *rc,
}
-/**
- * Handle a "/seed" request.
- *
- * @param rc request context
- * @param args array of additional options (must be empty for this function)
- * @return MHD result code
- */
-static MHD_RESULT
-handler_seed (struct DH_RequestContext *rc,
- const char *const args[])
-{
-#define SEED_SIZE 32
- char *body;
- MHD_RESULT ret;
- struct MHD_Response *resp;
-
- (void) args;
- body = malloc (SEED_SIZE); /* must use malloc(), because MHD will use free()
*/
- if (NULL == body)
- return MHD_NO;
- GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
- body,
- SEED_SIZE);
- resp = MHD_create_response_from_buffer (SEED_SIZE,
- body,
- MHD_RESPMEM_MUST_FREE);
- TALER_MHD_add_global_headers (resp);
- ret = MHD_queue_response (rc->connection,
- MHD_HTTP_OK,
- resp);
- GNUNET_break (MHD_YES == ret);
- MHD_destroy_response (resp);
- return ret;
-#undef SEED_SIZE
-}
-
-
/**
* Handle incoming HTTP request.
*
@@ -511,69 +455,6 @@ handle_mhd_request (void *cls,
.data = "User-agent: *\nDisallow: /\n",
.response_code = MHD_HTTP_OK
},
-/* Landing page, tell humans to go away. */
- {
- .url = "",
- .method = MHD_HTTP_METHOD_GET,
- // .handler.get = DH_handler_static_response,
- .mime_type = "text/plain",
- .data =
- "Hello, I'm the Taler donau. This HTTP server is not for humans.\n",
- .response_code = MHD_HTTP_OK
- },
-/* AGPL licensing page, redirect to source. As per the AGPL-license, every
- deployment is required to offer the user a download of the source of
- the actual deployment. We make this easy by including a redirect to the
- source here. */
- {
- .url = "agpl",
- .method = MHD_HTTP_METHOD_GET,
- // .handler.get = &DH_handler_agpl_redirect
- },
- {
- .url = "seed",
- .method = MHD_HTTP_METHOD_GET,
- .handler.get = &handler_seed
- },
-/* Configuration */
- {
- .url = "config",
- .method = MHD_HTTP_METHOD_GET,
- // .handler.get = &DH_handler_config
- },
-/* Performance metrics */
- {
- .url = "metrics",
- .method = MHD_HTTP_METHOD_GET,
- // .handler.get = &DH_handler_metrics
- },
-/* Terms of service */
- {
- .url = "terms",
- .method = MHD_HTTP_METHOD_GET,
- // .handler.get = &DH_handler_terms
- },
-/* Privacy policy */
- {
- .url = "privacy",
- .method = MHD_HTTP_METHOD_GET,
- // .handler.get = &DH_handler_privacy
- },
-/* Return key material and fundamental properties for this donau */
- {
- .url = "keys",
- .method = MHD_HTTP_METHOD_GET,
- // .handler.get = &DH_keys_get_handler,
- },
-/* request R, used in clause schnorr withdraw and refresh */
- {
- .url = "csr-melt",
- .method = MHD_HTTP_METHOD_POST,
- // .handler.post = &DH_handler_csr_melt,
- .nargs = 0
- },
-
-
/* mark end of list */
{
.url = NULL
@@ -871,249 +752,9 @@ donau_serve_process_config (void)
return GNUNET_SYSERR;
}
- // {
- // char *master_public_key_str;
-
- // if (GNUNET_OK !=
- // GNUNET_CONFIGURATION_get_value_string (DH_cfg,
- // "donau",
- // "MASTER_PUBLIC_KEY",
- // &master_public_key_str))
- // {
- // GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- // "donau",
- // "MASTER_PUBLIC_KEY");
- // return GNUNET_SYSERR;
- // }
- // if (GNUNET_OK !=
- // GNUNET_CRYPTO_eddsa_public_key_from_string (master_public_key_str,
- // strlen (
- //
master_public_key_str),
- // &DH_master_public_key.
- // eddsa_pub))
- // {
- // GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_ERROR,
- // "donau",
- // "MASTER_PUBLIC_KEY",
- // "invalid base32 encoding for a master
public key");
- // GNUNET_free (master_public_key_str);
- // return GNUNET_SYSERR;
- // }
- // GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- // "Launching donau with public key `%s'...\n",
- // master_public_key_str);
- // GNUNET_free (master_public_key_str);
- // }
-
- // {
- // char *attr_enc_key_str;
-
- // if (GNUNET_OK !=
- // GNUNET_CONFIGURATION_get_value_string (DH_cfg,
- // "donau",
- // "ATTRIBUTE_ENCRYPTION_KEY",
- // &attr_enc_key_str))
- // {
- // GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
- // "donau",
- // "ATTRIBUTE_ENCRYPTION_KEY");
- // return GNUNET_SYSERR;
- // }
- // GNUNET_CRYPTO_hash (attr_enc_key_str,
- // strlen (attr_enc_key_str),
- // &DH_attribute_key.hash);
- // GNUNET_free (attr_enc_key_str);
- // }
-
- // for (unsigned int i = 0; i<MAX_DB_RETRIES; i++)
- // {
- // DH_plugin = DONAUDB_plugin_load (DH_cfg);
- // if (NULL != DH_plugin)
- // break;
- // GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- // "Failed to connect to DB, will try again %u times\n",
- // MAX_DB_RETRIES - i);
- // sleep (1);
- // }
- // if (NULL == DH_plugin)
- // {
- // GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- // "Failed to initialize DB subsystem. Giving up.\n");
- // return GNUNET_SYSERR;
- // }
return GNUNET_OK;
}
-
-/**
- * Called when the main thread exits, writes out performance
- * stats if requested.
- */
-static void
-write_stats (void)
-{
- struct GNUNET_DISK_FileHandle *fh;
- pid_t pid = getpid ();
- char *benchmark_dir;
- char *s;
- struct rusage usage;
-
- benchmark_dir = getenv ("GNUNET_BENCHMARK_DIR");
- if (NULL == benchmark_dir)
- return;
- GNUNET_asprintf (&s,
- "%s/taler-donau-%llu.txt",
- benchmark_dir,
- (unsigned long long) pid);
- fh = GNUNET_DISK_file_open (s,
- (GNUNET_DISK_OPEN_WRITE
- | GNUNET_DISK_OPEN_TRUNCATE
- | GNUNET_DISK_OPEN_CREATE),
- (GNUNET_DISK_PERM_USER_READ
- | GNUNET_DISK_PERM_USER_WRITE));
- GNUNET_free (s);
- if (NULL == fh)
- return; /* permission denied? */
-
- /* Collect stats, summed up for all threads */
- GNUNET_assert (0 ==
- getrusage (RUSAGE_SELF,
- &usage));
- GNUNET_asprintf (&s,
- "time_donau sys %llu user %llu\n",
- (unsigned long long) (usage.ru_stime.tv_sec * 1000 * 1000
- + usage.ru_stime.tv_usec),
- (unsigned long long) (usage.ru_utime.tv_sec * 1000 * 1000
- + usage.ru_utime.tv_usec));
- GNUNET_assert (GNUNET_SYSERR !=
- GNUNET_DISK_file_write_blocking (fh,
- s,
- strlen (s)));
- GNUNET_free (s);
- GNUNET_assert (GNUNET_OK ==
- GNUNET_DISK_file_close (fh));
-}
-
-
-/* Developer logic for supporting the `-f' option. */
-
-#if HAVE_DEVELOPER
-/**
- * Option `-f' (specifies an input file to give to the HTTP server).
- */
-static char *input_filename;
-
-
-/**
- * Run 'nc' or 'ncat' as a fake HTTP client using #input_filename
- * as the input for the request. If launching the client worked,
- * run the #DH_KS_loop() event loop as usual.
- *
- * @return child pid
- */
-static pid_t
-run_fake_client (void)
-{
- pid_t cld;
- char ports[6];
- int fd;
-
- if (0 == strcmp (input_filename,
- "-"))
- fd = STDIN_FILENO;
- else
- fd = open (input_filename,
- O_RDONLY);
- if (-1 == fd)
- {
- fprintf (stderr,
- "Failed to open `%s': %s\n",
- input_filename,
- strerror (errno));
- return -1;
- }
- /* Fake HTTP client request with #input_filename as input.
- We do this using the nc tool. */
- GNUNET_snprintf (ports,
- sizeof (ports),
- "%u",
- serve_port);
- if (0 == (cld = fork ()))
- {
- GNUNET_break (0 == close (0));
- GNUNET_break (0 == dup2 (fd, 0));
- GNUNET_break (0 == close (fd));
- if ( (0 != execlp ("nc",
- "nc",
- "localhost",
- ports,
- "-w", "30",
- NULL)) &&
- (0 != execlp ("ncat",
- "ncat",
- "localhost",
- ports,
- "-i", "30",
- NULL)) )
- {
- fprintf (stderr,
- "Failed to run both `nc' and `ncat': %s\n",
- strerror (errno));
- }
- _exit (1);
- }
- /* parent process */
- if (0 != strcmp (input_filename,
- "-"))
- GNUNET_break (0 == close (fd));
- return cld;
-}
-
-
-/**
- * Run the donau to serve a single request only, without threads.
- *
- * @return #GNUNET_OK on success
- */
-static void
-run_single_request (void)
-{
- pid_t xfork;
-
- xfork = fork ();
- if (-1 == xfork)
- {
- global_ret = EXIT_FAILURE;
- GNUNET_SCHEDULER_shutdown ();
- return;
- }
- if (0 == xfork)
- {
- pid_t cld;
-
- cld = run_fake_client ();
- if (-1 == cld)
- _exit (EXIT_FAILURE);
- _exit (EXIT_SUCCESS);
- }
-
- {
- int status;
-
- if (xfork != waitpid (xfork,
- &status,
- 0))
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Waiting for `nc' child failed: %s\n",
- strerror (errno));
- }
-}
-
-
-#endif
-/* end of HAVE_DEVELOPER */
-
-
/**
* Signature of the callback used by MHD to notify the application
* about completed connections. If we are running in test-mode with
@@ -1147,13 +788,6 @@ connection_done (void *cls,
GNUNET_SCHEDULER_shutdown ();
break;
}
-#if HAVE_DEVELOPER
- /* We only act if the connection is closed. */
- if (MHD_CONNECTION_NOTIFY_CLOSED != toe)
- return;
- if (NULL != input_filename)
- GNUNET_SCHEDULER_shutdown ();
-#endif
}
@@ -1301,12 +935,6 @@ run (void *cls,
}
global_ret = EXIT_SUCCESS;
TALER_MHD_daemon_start (mhd);
- atexit (&write_stats);
-
-#if HAVE_DEVELOPER
- if (NULL != input_filename)
- run_single_request ();
-#endif
}
@@ -1337,13 +965,6 @@ main (int argc,
&connection_timeout),
GNUNET_GETOPT_option_timetravel ('T',
"timetravel"),
-#if HAVE_DEVELOPER
- GNUNET_GETOPT_option_filename ('f',
- "file-input",
- "FILENAME",
- "run in test-mode using FILENAME as the
HTTP request to process, use '-' to read from stdin",
- &input_filename),
-#endif
GNUNET_GETOPT_option_help (
"HTTP server providing a RESTful API to access a Taler donau"),
GNUNET_GETOPT_OPTION_END
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-donau] branch master updated: cleanup, gnunet, 2024/01/01
- [taler-donau] branch master updated: cleanup, gnunet, 2024/01/02
- [taler-donau] branch master updated: cleanup,
gnunet <=
- [taler-donau] branch master updated: cleanup, gnunet, 2024/01/02
- [taler-donau] branch master updated: cleanup, gnunet, 2024/01/02
- [taler-donau] branch master updated: cleanup, gnunet, 2024/01/02
- [taler-donau] branch master updated: cleanup, gnunet, 2024/01/02
- [taler-donau] branch master updated: cleanup, gnunet, 2024/01/02
- [taler-donau] branch master updated: cleanup, gnunet, 2024/01/05