diff options
author | Bart Polot <bart@net.in.tum.de> | 2013-02-13 10:37:34 +0000 |
---|---|---|
committer | Bart Polot <bart@net.in.tum.de> | 2013-02-13 10:37:34 +0000 |
commit | a9ac8b77fe468ece9d78de46475bb7c3add5b42f (patch) | |
tree | a52c99023eba78a5b562b17e32a91cb9bd98d1b2 /src/regex | |
parent | a874deb287c61ad82338e4e504a47bb255798e6d (diff) | |
download | gnunet-a9ac8b77fe468ece9d78de46475bb7c3add5b42f.tar.gz gnunet-a9ac8b77fe468ece9d78de46475bb7c3add5b42f.zip |
- remove regex daemon dependency to peers' public keys: allow to use HEAD regex with 0.9.5a core and others, allowing also committing regex changes to svn HEAD
Diffstat (limited to 'src/regex')
-rw-r--r-- | src/regex/gnunet-daemon-regexprofiler.c | 76 |
1 files changed, 6 insertions, 70 deletions
diff --git a/src/regex/gnunet-daemon-regexprofiler.c b/src/regex/gnunet-daemon-regexprofiler.c index acda7ccc4..3ca57b4f3 100644 --- a/src/regex/gnunet-daemon-regexprofiler.c +++ b/src/regex/gnunet-daemon-regexprofiler.c | |||
@@ -59,11 +59,6 @@ static struct GNUNET_DHT_Handle *dht_handle; | |||
59 | static struct GNUNET_REGEX_announce_handle *announce_handle; | 59 | static struct GNUNET_REGEX_announce_handle *announce_handle; |
60 | 60 | ||
61 | /** | 61 | /** |
62 | * Hostkey generation context | ||
63 | */ | ||
64 | static struct GNUNET_CRYPTO_EccKeyGenerationContext *keygen; | ||
65 | |||
66 | /** | ||
67 | * Periodically reannounce regex. | 62 | * Periodically reannounce regex. |
68 | */ | 63 | */ |
69 | static GNUNET_SCHEDULER_TaskIdentifier reannounce_task; | 64 | static GNUNET_SCHEDULER_TaskIdentifier reannounce_task; |
@@ -79,11 +74,6 @@ static struct GNUNET_TIME_Relative reannounce_freq; | |||
79 | static struct GNUNET_TIME_Relative announce_delay; | 74 | static struct GNUNET_TIME_Relative announce_delay; |
80 | 75 | ||
81 | /** | 76 | /** |
82 | * Local peer's PeerID. | ||
83 | */ | ||
84 | static struct GNUNET_PeerIdentity my_full_id; | ||
85 | |||
86 | /** | ||
87 | * Maximal path compression length for regex announcing. | 77 | * Maximal path compression length for regex announcing. |
88 | */ | 78 | */ |
89 | static unsigned long long max_path_compression; | 79 | static unsigned long long max_path_compression; |
@@ -116,11 +106,6 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
116 | { | 106 | { |
117 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "shutting down\n"); | 107 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "shutting down\n"); |
118 | 108 | ||
119 | if (NULL != keygen) | ||
120 | { | ||
121 | GNUNET_CRYPTO_ecc_key_create_stop (keygen); | ||
122 | keygen = NULL; | ||
123 | } | ||
124 | if (NULL != announce_handle) | 109 | if (NULL != announce_handle) |
125 | { | 110 | { |
126 | GNUNET_REGEX_announce_cancel (announce_handle); | 111 | GNUNET_REGEX_announce_cancel (announce_handle); |
@@ -146,7 +131,9 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
146 | static void | 131 | static void |
147 | reannounce_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 132 | reannounce_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
148 | { | 133 | { |
134 | struct GNUNET_PeerIdentity id; | ||
149 | char *regex = cls; | 135 | char *regex = cls; |
136 | |||
150 | reannounce_task = GNUNET_SCHEDULER_NO_TASK; | 137 | reannounce_task = GNUNET_SCHEDULER_NO_TASK; |
151 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | 138 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) |
152 | { | 139 | { |
@@ -161,8 +148,9 @@ reannounce_regex (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
161 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 148 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
162 | "First time, creating regex: %s\n", | 149 | "First time, creating regex: %s\n", |
163 | regex); | 150 | regex); |
151 | memset (&id, 0, sizeof (struct GNUNET_PeerIdentity)); | ||
164 | announce_handle = GNUNET_REGEX_announce (dht_handle, | 152 | announce_handle = GNUNET_REGEX_announce (dht_handle, |
165 | &my_full_id, | 153 | &id, |
166 | regex, | 154 | regex, |
167 | (unsigned int) max_path_compression, | 155 | (unsigned int) max_path_compression, |
168 | stats_handle); | 156 | stats_handle); |
@@ -273,42 +261,6 @@ load_regexes (const char *filename, char **rx) | |||
273 | 261 | ||
274 | 262 | ||
275 | /** | 263 | /** |
276 | * Callback for hostkey read/generation | ||
277 | * | ||
278 | * @param cls Closure (not used). | ||
279 | * @param pk The private key of the local peer. | ||
280 | * @param emsg Error message if applicable. | ||
281 | */ | ||
282 | static void | ||
283 | key_generation_cb (void *cls, | ||
284 | struct GNUNET_CRYPTO_EccPrivateKey *pk, | ||
285 | const char *emsg) | ||
286 | { | ||
287 | struct GNUNET_CRYPTO_EccPublicKeyBinaryEncoded my_public_key; | ||
288 | |||
289 | keygen = NULL; | ||
290 | if (NULL == pk) | ||
291 | { | ||
292 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
293 | _("Regexprofiler could not access hostkey: %s. Exiting.\n"), | ||
294 | emsg); | ||
295 | GNUNET_SCHEDULER_shutdown (); | ||
296 | return; | ||
297 | } | ||
298 | |||
299 | GNUNET_CRYPTO_ecc_key_get_public (pk, &my_public_key); | ||
300 | GNUNET_CRYPTO_hash (&my_public_key, sizeof (my_public_key), | ||
301 | &my_full_id.hashPubKey); | ||
302 | |||
303 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
304 | "Regexprofiler for peer [%s] starting\n", | ||
305 | GNUNET_i2s(&my_full_id)); | ||
306 | announce_regex (rx_with_pfx); | ||
307 | GNUNET_free (rx_with_pfx); | ||
308 | } | ||
309 | |||
310 | |||
311 | /** | ||
312 | * @brief Main function that will be run by the scheduler. | 264 | * @brief Main function that will be run by the scheduler. |
313 | * | 265 | * |
314 | * @param cls closure | 266 | * @param cls closure |
@@ -322,23 +274,10 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
322 | const struct GNUNET_CONFIGURATION_Handle *cfg_) | 274 | const struct GNUNET_CONFIGURATION_Handle *cfg_) |
323 | { | 275 | { |
324 | char *regex = NULL; | 276 | char *regex = NULL; |
325 | char *keyfile; | ||
326 | 277 | ||
327 | cfg = cfg_; | 278 | cfg = cfg_; |
328 | 279 | ||
329 | if (GNUNET_OK != | 280 | if (GNUNET_OK != |
330 | GNUNET_CONFIGURATION_get_value_filename (cfg, "PEER", "PRIVATE_KEY", | ||
331 | &keyfile)) | ||
332 | { | ||
333 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
334 | _ | ||
335 | ("%s service is lacking key configuration settings (%s). Exiting.\n"), | ||
336 | "regexdaemon", "peer/privatekey"); | ||
337 | GNUNET_SCHEDULER_shutdown (); | ||
338 | return; | ||
339 | } | ||
340 | |||
341 | if (GNUNET_OK != | ||
342 | GNUNET_CONFIGURATION_get_value_number (cfg, "REGEXPROFILER", "MAX_PATH_COMPRESSION", | 281 | GNUNET_CONFIGURATION_get_value_number (cfg, "REGEXPROFILER", "MAX_PATH_COMPRESSION", |
343 | &max_path_compression)) | 282 | &max_path_compression)) |
344 | { | 283 | { |
@@ -417,12 +356,9 @@ run (void *cls, char *const *args GNUNET_UNUSED, | |||
417 | 356 | ||
418 | /* Announcing regexes from policy_filename */ | 357 | /* Announcing regexes from policy_filename */ |
419 | GNUNET_asprintf (&rx_with_pfx, "%s(%s)", regex_prefix, regex); | 358 | GNUNET_asprintf (&rx_with_pfx, "%s(%s)", regex_prefix, regex); |
359 | announce_regex (rx_with_pfx); | ||
420 | GNUNET_free (regex); | 360 | GNUNET_free (regex); |
421 | 361 | GNUNET_free (rx_with_pfx); | |
422 | keygen = GNUNET_CRYPTO_ecc_key_create_start (keyfile, | ||
423 | &key_generation_cb, | ||
424 | NULL); | ||
425 | GNUNET_free (keyfile); | ||
426 | 362 | ||
427 | /* Scheduled the task to clean up when shutdown is called */ | 363 | /* Scheduled the task to clean up when shutdown is called */ |
428 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, | 364 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, |