[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: -fix ztld parsing in recordline; add tes
From: |
gnunet |
Subject: |
[gnunet] branch master updated: -fix ztld parsing in recordline; add test for that |
Date: |
Mon, 21 Nov 2022 07:43:49 +0100 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new bdab06894 -fix ztld parsing in recordline; add test for that
bdab06894 is described below
commit bdab06894ca42106651e7328657cf87c779b6acf
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Mon Nov 21 15:43:43 2022 +0900
-fix ztld parsing in recordline; add test for that
---
src/namestore/gnunet-namestore.c | 56 +++++++++++++++++++++++++------
src/namestore/test_namestore_put_stdin.sh | 8 ++++-
2 files changed, 53 insertions(+), 11 deletions(-)
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c
index ee59e7432..207394dd9 100644
--- a/src/namestore/gnunet-namestore.c
+++ b/src/namestore/gnunet-namestore.c
@@ -1371,12 +1371,12 @@ run_with_zone_pkey (const struct
GNUNET_CONFIGURATION_Handle *cfg)
struct GNUNET_GNSRECORD_Data *rd;
/* FIXME: We could easily support append and delete with this as well */
- if (!add)
+ if (! add)
{
- fprintf (stderr, _("Recordlines only work with option `%s'\n"),
+ fprintf (stderr, _ ("Recordlines only work with option `%s'\n"),
"-a");
ret = 1;
- finish_command();
+ finish_command ();
return;
}
if (NULL == name)
@@ -1741,10 +1741,47 @@ run_with_zone_pkey (const struct
GNUNET_CONFIGURATION_Handle *cfg)
#define MAX_ARGS 20
+static int
+get_identity_for_string (const char *str,
+ struct GNUNET_IDENTITY_PrivateKey *zk)
+{
+ const struct GNUNET_IDENTITY_PrivateKey *privkey;
+ struct GNUNET_IDENTITY_PublicKey pubkey;
+ struct GNUNET_IDENTITY_PublicKey ego_pubkey;
+ struct EgoEntry *ego_entry;
+
+ if (GNUNET_OK == GNUNET_IDENTITY_public_key_from_string (str,
+ &pubkey))
+ {
+ for (ego_entry = ego_head;
+ NULL != ego_entry; ego_entry = ego_entry->next)
+ {
+ privkey = GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
+ GNUNET_IDENTITY_ego_get_public_key (ego_entry->ego, &ego_pubkey);
+ if (0 == memcmp (&ego_pubkey, &pubkey, sizeof (pubkey)))
+ {
+ *zk = *privkey;
+ return GNUNET_OK;
+ }
+ }
+ }
+ else
+ {
+ for (ego_entry = ego_head; NULL != ego_entry; ego_entry = ego_entry->next)
+ {
+ /** FIXME: Check for zTLD? **/
+ if (0 != strcmp (str, ego_entry->identifier))
+ continue;
+ *zk = *GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
+ return GNUNET_OK;
+ }
+ }
+ return GNUNET_NO;
+}
+
static void
process_command_stdin ()
{
- struct EgoEntry *ego_entry;
char buf[MAX_LINE_LEN];
static struct GNUNET_IDENTITY_PrivateKey next_zone_key;
static char next_name[GNUNET_DNSPARSER_MAX_NAME_LENGTH];
@@ -1783,13 +1820,12 @@ process_command_stdin ()
ret = 1;
return;
}
- for (ego_entry = ego_head; NULL != ego_entry; ego_entry =
ego_entry->next)
+ if (GNUNET_OK != get_identity_for_string (tmp + 1, &next_zone_key))
{
- /** FIXME: Check for zTLD? **/
- if (0 != strcmp (tmp + 1, ego_entry->identifier))
- continue;
- next_zone_key = *GNUNET_IDENTITY_ego_get_private_key (ego_entry->ego);
- break;
+ fprintf (stderr, "Error parsing zone name `%s'\n", tmp + 1);
+ ret = 1;
+ GNUNET_SCHEDULER_shutdown ();
+ return;
}
*tmp = '\0';
printf ("Switching to new name `%s' in zone `%s'\n", next_name, tmp + 1);
diff --git a/src/namestore/test_namestore_put_stdin.sh
b/src/namestore/test_namestore_put_stdin.sh
index 8fdcaa23f..deb7bc4cb 100755
--- a/src/namestore/test_namestore_put_stdin.sh
+++ b/src/namestore/test_namestore_put_stdin.sh
@@ -26,17 +26,20 @@ function start_peer
{
gnunet-arm -s -c $CONFIGURATION
gnunet-identity -C testego -c $CONFIGURATION
+ gnunet-identity -C testego2 -c $CONFIGURATION
}
function stop_peer
{
gnunet-identity -D testego -c $CONFIGURATION
+ gnunet-identity -D testego2 -c $CONFIGURATION
gnunet-arm -e -c $CONFIGURATION
}
start_peer
# Create a public record
+EGOKEY=`gnunet-identity -d | grep testego2 | cut -d' ' -f3`
gnunet-namestore -a -c $CONFIGURATION -S <<EOF
$TEST_RECORD_NAME.testego:
A 3600000000 [pr] $TEST_IP
@@ -48,9 +51,12 @@ $TEST_RECORD_NAME2.testego:
AAAA 324241223 [prS] ::dead:beef
A 111324241223000000 [pC] 1.1.1.1
+www7.$EGOKEY:
+ A 3600000000 [pr] $TEST_IP
+
EOF
NAMESTORE_RES=$?
-gnunet-namestore -z testego -D -r -c $CONFIGURATION
+gnunet-namestore -D -r -c $CONFIGURATION
stop_peer
if [ $NAMESTORE_RES = 0 ]
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: -fix ztld parsing in recordline; add test for that,
gnunet <=