gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r6371 - GNUnet/src/applications/hostlist


From: gnunet
Subject: [GNUnet-SVN] r6371 - GNUnet/src/applications/hostlist
Date: Mon, 18 Feb 2008 18:51:41 -0700 (MST)

Author: grothoff
Date: 2008-02-18 18:51:41 -0700 (Mon, 18 Feb 2008)
New Revision: 6371

Added:
   GNUnet/src/applications/hostlist/check.conf
   GNUnet/src/applications/hostlist/hostlisttest.c
   GNUnet/src/applications/hostlist/nat-peer.conf
   GNUnet/src/applications/hostlist/tcp-peer.conf
Modified:
   GNUnet/src/applications/hostlist/Makefile.am
   GNUnet/src/applications/hostlist/hostlist.c
Log:
testcase

Modified: GNUnet/src/applications/hostlist/Makefile.am
===================================================================
--- GNUnet/src/applications/hostlist/Makefile.am        2008-02-19 00:02:14 UTC 
(rev 6370)
+++ GNUnet/src/applications/hostlist/Makefile.am        2008-02-19 01:51:41 UTC 
(rev 6371)
@@ -16,3 +16,21 @@
 libgnunetmodule_hostlist_la_LDFLAGS = \
   -export-dynamic -avoid-version -module
 
+
+
+check_PROGRAMS = \
+  hostlisttest_tcp 
+
+TESTS = $(check_PROGRAMS)
+
+hostlisttest_tcp_SOURCES = \
+  hostlisttest.c 
+hostlisttest_tcp_LDADD = \
+  $(top_builddir)/src/applications/stats/libgnunetstats_api.la \
+  $(top_builddir)/src/applications/testing/libgnunettesting_api.la \
+  $(top_builddir)/src/util/libgnunetutil.la 
+
+EXTRA_DIST = \
+  check.conf \
+  tcp-peer.conf \
+  nat-peer.conf
\ No newline at end of file

Added: GNUnet/src/applications/hostlist/check.conf
===================================================================
--- GNUnet/src/applications/hostlist/check.conf                         (rev 0)
+++ GNUnet/src/applications/hostlist/check.conf 2008-02-19 01:51:41 UTC (rev 
6371)
@@ -0,0 +1,16 @@
+# General settings
+[GNUNET]
+GNUNET_HOME = "/tmp/gnunet-session-test-driver"
+LOGLEVEL = "WARNING"
+LOGFILE = ""
+PROCESS-PRIORITY = "NORMAL"
+
+# Network options for the clients
+[NETWORK]
+HOST = "localhost:2087"
+
+
+[TESTING]
+WEAKRANDOM = YES
+
+

Modified: GNUnet/src/applications/hostlist/hostlist.c
===================================================================
--- GNUnet/src/applications/hostlist/hostlist.c 2008-02-19 00:02:14 UTC (rev 
6370)
+++ GNUnet/src/applications/hostlist/hostlist.c 2008-02-19 01:51:41 UTC (rev 
6371)
@@ -28,6 +28,7 @@
 #include <microhttpd.h>
 #include "gnunet_identity_service.h"
 #include "gnunet_stats_service.h"
+#include "gnunet_protocols.h"
 
 #define DEBUG_HOSTLIST GNUNET_NO
 
@@ -98,6 +99,8 @@
   static int dummy;
   struct MHD_Response *response;
   struct HostSet results;
+  const char * protos;
+  int ret;
 
   if (0 != strcmp (method, MHD_HTTP_METHOD_GET))
     return MHD_NO;
@@ -109,22 +112,28 @@
   if (*upload_data_size != 0)
     return MHD_NO;              /* do not support upload data */
   memset (&results, 0, sizeof (struct HostSet));
-  results.protocols = -1;       /* for now */
+  protos = MHD_lookup_connection_value(connection,
+                                      MHD_GET_ARGUMENT_KIND,
+                                      "p");  
+  if ( (protos == NULL) ||
+       (1 != sscanf(protos, "%llu", &results.protocols)) )
+    results.protocols = -1;
+  host_processor(coreAPI->myIdentity,
+                GNUNET_TRANSPORT_PROTOCOL_NUMBER_ANY,
+                GNUNET_YES,
+                &results);
   identity->forEachHost (GNUNET_get_time (), &host_processor, &results);
   if (results.size == 0)
     return MHD_NO;              /* no known hosts!? */
   response = MHD_create_response_from_data (results.size,
                                             results.data, MHD_YES, MHD_NO);
-  MHD_queue_response (connection, MHD_HTTP_OK, response);
+  ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
   MHD_destroy_response (response);
-  return MHD_NO;
+  if (stats != NULL)
+    stats->change(stat_request_count, 1);
+  return ret;
 }
 
-/**
- * Initialize the hostlist module. This method name must match
- * the library name (libgnunet_XXX => initialize_XXX).
- * @return GNUNET_SYSERR on errors
- */
 int
 initialize_module_hostlist (GNUNET_CoreAPIForPlugins * capi)
 {

Added: GNUnet/src/applications/hostlist/hostlisttest.c
===================================================================
--- GNUnet/src/applications/hostlist/hostlisttest.c                             
(rev 0)
+++ GNUnet/src/applications/hostlist/hostlisttest.c     2008-02-19 01:51:41 UTC 
(rev 6371)
@@ -0,0 +1,122 @@
+/*
+     This file is part of GNUnet.
+     (C) 2005, 2006, 2007, 2008 Christian Grothoff (and other contributing 
authors)
+
+     GNUnet is free software; you can redistribute it and/or modify
+     it under the terms of the GNU General Public License as published
+     by the Free Software Foundation; either version 2, or (at your
+     option) any later version.
+
+     GNUnet is distributed in the hope that it will be useful, but
+     WITHOUT ANY WARRANTY; without even the implied warranty of
+     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+     General Public License for more details.
+
+     You should have received a copy of the GNU General Public License
+     along with GNUnet; see the file COPYING.  If not, write to the
+     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+     Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file applications/hostlist/hostlisttest.c
+ * @brief testcase for hostlist server
+ * @author Christian Grothoff
+ */
+
+#include "platform.h"
+#include "gnunet_protocols.h"
+#include "gnunet_util.h"
+#include "gnunet_testing_lib.h"
+#include "gnunet_stats_lib.h"
+
+#define START_PEERS GNUNET_YES
+
+static int ok;
+
+static int
+waitForConnect (const char *name, unsigned long long value, void *cls)
+{
+  if ((value > 0) && (0 == strcmp (_("# of connected peers"), name)))
+    {
+      ok = 1;
+      return GNUNET_SYSERR;
+    }
+  return GNUNET_OK;
+}
+
+/**
+ * Testcase to test p2p session key exchange.
+ *
+ * @param argc number of arguments from the command line
+ * @param argv command line arguments
+ * @return 0: ok, -1: error
+ */
+int
+main (int argc, char **argv)
+{
+#if START_PEERS
+  struct GNUNET_TESTING_DaemonContext *peers;
+#endif
+  int ret;
+  struct GNUNET_ClientServerConnection *sock1;
+  struct GNUNET_ClientServerConnection *sock2;
+  int left;
+  struct GNUNET_GC_Configuration *cfg;
+
+  cfg = GNUNET_GC_create ();
+  if (-1 == GNUNET_GC_parse_configuration (cfg, "check.conf"))
+    {
+      GNUNET_GC_free (cfg);
+      return -1;
+    }
+#if START_PEERS
+  peers = GNUNET_TESTING_start_daemons (strstr (argv[0], "_") + 1,      /* 
tcp, udp or http */
+                                        "advertising stats",
+                                        "/tmp/gnunet-session-test", 2087,
+                                        10000, 2);
+  if (peers == NULL)
+    {
+      GNUNET_GC_free (cfg);
+      return -1;
+    }
+#endif
+  if (GNUNET_OK ==
+      GNUNET_wait_for_daemon_running (NULL, cfg, 30 * GNUNET_CRON_SECONDS))
+    {
+      sock1 = GNUNET_client_connection_create (NULL, cfg);
+      GNUNET_GC_set_configuration_value_string (cfg,
+                                                NULL,
+                                                "NETWORK",
+                                                "HOST", "localhost:12087");
+      sock2 = GNUNET_client_connection_create (NULL, cfg);
+      left = 30;                /* how many iterations should we wait? */
+      while (GNUNET_OK ==
+             GNUNET_STATS_get_statistics (NULL, sock1, &waitForConnect, NULL))
+        {
+          printf ("Waiting for peers to connect (%u iterations left)...\n",
+                  left);
+          sleep (5);
+          left--;
+          if (left == 0)
+            {
+              ret = 1;
+              break;
+            }
+        }
+      GNUNET_client_connection_destroy (sock1);
+      GNUNET_client_connection_destroy (sock2);
+    }
+  else
+    {
+      printf ("Could not establish connection with peer.\n");
+      ret = 1;
+    }
+#if START_PEERS
+  GNUNET_TESTING_stop_daemons (peers);
+#endif
+  GNUNET_GC_free (cfg);
+  return (ok == 0) ? 1 : 0;
+}
+
+/* end of hostlisttest.c */


Property changes on: GNUnet/src/applications/hostlist/hostlisttest.c
___________________________________________________________________
Name: svn:eol-style
   + native

Added: GNUnet/src/applications/hostlist/nat-peer.conf
===================================================================
--- GNUnet/src/applications/hostlist/nat-peer.conf                              
(rev 0)
+++ GNUnet/src/applications/hostlist/nat-peer.conf      2008-02-19 01:51:41 UTC 
(rev 6371)
@@ -0,0 +1,47 @@
+# This is the configuration for the NATed peer
+[PATHS]
+GNUNETD_HOME     = /tmp/gnunet-hostlist-test-client
+
+[GNUNETD]
+HELLOEXPIRES     = 60
+LOGFILE         = $GNUNETD_HOME/logs
+KEEPLOG         = 0
+PIDFILE         = $GNUNETD_HOME/gnunetd.pid
+HOSTS          = $GNUNETD_HOME/data/hosts/
+APPLICATIONS = "advertising stats"
+TRANSPORTS = "nat tcp"
+HOSTLISTURL = "http://localhost:8080/";
+
+[LOGGING]
+USER-LEVEL = ERROR
+ADMIN-LEVEL = ERROR
+DEVELOPER = NO
+
+[MODULES]
+sqstore = "sqstore_sqlite"
+topology = "topology_default"
+
+[NETWORK]
+PORT = 12087
+HELLOEXCHANGE = YES
+TRUSTED = 127.0.0.0/8;
+
+[LOAD]
+BASICLIMITING = YES
+MAXNETUPBPSTOTAL       = 50000
+MAXNETDOWNBPSTOTAL     = 50000
+MAXCPULOAD             = 100
+
+[TCP]
+PORT = 0
+BLACKLIST =
+BLACKLISTV6 =
+
+[NAT]
+LIMITED = YES
+
+
+[TESTING]
+WEAKRANDOM = YES
+
+

Added: GNUnet/src/applications/hostlist/tcp-peer.conf
===================================================================
--- GNUnet/src/applications/hostlist/tcp-peer.conf                              
(rev 0)
+++ GNUnet/src/applications/hostlist/tcp-peer.conf      2008-02-19 01:51:41 UTC 
(rev 6371)
@@ -0,0 +1,48 @@
+# This is the configuration for the non-NATed peer
+[PATHS]
+GNUNETD_HOME     = /tmp/gnunet-hostlist-test-server
+
+[GNUNETD]
+HELLOEXPIRES     = 60
+LOGFILE         = $GNUNETD_HOME/logs
+KEEPLOG         = 0
+PIDFILE         = $GNUNETD_HOME/gnunetd.pid
+HOSTS          = $GNUNETD_HOME/data/hosts/
+APPLICATIONS = "advertising stats hostlist"
+TRANSPORTS = "tcp nat"
+
+[LOGGING]
+USER-LEVEL = ERROR
+ADMIN-LEVEL = ERROR
+DEVELOPER = NO
+
+[MODULES]
+sqstore = "sqstore_sqlite"
+topology = "topology_default"
+
+[NETWORK]
+PORT = 2087
+HELLOEXCHANGE = YES
+TRUSTED = 127.0.0.0/8;
+IP = 127.0.0.1
+
+[LOAD]
+BASICLIMITING = YES
+MAXNETUPBPSTOTAL       = 50000
+MAXNETDOWNBPSTOTAL     = 50000
+MAXCPULOAD             = 100
+
+[TCP]
+PORT = 2086
+BLACKLIST =
+BLACKLISTV6 =
+UPNP = NO
+
+[NAT]
+LIMITED = NO
+
+[TESTING]
+WEAKRANDOM = YES
+
+[HOSTLIST]
+PORT = 8080





reply via email to

[Prev in Thread] Current Thread [Next in Thread]