[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r36346 - in gnunet/src: include psyc social
From: |
gnunet |
Subject: |
[GNUnet-SVN] r36346 - in gnunet/src: include psyc social |
Date: |
Tue, 8 Sep 2015 03:36:33 +0200 |
Author: tg
Date: 2015-09-08 03:36:33 +0200 (Tue, 08 Sep 2015)
New Revision: 36346
Modified:
gnunet/src/include/gnunet_social_service.h
gnunet/src/psyc/gnunet-service-psyc.c
gnunet/src/social/gnunet-service-social.c
gnunet/src/social/social_api.c
gnunet/src/social/test_social.c
Log:
social: advertise; farewell fix
Modified: gnunet/src/include/gnunet_social_service.h
===================================================================
--- gnunet/src/include/gnunet_social_service.h 2015-09-07 16:46:07 UTC (rev
36345)
+++ gnunet/src/include/gnunet_social_service.h 2015-09-08 01:36:33 UTC (rev
36346)
@@ -38,6 +38,7 @@
#include "gnunet_util_lib.h"
#include "gnunet_env_lib.h"
#include "gnunet_identity_service.h"
+#include "gnunet_namestore_service.h"
#include "gnunet_psyc_service.h"
@@ -459,7 +460,7 @@
* @param nym
* Pseudonym to map to a cryptographic identifier.
*
- * @return Public key of nym;
+ * @return Public key of nym.
*/
const struct GNUNET_CRYPTO_EcdsaPublicKey *
GNUNET_SOCIAL_nym_get_key (const struct GNUNET_SOCIAL_Nym *nym);
@@ -466,15 +467,37 @@
/**
+ * Get the hash of the public key of a @a nym.
+ *
+ * @param nym
+ * Pseudonym to map to a cryptographic identifier.
+ *
+ * @return Hash of the public key of nym.
+ */
+const struct GNUNET_HashCode *
+GNUNET_SOCIAL_nym_get_key_hash (const struct GNUNET_SOCIAL_Nym *nym);
+
+
+/**
* Advertise the place in the GNS zone of the @e ego of the @a host.
*
- * @param host Host of the place.
- * @param name The name for the PLACE record to put in the zone.
- * @param peer_count Number of elements in the @a peers array.
- * @param peers List of peers in the PLACE record that can be used to send join
- * requests to.
- * @param expiration_time Expiration time of the record, use 0 to remove the
record.
- * @param password Password used to encrypt the record.
+ * @param hst
+ * Host of the place.
+ * @param name
+ * The name for the PLACE record to put in the zone.
+ * @param peer_count
+ * Number of elements in the @a peers array.
+ * @param peers
+ * List of peers to put in the PLACE record to advertise
+ * as entry points to the place in addition to the origin.
+ * @param expiration_time
+ * Expiration time of the record, use 0 to remove the record.
+ * @param password
+ * Password used to encrypt the record.
+ * @param result_cb
+ * Function called with the result of the operation.
+ * @param result_cls
+ * Closure for @a result_cb
*/
void
GNUNET_SOCIAL_host_advertise (struct GNUNET_SOCIAL_Host *host,
@@ -482,7 +505,9 @@
size_t peer_count,
const struct GNUNET_PeerIdentity *peers,
struct GNUNET_TIME_Relative expiration_time,
- const char *password);
+ const char *password,
+ GNUNET_NAMESTORE_ContinuationWithStatus
result_cb,
+ void *result_cls);
/**
Modified: gnunet/src/psyc/gnunet-service-psyc.c
===================================================================
--- gnunet/src/psyc/gnunet-service-psyc.c 2015-09-07 16:46:07 UTC (rev
36345)
+++ gnunet/src/psyc/gnunet-service-psyc.c 2015-09-08 01:36:33 UTC (rev
36346)
@@ -1,4 +1,3 @@
-
/*
* This file is part of GNUnet
* Copyright (C) 2013 Christian Grothoff (and other contributing authors)
@@ -534,7 +533,7 @@
static void
cleanup_channel (struct Channel *chn)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%p Cleaning up channel %s. master? %u\n",
chn, GNUNET_h2s (&chn->pub_key_hash), chn->is_master);
message_queue_drop (chn);
@@ -569,7 +568,6 @@
struct Channel *
chn = GNUNET_SERVER_client_get_user_context (client, struct Channel);
- chn->is_disconnected = GNUNET_YES;
if (NULL == chn)
{
@@ -584,6 +582,8 @@
chn, (GNUNET_YES == chn->is_master) ? "master" : "slave",
GNUNET_h2s (&chn->pub_key_hash));
+ chn->is_disconnected = GNUNET_YES;
+
struct Client *cli = chn->clients_head;
while (NULL != cli)
{
@@ -1548,9 +1548,11 @@
struct Master *mst = cls;
uint16_t size = ntohs (req->header.size);
+ char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&req->member_key);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "%p Received multicast request of size %u.\n",
- mst, size);
+ "%p Received multicast request of size %u from %s.\n",
+ mst, size, str);
+ GNUNET_free (str);
uint16_t first_ptype = 0, last_ptype = 0;
if (GNUNET_SYSERR
Modified: gnunet/src/social/gnunet-service-social.c
===================================================================
--- gnunet/src/social/gnunet-service-social.c 2015-09-07 16:46:07 UTC (rev
36345)
+++ gnunet/src/social/gnunet-service-social.c 2015-09-08 01:36:33 UTC (rev
36346)
@@ -599,6 +599,13 @@
const struct GNUNET_PSYC_MessageHeader *msg)
{
struct Place *plc = cls;
+
+ char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&msg->slave_key);
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "%p Received PSYC message of size %u from %s.\n",
+ plc, ntohs (msg->header.size), str);
+ GNUNET_free (str);
+
client_send_msg (plc, &msg->header);
/* FIXME: further processing */
Modified: gnunet/src/social/social_api.c
===================================================================
--- gnunet/src/social/social_api.c 2015-09-07 16:46:07 UTC (rev 36345)
+++ gnunet/src/social/social_api.c 2015-09-08 01:36:33 UTC (rev 36346)
@@ -455,7 +455,8 @@
const char *method_name)
{
struct GNUNET_SOCIAL_Host *hst = cls;
- if (NULL == nym)
+ if (0 == memcmp (&(struct GNUNET_CRYPTO_EcdsaPublicKey) {},
+ &nym->pub_key, sizeof (nym->pub_key)))
return;
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
@@ -464,6 +465,12 @@
hst->notice_place_leave_nym = (struct GNUNET_SOCIAL_Nym *) nym;
hst->notice_place_leave_env = GNUNET_ENV_environment_create ();
+
+ char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string
(&hst->notice_place_leave_nym->pub_key);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "_notice_place_leave: got method from nym %s (%s).\n",
+ GNUNET_h2s (&hst->notice_place_leave_nym->pub_key_hash), str);
+ GNUNET_break (0);
}
@@ -506,6 +513,11 @@
if (NULL == hst->notice_place_leave_env)
return;
+ char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string
(&hst->notice_place_leave_nym->pub_key);
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+ "_notice_place_leave: got EOM from nym %s (%s).\n",
+ GNUNET_h2s (&hst->notice_place_leave_nym->pub_key_hash), str);
+
if (GNUNET_YES != cancelled)
{
if (NULL != hst->farewell_cb)
@@ -658,10 +670,12 @@
GNUNET_assert (message_id == slicer->message_id);
}
+ char *nym_str = GNUNET_CRYPTO_ecdsa_public_key_to_string (slave_key);
LOG (GNUNET_ERROR_TYPE_DEBUG,
"Slicer received message of type %u and size %u, "
- "with ID %" PRIu64 " and method %s\n",
- ptype, ntohs (msg->size), message_id, slicer->method_name);
+ "with ID %" PRIu64 " and method %s from %s\n",
+ ptype, ntohs (msg->size), message_id, slicer->method_name, nym_str);
+ GNUNET_free (nym_str);
slicer->msg = msg;
@@ -1661,8 +1675,8 @@
*
* @param nym
* Pseudonym to map to a cryptographic identifier.
- * @param[out] nym_key
- * Set to the public key of the nym.
+ *
+ * @return Public key of nym.
*/
const struct GNUNET_CRYPTO_EcdsaPublicKey *
GNUNET_SOCIAL_nym_get_key (const struct GNUNET_SOCIAL_Nym *nym)
@@ -1672,6 +1686,21 @@
/**
+ * Get the hash of the public key of a @a nym.
+ *
+ * @param nym
+ * Pseudonym to map to a cryptographic identifier.
+ *
+ * @return Hash of the public key of nym.
+ */
+const struct GNUNET_HashCode *
+GNUNET_SOCIAL_nym_get_key_hash (const struct GNUNET_SOCIAL_Nym *nym)
+{
+ return &nym->pub_key_hash;
+}
+
+
+/**
* Obtain the private-public key pair of the hosted place.
*
* The public part is suitable for storing in GNS within a PLACE record,
@@ -1689,13 +1718,6 @@
}
-static void
-namestore_result_host_advertise (void *cls, int32_t success, const char *emsg)
-{
-
-}
-
-
/**
* Connected to core service.
*/
@@ -1710,13 +1732,23 @@
/**
* Advertise the place in the GNS zone of the @e ego of the @a host.
*
- * @param hst Host of the place.
- * @param name The name for the PLACE record to put in the zone.
- * @param peer_count Number of elements in the @a peers array.
- * @param peers List of peers in the PLACE record that can be used to send join
- * requests to.
- * @param expiration_time Expiration time of the record, use 0 to remove the
record.
- * @param password Password used to encrypt the record.
+ * @param hst
+ * Host of the place.
+ * @param name
+ * The name for the PLACE record to put in the zone.
+ * @param peer_count
+ * Number of elements in the @a peers array.
+ * @param peers
+ * List of peers to put in the PLACE record to advertise
+ * as entry points to the place in addition to the origin.
+ * @param expiration_time
+ * Expiration time of the record, use 0 to remove the record.
+ * @param password
+ * Password used to encrypt the record.
+ * @param result_cb
+ * Function called with the result of the operation.
+ * @param result_cls
+ * Closure for @a result_cb
*/
void
GNUNET_SOCIAL_host_advertise (struct GNUNET_SOCIAL_Host *hst,
@@ -1724,7 +1756,9 @@
size_t peer_count,
const struct GNUNET_PeerIdentity *peers,
struct GNUNET_TIME_Relative expiration_time,
- const char *password)
+ const char *password,
+ GNUNET_NAMESTORE_ContinuationWithStatus
result_cb,
+ void *result_cls)
{
struct GNUNET_SOCIAL_Place *plc = &hst->plc;
if (NULL == namestore)
@@ -1748,8 +1782,7 @@
rd.data = rec;
GNUNET_NAMESTORE_records_store (namestore, &hst->plc.ego_key,
- name, 1, &rd,
namestore_result_host_advertise,
- hst);
+ name, 1, &rd, result_cb, result_cls);
}
Modified: gnunet/src/social/test_social.c
===================================================================
--- gnunet/src/social/test_social.c 2015-09-07 16:46:07 UTC (rev 36345)
+++ gnunet/src/social/test_social.c 2015-09-08 01:36:33 UTC (rev 36346)
@@ -127,7 +127,9 @@
TEST_GUEST_LOOK_AT = 12,
TEST_GUEST_LOOK_FOR = 13,
TEST_GUEST_LEAVE = 14,
- TEST_HOST_LEAVE = 15,
+ TEST_HOST_ADVERTISE = 15,
+ TEST_GUEST_ENTER_BY_NAME = 16,
+ TEST_HOST_LEAVE = 17,
} test;
@@ -307,17 +309,36 @@
static void
+host_recv_advertise_result (void *cls, int32_t success, const char *emsg)
+{
+ GNUNET_assert (GNUNET_YES == success);
+ GNUNET_SCHEDULER_add_now (&schedule_host_leave, NULL);
+}
+
+
+static void
+host_advertise ()
+{
+ test = TEST_HOST_ADVERTISE;
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Test #%u: Advertising place.\n",
test);
+ GNUNET_SOCIAL_host_advertise (hst, "home", 1, &this_peer,
+ GNUNET_TIME_UNIT_MINUTES, "let.me*in!",
+ host_recv_advertise_result, hst);
+}
+
+
+static void
host_farewell (void *cls,
const struct GNUNET_SOCIAL_Nym *nym,
struct GNUNET_ENV_Environment *env)
{
- const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_key =
GNUNET_SOCIAL_nym_get_key (nym);
- char *str;
+ const struct GNUNET_CRYPTO_EcdsaPublicKey *
+ nym_key = GNUNET_SOCIAL_nym_get_key (nym);
- str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key);
+ char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key);
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
- "Farewell: nym %s has left the place.\n",
- str);
+ "Farewell: nym %s (%s) has left the place.\n",
+ GNUNET_h2s (GNUNET_SOCIAL_nym_get_key_hash (nym)), str);
GNUNET_free (str);
GNUNET_assert (1 == GNUNET_ENV_environment_get_count (env));
if (0 != memcmp (&guest_pub_key, nym_key, sizeof (*nym_key)))
@@ -328,8 +349,7 @@
GNUNET_free (str);
GNUNET_assert (0);
}
-
- GNUNET_SCHEDULER_add_now (&schedule_host_leave, NULL);
+ host_advertise ();
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r36346 - in gnunet/src: include psyc social,
gnunet <=