/**
* Public key submitted via form.
*/
- char public_key[1024];
+ char public_key[64];
};
/**
- * Process a record that was stored in the namestore.
+ * Test if a name mapping was found, if so, refuse. If not, initiate storing of the record.
*
* @param cls closure
* @param zone_key public key of the zone
* because the user queried for a particular record type only)
*/
static void
-lookup_result_processor (void *cls,
- const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
- struct GNUNET_TIME_Absolute expire,
- const char *name,
- unsigned int rd_count,
- const struct GNUNET_NAMESTORE_RecordData *rd,
- const struct GNUNET_CRYPTO_RsaSignature *signature)
+zone_to_name_cb (void *cls,
+ const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
+ struct GNUNET_TIME_Absolute expire,
+ const char *name,
+ unsigned int rd_count,
+ const struct GNUNET_NAMESTORE_RecordData *rd,
+ const struct GNUNET_CRYPTO_RsaSignature *signature)
{
struct Request *request = cls;
struct GNUNET_NAMESTORE_RecordData r;
- GNUNET_HashCode pub;
+ struct GNUNET_CRYPTO_ShortHashCode pub;
- GNUNET_assert (GNUNET_OK ==
- GNUNET_CRYPTO_hash_from_string2 (request->public_key,
- strlen (request->public_key),
- &pub));
request->qe = NULL;
- if (0 != rd_count)
+ if (NULL != name)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Found %u existing records for domain `%s'\n"),
- rd_count,
- request->domain_name);
+ _("Found existing name `%s' for the given key\n"),
+ name);
request->phase = RP_FAIL;
run_httpd_now ();
return;
}
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CRYPTO_short_hash_from_string2 (request->public_key,
+ strlen (request->public_key),
+ &pub));
r.data = &pub;
r.data_size = sizeof (pub);
r.expiration = GNUNET_TIME_UNIT_FOREVER_ABS;
}
+/**
+ * Process a record that was stored in the namestore. Used to check if
+ * the requested name already exists in the namestore. If not,
+ * proceed to check if the requested key already exists.
+ *
+ * @param cls closure
+ * @param zone_key public key of the zone
+ * @param expire when does the corresponding block in the DHT expire (until
+ * when should we never do a DHT lookup for the same name again)?;
+ * GNUNET_TIME_UNIT_ZERO_ABS if there are no records of any type in the namestore,
+ * or the expiration time of the block in the namestore (even if there are zero
+ * records matching the desired record type)
+ * @param name name that is being mapped (at most 255 characters long)
+ * @param rd_count number of entries in 'rd' array
+ * @param rd array of records with data to store
+ * @param signature signature of the record block, NULL if signature is unavailable (i.e.
+ * because the user queried for a particular record type only)
+ */
+static void
+lookup_result_processor (void *cls,
+ const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
+ struct GNUNET_TIME_Absolute expire,
+ const char *name,
+ unsigned int rd_count,
+ const struct GNUNET_NAMESTORE_RecordData *rd,
+ const struct GNUNET_CRYPTO_RsaSignature *signature)
+{
+ struct Request *request = cls;
+ struct GNUNET_CRYPTO_ShortHashCode pub;
+
+ request->qe = NULL;
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_CRYPTO_short_hash_from_string2 (request->public_key,
+ strlen (request->public_key),
+ &pub));
+ if (0 != rd_count)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("Found %u existing records for domain `%s'\n"),
+ rd_count,
+ request->domain_name);
+ request->phase = RP_FAIL;
+ run_httpd_now ();
+ return;
+ }
+ request->qe = GNUNET_NAMESTORE_zone_to_name (ns,
+ &fcfsd_zone,
+ &pub,
+ &zone_to_name_cb,
+ request);
+}
+
+
/**
* Main MHD callback for handling requests.
*
struct MHD_Response *response;
struct Request *request;
int ret;
- GNUNET_HashCode pub;
+ struct GNUNET_CRYPTO_ShortHashCode pub;
if ( (0 == strcmp (method, MHD_HTTP_METHOD_GET)) ||
(0 == strcmp (method, MHD_HTTP_METHOD_HEAD)) )
request->pp = NULL;
}
if (GNUNET_OK !=
- GNUNET_CRYPTO_hash_from_string2 (request->public_key,
- strlen (request->public_key),
- &pub))
+ GNUNET_CRYPTO_short_hash_from_string2 (request->public_key,
+ strlen (request->public_key),
+ &pub))
{
/* parse error */
return fill_s_reply ("Failed to parse given public key",