[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: RECLAIM: Fix tests and fields in message
From: |
gnunet |
Subject: |
[gnunet] branch master updated: RECLAIM: Fix tests and fields in messages |
Date: |
Tue, 07 May 2024 15:56:26 +0200 |
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 62375e41d RECLAIM: Fix tests and fields in messages
62375e41d is described below
commit 62375e41d8347e6b5f58fd55ebc9196dae6d4db7
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Tue May 7 15:56:20 2024 +0200
RECLAIM: Fix tests and fields in messages
---
src/cli/reclaim/gnunet-reclaim.c | 24 +++++++++-------------
src/cli/reclaim/test_reclaim.conf | 1 +
src/cli/reclaim/test_reclaim_consume.sh | 6 ++++--
src/cli/reclaim/test_reclaim_issue.sh | 2 +-
src/plugin/reclaim/plugin_gnsrecord_reclaim.c | 4 ++--
.../reclaim/gnunet-service-reclaim_tickets.c | 21 ++++++-------------
src/service/reclaim/reclaim_api.c | 8 +++++---
7 files changed, 29 insertions(+), 37 deletions(-)
diff --git a/src/cli/reclaim/gnunet-reclaim.c b/src/cli/reclaim/gnunet-reclaim.c
index b7342d3ff..94bceb8da 100644
--- a/src/cli/reclaim/gnunet-reclaim.c
+++ b/src/cli/reclaim/gnunet-reclaim.c
@@ -234,17 +234,10 @@ ticket_issue_cb (void *cls,
const struct GNUNET_RECLAIM_Ticket *ticket,
const struct GNUNET_RECLAIM_PresentationList *presentations)
{
- char *ticket_str;
-
reclaim_op = NULL;
if (NULL != ticket)
{
- ticket_str =
- GNUNET_STRINGS_data_to_string_alloc (ticket,
- sizeof(
- struct GNUNET_RECLAIM_Ticket));
- printf ("%s\n", ticket_str);
- GNUNET_free (ticket_str);
+ printf ("%s\n", ticket->gns_name);
}
cleanup_task = GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
}
@@ -440,9 +433,15 @@ iter_finished (void *cls)
GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
return;
}
+ if (NULL == ex_rp_uri)
+ {
+ fprintf (stdout, "No RP URI provided\n");
+ GNUNET_SCHEDULER_add_now (&do_cleanup, NULL);
+ return;
+ }
reclaim_op = GNUNET_RECLAIM_ticket_issue (reclaim_handle,
pkey,
- rp,
+ ex_rp_uri,
attr_list,
&ticket_issue_cb,
NULL);
@@ -757,10 +756,7 @@ start_process ()
}
if (NULL != consume_ticket)
- GNUNET_STRINGS_string_to_data (consume_ticket,
- strlen (consume_ticket),
- &ticket,
- sizeof(struct GNUNET_RECLAIM_Ticket));
+ memcpy (ticket.gns_name, consume_ticket, strlen (consume_ticket) + 1);
if (NULL != revoke_ticket)
GNUNET_STRINGS_string_to_data (revoke_ticket,
strlen (revoke_ticket),
@@ -870,7 +866,7 @@ main (int argc, char *const argv[])
gettext_noop (
"Specify the relying party for issue"),
&rp),
- GNUNET_GETOPT_option_string ('u',
+ GNUNET_GETOPT_option_string ('U',
"rpuri",
"RPURI",
gettext_noop (
diff --git a/src/cli/reclaim/test_reclaim.conf
b/src/cli/reclaim/test_reclaim.conf
index faa195ae1..83a5c30d9 100644
--- a/src/cli/reclaim/test_reclaim.conf
+++ b/src/cli/reclaim/test_reclaim.conf
@@ -18,6 +18,7 @@ START_ON_DEMAND = YES
IMMEDIATE_START = YES
[reclaim]
+IMMEDIATE_START = YES
START_ON_DEMAND = YES
TICKET_REFRESH_INTERVAL = 1 h
#PREFIX = valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes
--log-file=$GNUNET_TMP/idplog
diff --git a/src/cli/reclaim/test_reclaim_consume.sh
b/src/cli/reclaim/test_reclaim_consume.sh
index 8a88136c6..00076fbf8 100755
--- a/src/cli/reclaim/test_reclaim_consume.sh
+++ b/src/cli/reclaim/test_reclaim_consume.sh
@@ -32,11 +32,13 @@ SUBJECT_KEY=$(gnunet-identity -d -e rpego -q -c
test_reclaim.conf)
TEST_KEY=$(gnunet-identity -d -e testego -q -c test_reclaim.conf)
gnunet-reclaim -e testego -a email -V john@doe.gnu -c test_reclaim.conf
gnunet-reclaim -e testego -a name -V John -c test_reclaim.conf
-TICKET=$(gnunet-reclaim -e testego -i "email,name" -r $SUBJECT_KEY -c
test_reclaim.conf | awk '{print $1}')
+TICKET=$(gnunet-reclaim -e testego -U "urn:gns:$TEST_KEY" -i "email,name" -r
$SUBJECT_KEY -c test_reclaim.conf | awk '{print $1}')
+echo "Ticket: $TICKET"
+gnunet-gns -u $TICKET -c test_reclaim.conf
gnunet-namestore -z testego -D -c test_reclaim.conf
gnunet-identity -d -c test_reclaim.conf
sleep 1
-gnunet-reclaim -e rpego -C $TICKET -c test_reclaim.conf
+gnunet-reclaim -e rpego -U "urn:gns:$TEST_KEY" -C $TICKET -c test_reclaim.conf
RES=$?
gnunet-identity -D testego -c test_reclaim.conf
diff --git a/src/cli/reclaim/test_reclaim_issue.sh
b/src/cli/reclaim/test_reclaim_issue.sh
index 63140e54c..39e614d19 100755
--- a/src/cli/reclaim/test_reclaim_issue.sh
+++ b/src/cli/reclaim/test_reclaim_issue.sh
@@ -32,7 +32,7 @@ TEST_KEY=$(gnunet-identity -d -e testego -q -c
test_reclaim.conf)
gnunet-reclaim -e testego -a email -V john@doe.gnu -c test_reclaim.conf
gnunet-reclaim -e testego -a name -V John -c test_reclaim.conf
#gnunet-reclaim -e testego -D -c test_reclaim.conf
-gnunet-reclaim -e testego -i "email,name" -r $SUBJECT_KEY -c test_reclaim.conf
> /dev/null 2>&1
+gnunet-reclaim -e testego -u "urn:gns:$TEST_KEY" -i "email,name" -r
$SUBJECT_KEY -c test_reclaim.conf > /dev/null 2>&1
if test $? != 0
then
echo "Failed."
diff --git a/src/plugin/reclaim/plugin_gnsrecord_reclaim.c
b/src/plugin/reclaim/plugin_gnsrecord_reclaim.c
index ce6fe483d..baf2fc37a 100644
--- a/src/plugin/reclaim/plugin_gnsrecord_reclaim.c
+++ b/src/plugin/reclaim/plugin_gnsrecord_reclaim.c
@@ -44,12 +44,12 @@ value_to_string (void *cls, uint32_t type, const void
*data, size_t data_size)
{
switch (type)
{
+ case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET:
case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT:
case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT:
return GNUNET_strndup (data, data_size);
case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE:
case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF:
- case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET:
case GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL:
case GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION:
return GNUNET_STRINGS_data_to_string_alloc (data, data_size);
@@ -79,6 +79,7 @@ string_to_value (void *cls, uint32_t type, const char *s,
void **data,
return GNUNET_SYSERR;
switch (type)
{
+ case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET:
case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_REDIRECT:
case GNUNET_GNSRECORD_TYPE_RECLAIM_OIDC_CLIENT:
*data = GNUNET_strdup (s);
@@ -86,7 +87,6 @@ string_to_value (void *cls, uint32_t type, const char *s,
void **data,
return GNUNET_OK;
case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE:
case GNUNET_GNSRECORD_TYPE_RECLAIM_ATTRIBUTE_REF:
- case GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET:
case GNUNET_GNSRECORD_TYPE_RECLAIM_CREDENTIAL:
case GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION:
return GNUNET_STRINGS_string_to_data (s, strlen (s), *data, *data_size);
diff --git a/src/service/reclaim/gnunet-service-reclaim_tickets.c
b/src/service/reclaim/gnunet-service-reclaim_tickets.c
index 23ce8ad92..bbd379fa1 100644
--- a/src/service/reclaim/gnunet-service-reclaim_tickets.c
+++ b/src/service/reclaim/gnunet-service-reclaim_tickets.c
@@ -1118,7 +1118,7 @@ lookup_authz_cb (void *cls,
*/
switch (rd[i].record_type)
{
- case GNUNET_DNSPARSER_TYPE_URI:
+ case GNUNET_DNSPARSER_TYPE_TXT:
rp_uri = rd[i].data;
break;
case GNUNET_GNSRECORD_TYPE_RECLAIM_PRESENTATION:
@@ -1153,8 +1153,8 @@ lookup_authz_cb (void *cls,
"Ignoring unknown record type %d", rd[i].record_type);
}
}
- GNUNET_assert (GNUNET_OK == GNUNET_GNS_parse_ztld (cth->ticket.gns_name,
&iss)
- );
+ GNUNET_assert (GNUNET_OK
+ == GNUNET_GNS_parse_ztld (cth->ticket.gns_name, &iss));
if (NULL == rp_uri)
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -1219,8 +1219,6 @@ RECLAIM_TICKETS_consume (const struct
GNUNET_RECLAIM_Ticket *ticket,
void *cb_cls)
{
struct RECLAIM_TICKETS_ConsumeHandle *cth;
- char *label;
- char *tmp;
cth = GNUNET_new (struct RECLAIM_TICKETS_ConsumeHandle);
@@ -1230,12 +1228,6 @@ RECLAIM_TICKETS_consume (const struct
GNUNET_RECLAIM_Ticket *ticket,
memcpy (cth->rp_uri, rp_uri, strlen (rp_uri) + 1);
cth->cb = cb;
cth->cb_cls = cb_cls;
- tmp = GNUNET_strdup (ticket->gns_name);
- label = strtok (tmp, ".");
- GNUNET_assert (NULL != label);
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Looking for AuthZ info under %s\n",
- tmp);
cth->lookup_start_time = GNUNET_TIME_absolute_get ();
cth->lookup_request =
GNUNET_GNS_lookup_with_tld (gns,
@@ -1244,7 +1236,6 @@ RECLAIM_TICKETS_consume (const struct
GNUNET_RECLAIM_Ticket *ticket,
GNUNET_GNS_LO_DEFAULT,
&lookup_authz_cb,
cth);
- GNUNET_free (tmp);
return cth;
}
@@ -1442,7 +1433,7 @@ issue_ticket (struct TicketIssueHandle *ih)
attrs_record[i].data_size = strlen (ih->rp_uri);
attrs_record[i].data = ih->rp_uri;
attrs_record[i].expiration_time = ticket_refresh_interval.rel_value_us;
- attrs_record[i].record_type = GNUNET_DNSPARSER_TYPE_URI;
+ attrs_record[i].record_type = GNUNET_DNSPARSER_TYPE_TXT;
attrs_record[i].flags =
GNUNET_GNSRECORD_RF_RELATIVE_EXPIRATION;
i++;
@@ -1547,7 +1538,7 @@ filter_tickets_cb (void *cls,
tih->ticket = *ticket;
ticket_found = GNUNET_YES;
}
- if (GNUNET_DNSPARSER_TYPE_URI == rd[i].record_type)
+ if (GNUNET_DNSPARSER_TYPE_TXT == rd[i].record_type)
{
// cmp audience
if (0 != strncmp (tih->rp_uri,
@@ -1755,7 +1746,7 @@ collect_tickets_cb (void *cls,
for (int i = 0; i < rd_count; i++)
{
- if (GNUNET_DNSPARSER_TYPE_URI == rd[i].record_type)
+ if (GNUNET_DNSPARSER_TYPE_TXT == rd[i].record_type)
rp_uri = rd[i].data;
if (GNUNET_GNSRECORD_TYPE_RECLAIM_TICKET != rd[i].record_type)
continue;
diff --git a/src/service/reclaim/reclaim_api.c
b/src/service/reclaim/reclaim_api.c
index 001e69095..f1819614c 100644
--- a/src/service/reclaim/reclaim_api.c
+++ b/src/service/reclaim/reclaim_api.c
@@ -1553,6 +1553,7 @@ GNUNET_RECLAIM_ticket_consume (
struct GNUNET_RECLAIM_Operation *op;
struct ConsumeTicketMessage *ctm;
size_t tkt_len;
+ size_t rp_uri_len;
char *buf;
op = GNUNET_new (struct GNUNET_RECLAIM_Operation);
@@ -1561,16 +1562,17 @@ GNUNET_RECLAIM_ticket_consume (
op->cls = cb_cls;
op->r_id = h->r_id_gen++;
tkt_len = strlen (ticket->gns_name) + 1;
+ rp_uri_len = strlen (rp_uri) + 1;
GNUNET_CONTAINER_DLL_insert_tail (h->op_head, h->op_tail, op);
op->env = GNUNET_MQ_msg_extra (ctm,
- tkt_len,
+ tkt_len + rp_uri_len,
GNUNET_MESSAGE_TYPE_RECLAIM_CONSUME_TICKET);
buf = (char*) &ctm[1];
- ctm->rp_uri_len = htons (strlen (rp_uri) + 1);
+ ctm->rp_uri_len = htons (rp_uri_len);
ctm->tkt_len = htons (tkt_len);
memcpy (buf, ticket, tkt_len);
buf += tkt_len;
- memcpy (buf, rp_uri, strlen (rp_uri) + 1);
+ memcpy (buf, rp_uri, rp_uri_len);
ctm->id = htonl (op->r_id);
if (NULL != h->mq)
GNUNET_MQ_send_copy (h->mq, op->env);
--
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: RECLAIM: Fix tests and fields in messages,
gnunet <=