aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/namestore/gnunet-namestore.c116
1 files changed, 75 insertions, 41 deletions
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index e161a741d..b678086df 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -972,45 +972,16 @@ replace_cont (void *cls, int success, const char *emsg)
972 972
973 973
974/** 974/**
975 * Callback invoked from identity service with ego information. 975 * We have obtained the zone's private key, so now process
976 * An @a ego of NULL means the ego was not found. 976 * the main commands using it.
977 * 977 *
978 * @param cls closure with the configuration 978 * @param cfg configuration to use
979 * @param ego an ego known to identity service, or NULL
980 */ 979 */
981static void 980static void
982identity_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego) 981run_with_zone_pkey (const struct GNUNET_CONFIGURATION_Handle *cfg)
983{ 982{
984 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
985 struct GNUNET_GNSRECORD_Data rd; 983 struct GNUNET_GNSRECORD_Data rd;
986 984
987 el = NULL;
988 if ((NULL != name) && (0 != strchr (name, '.')))
989 {
990 fprintf (stderr,
991 _ ("Label `%s' contains `.' which is not allowed\n"),
992 name);
993 GNUNET_SCHEDULER_shutdown ();
994 ret = -1;
995 return;
996 }
997
998 if (NULL == ego)
999 {
1000 if (NULL != ego_name)
1001 {
1002 fprintf (stderr,
1003 _ ("Ego `%s' not known to identity service\n"),
1004 ego_name);
1005 }
1006 GNUNET_SCHEDULER_shutdown ();
1007 ret = -1;
1008 return;
1009 }
1010 zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego);
1011 GNUNET_free_non_null (ego_name);
1012 ego_name = NULL;
1013
1014 if (! (add | del | list | (NULL != nickstring) | (NULL != uri) | 985 if (! (add | del | list | (NULL != nickstring) | (NULL != uri) |
1015 (NULL != reverse_pkey) | (NULL != recordset))) 986 (NULL != reverse_pkey) | (NULL != recordset)))
1016 { 987 {
@@ -1265,13 +1236,66 @@ identity_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
1265} 1236}
1266 1237
1267 1238
1239/**
1240 * Callback invoked from identity service with ego information.
1241 * An @a ego of NULL means the ego was not found.
1242 *
1243 * @param cls closure with the configuration
1244 * @param ego an ego known to identity service, or NULL
1245 */
1246static void
1247identity_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
1248{
1249 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1250
1251 el = NULL;
1252 if ((NULL != name) && (0 != strchr (name, '.')))
1253 {
1254 fprintf (stderr,
1255 _ ("Label `%s' contains `.' which is not allowed\n"),
1256 name);
1257 GNUNET_SCHEDULER_shutdown ();
1258 ret = -1;
1259 return;
1260 }
1261
1262 if (NULL == ego)
1263 {
1264 if (NULL != ego_name)
1265 {
1266 fprintf (stderr,
1267 _ ("Ego `%s' not known to identity service\n"),
1268 ego_name);
1269 }
1270 GNUNET_SCHEDULER_shutdown ();
1271 ret = -1;
1272 return;
1273 }
1274 zone_pkey = *GNUNET_IDENTITY_ego_get_private_key (ego);
1275 GNUNET_free_non_null (ego_name);
1276 ego_name = NULL;
1277 run_with_zone_pkey (cfg);
1278}
1279
1280
1281/**
1282 * Function called with the default ego to be used for GNS
1283 * operations. Used if the user did not specify a zone via
1284 * command-line or environment variables.
1285 *
1286 * @param cls NULL
1287 * @param ego default ego, NULL for none
1288 * @param ctx NULL
1289 * @param name unused
1290 */
1268static void 1291static void
1269default_ego_cb (void *cls, 1292default_ego_cb (void *cls,
1270 struct GNUNET_IDENTITY_Ego *ego, 1293 struct GNUNET_IDENTITY_Ego *ego,
1271 void **ctx, 1294 void **ctx,
1272 const char *name) 1295 const char *name)
1273{ 1296{
1274 (void) cls; 1297 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1298
1275 (void) ctx; 1299 (void) ctx;
1276 (void) name; 1300 (void) name;
1277 get_default = NULL; 1301 get_default = NULL;
@@ -1284,11 +1308,23 @@ default_ego_cb (void *cls,
1284 } 1308 }
1285 else 1309 else
1286 { 1310 {
1287 identity_cb (cls, ego); 1311 identity_cb ((void *) cfg, ego);
1288 } 1312 }
1289} 1313}
1290 1314
1291 1315
1316/**
1317 * Function called with ALL of the egos known to the
1318 * identity service, used on startup if the user did
1319 * not specify a zone on the command-line.
1320 * Once the iteration is done (@a ego is NULL), we
1321 * ask for the default ego for "namestore".
1322 *
1323 * @param cls a `struct GNUNET_CONFIGURATION_Handle`
1324 * @param ego an ego, NULL for end of iteration
1325 * @param ctx NULL
1326 * @param name name associated with @a ego
1327 */
1292static void 1328static void
1293id_connect_cb (void *cls, 1329id_connect_cb (void *cls,
1294 struct GNUNET_IDENTITY_Ego *ego, 1330 struct GNUNET_IDENTITY_Ego *ego,
@@ -1297,14 +1333,12 @@ id_connect_cb (void *cls,
1297{ 1333{
1298 const struct GNUNET_CONFIGURATION_Handle *cfg = cls; 1334 const struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1299 1335
1300 (void) cls;
1301 (void) ctx; 1336 (void) ctx;
1302 (void) name; 1337 (void) name;
1303 if (NULL == ego) 1338 if (NULL != ego)
1304 { 1339 return;
1305 get_default = 1340 get_default =
1306 GNUNET_IDENTITY_get (idh, "namestore", &default_ego_cb, (void *) cfg); 1341 GNUNET_IDENTITY_get (idh, "namestore", &default_ego_cb, (void *) cfg);
1307 }
1308} 1342}
1309 1343
1310 1344