struct GNUNET_TIME_Relative latency,
uint32_t distance)
{
- if (advertising && (NULL != client_adv_handler))
+ if ( !learning )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Recieved hostlist advertisement, but I am not learning!\n");
+ return GNUNET_NO;
+ }
+
+ if (learning && (NULL != client_adv_handler))
{
(*client_adv_handler) (cls, peer, message, latency, distance);
return GNUNET_YES;
}
if (provide_hostlist)
{
- GNUNET_HOSTLIST_server_start (cfg, sched, stats, core, &server_ch, &server_dh);
+ GNUNET_HOSTLIST_server_start (cfg, sched, stats, core, &server_ch, &server_dh, advertising );
}
if (learning)
{
#include "gnunet_hello_lib.h"
#include "gnunet_statistics_service.h"
#include "gnunet_transport_service.h"
+#include "gnunet-daemon-hostlist.h"
#include <curl/curl.h>
#define DEBUG_HOSTLIST_CLIENT GNUNET_YES
struct GNUNET_TIME_Relative latency,
uint32_t distance)
{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Hostlist client recieved advertisement, checking message: %s\n");
int size = ntohs (message->size);
+ int uri_size = size - sizeof ( struct GNUNET_HOSTLIST_ADV_Message );
int type = ntohs (message->type);
+ char * uri = GNUNET_malloc ( uri_size );
+
if ( type != GNUNET_MESSAGE_TYPE_HOSTLIST_ADVERTISEMENT)
return GNUNET_NO;
-#if DEBUG_HOSTLIST_CLIENT
+
+ const struct GNUNET_HOSTLIST_ADV_Message * incoming = (const struct GNUNET_HOSTLIST_ADV_Message *) message;
+ //struct GNUNET_HOSTLIST_ADV_Message * msg = message;
+ memcpy ( uri, &incoming[1], uri_size );
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Hostlist client recieved advertisement uri: %s\n", uri);
+ #if DEBUG_HOSTLIST_CLIENT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Hostlist client recieved advertisement message, size %u, type %u\n",size,type);
+ "Hostlist client recieved advertisement message, type %u, message size %u, headersize %u, uri length %u, uri: %s\n",type,size,sizeof( struct GNUNET_HOSTLIST_ADV_Message ),uri_size,uri);
#endif
+
return GNUNET_YES;
}
char *data;
};
+/**
+ * Set if we are allowed to advertise our hostlist to others.
+ */
+static int advertising;
+
/**
* Task that will produce a new response object.
*/
uri = strcat(uri, ":");
uri = strcat(uri, port_s);
uri = strcat(uri, "/");
- strcpy(hostlist_uri,uri);
+ if ( length < 255);
+ strcpy(hostlist_uri,uri);
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,"Address to obtain hostlist: %s\n", hostlist_uri);
if ( ( size + sizeof( struct GNUNET_HOSTLIST_ADV_Message )) > GNUNET_SERVER_MAX_MESSAGE_SIZE)
struct GNUNET_TIME_Relative latency,
uint32_t distance)
{
+ if ( !advertising )
+ return;
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"A new peer connected to the server, preparing to send hostlist advertisement\n");
/* create a new advertisement message */
struct GNUNET_STATISTICS_Handle *st,
struct GNUNET_CORE_Handle *co,
GNUNET_CORE_ConnectEventHandler *server_ch,
- GNUNET_CORE_DisconnectEventHandler *server_dh)
+ GNUNET_CORE_DisconnectEventHandler *server_dh,
+ int advertise)
{
unsigned long long port;
+ advertising = advertise;
+ if ( !advertising )
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Advertising not enabled on this hostlist server\n");
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Advertising enabled on this hostlist server\n");
sched = s;
cfg = c;
stats = st;
struct GNUNET_STATISTICS_Handle *st,
struct GNUNET_CORE_Handle *core,
GNUNET_CORE_ConnectEventHandler *server_ch,
- GNUNET_CORE_DisconnectEventHandler *server_dh);
+ GNUNET_CORE_DisconnectEventHandler *server_dh,
+ int advertise);
/**
#define START_ARM GNUNET_YES
-#define VERBOSE GNUNET_YES
-#define DEBUG GNUNET_YES
-
/**
* How long until we give up on transmitting the message?
*/