diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2016-10-07 09:43:32 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2016-10-07 09:43:32 +0000 |
commit | b37e89b590b30cb4f650375807d60e1748930ba4 (patch) | |
tree | 7ec836c685f90d900241253780ffc21fa7bb23a0 /src/gns/gnunet-service-gns.c | |
parent | 014c0a8f67696d36bf27af70537a6a71abaa1653 (diff) | |
download | gnunet-b37e89b590b30cb4f650375807d60e1748930ba4.tar.gz gnunet-b37e89b590b30cb4f650375807d60e1748930ba4.zip |
-add reverse autoadd; with test
Diffstat (limited to 'src/gns/gnunet-service-gns.c')
-rw-r--r-- | src/gns/gnunet-service-gns.c | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index 221d75bba..3e718dac8 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -301,6 +301,7 @@ shutdown_task (void *cls) | |||
301 | identity_handle = NULL; | 301 | identity_handle = NULL; |
302 | } | 302 | } |
303 | GNS_resolver_done (); | 303 | GNS_resolver_done (); |
304 | GNS_reverse_done (); | ||
304 | GNS_shorten_done (); | 305 | GNS_shorten_done (); |
305 | while (NULL != (ma = ma_head)) | 306 | while (NULL != (ma = ma_head)) |
306 | { | 307 | { |
@@ -1061,6 +1062,51 @@ handle_monitor_error (void *cls) | |||
1061 | NULL); | 1062 | NULL); |
1062 | } | 1063 | } |
1063 | 1064 | ||
1065 | /** | ||
1066 | * Method called to inform about the ego to be used for the master zone | ||
1067 | * for DNS interceptions. | ||
1068 | * | ||
1069 | * This function is only called ONCE, and 'NULL' being passed in | ||
1070 | * @a ego does indicate that interception is not configured. | ||
1071 | * If @a ego is non-NULL, we should start to intercept DNS queries | ||
1072 | * and resolve ".gnu" queries using the given ego as the master zone. | ||
1073 | * | ||
1074 | * @param cls closure, our `const struct GNUNET_CONFIGURATION_Handle *c` | ||
1075 | * @param ego ego handle | ||
1076 | * @param ctx context for application to store data for this ego | ||
1077 | * (during the lifetime of this process, initially NULL) | ||
1078 | * @param name name assigned by the user for this ego, | ||
1079 | * NULL if the user just deleted the ego and it | ||
1080 | * must thus no longer be used | ||
1081 | */ | ||
1082 | static void | ||
1083 | identity_reverse_cb (void *cls, | ||
1084 | struct GNUNET_IDENTITY_Ego *ego, | ||
1085 | void **ctx, | ||
1086 | const char *name) | ||
1087 | { | ||
1088 | identity_op = NULL; | ||
1089 | |||
1090 | if (NULL == ego) | ||
1091 | { | ||
1092 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
1093 | _("No ego configured for `%s`\n"), | ||
1094 | "gns-master"); | ||
1095 | |||
1096 | return; | ||
1097 | } | ||
1098 | if (GNUNET_SYSERR == | ||
1099 | GNS_reverse_init (namestore_handle, | ||
1100 | GNUNET_IDENTITY_ego_get_private_key (ego), | ||
1101 | name)) | ||
1102 | { | ||
1103 | GNUNET_break (0); | ||
1104 | GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
1105 | return; | ||
1106 | } | ||
1107 | } | ||
1108 | |||
1109 | |||
1064 | 1110 | ||
1065 | /** | 1111 | /** |
1066 | * Method called to inform about the ego to be used for the master zone | 1112 | * Method called to inform about the ego to be used for the master zone |
@@ -1087,13 +1133,22 @@ identity_intercept_cb (void *cls, | |||
1087 | { | 1133 | { |
1088 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 1134 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; |
1089 | struct GNUNET_CRYPTO_EcdsaPublicKey dns_root; | 1135 | struct GNUNET_CRYPTO_EcdsaPublicKey dns_root; |
1090 | |||
1091 | identity_op = NULL; | 1136 | identity_op = NULL; |
1137 | |||
1138 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1139 | "Looking for gns-intercept ego\n"); | ||
1140 | identity_op = GNUNET_IDENTITY_get (identity_handle, | ||
1141 | "gns-reverse", | ||
1142 | &identity_reverse_cb, | ||
1143 | (void*)cfg); | ||
1144 | |||
1145 | |||
1092 | if (NULL == ego) | 1146 | if (NULL == ego) |
1093 | { | 1147 | { |
1094 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 1148 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
1095 | _("No ego configured for `%s`\n"), | 1149 | _("No ego configured for `%s`\n"), |
1096 | "gns-intercept"); | 1150 | "gns-intercept"); |
1151 | |||
1097 | return; | 1152 | return; |
1098 | } | 1153 | } |
1099 | GNUNET_IDENTITY_ego_get_public_key (ego, | 1154 | GNUNET_IDENTITY_ego_get_public_key (ego, |