gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r5883 - in GNUnet: . contrib src/applications src/applicati


From: gnunet
Subject: [GNUnet-SVN] r5883 - in GNUnet: . contrib src/applications src/applications/session src/applications/transport src/server src/transports
Date: Wed, 12 Dec 2007 14:02:30 -0700 (MST)

Author: grothoff
Date: 2007-12-12 14:02:30 -0700 (Wed, 12 Dec 2007)
New Revision: 5883

Modified:
   GNUnet/contrib/config-daemon.scm
   GNUnet/src/applications/Makefile.am
   GNUnet/src/applications/session/connect.c
   GNUnet/src/applications/session/sessiontest_http.c
   GNUnet/src/applications/transport/transport.c
   GNUnet/src/server/connection.c
   GNUnet/src/server/connection.h
   GNUnet/src/transports/smtp.c
   GNUnet/todo
Log:
implementing rate limiting for outbound e-mail

Modified: GNUnet/contrib/config-daemon.scm
===================================================================
--- GNUnet/contrib/config-daemon.scm    2007-12-12 20:52:50 UTC (rev 5882)
+++ GNUnet/contrib/config-daemon.scm    2007-12-12 21:02:30 UTC (rev 5883)
@@ -989,6 +989,18 @@
  (cons 1200 65528)
  'smtp-loaded))
 
+(define (smtp-ratelimit builder)
+ (builder
+ "SMTP"
+ "RATELIMIT"
+ (_ "What is the maximum number of e-mails that gnunetd would be allowed to 
send per hour?")
+ (_ "Use 0 for unlimited")
+ '()
+ #t
+ 0
+ (cons 0 1048576)
+ 'smtp-loaded))
+
 (define (smtp-email builder)
  (builder
  "SMTP"
@@ -1045,6 +1057,7 @@
  (nohelp)
  (list 
    (smtp-email builder)
+   (smtp-ratelimit builder)
    (smtp-filter builder)
    (smtp-pipe builder)
    (smtp-server builder)

Modified: GNUnet/src/applications/Makefile.am
===================================================================
--- GNUnet/src/applications/Makefile.am 2007-12-12 20:52:50 UTC (rev 5882)
+++ GNUnet/src/applications/Makefile.am 2007-12-12 21:02:30 UTC (rev 5883)
@@ -24,7 +24,6 @@
  fs \
  state \
  stats \
- gap \
  pingpong \
  session \
  dht \
@@ -37,6 +36,7 @@
  traffic \
  transport \
  advertising \
+ gap \
  $(VPN_DIR)
 # $(TESTBED_DIR) 
 # chat

Modified: GNUnet/src/applications/session/connect.c
===================================================================
--- GNUnet/src/applications/session/connect.c   2007-12-12 20:52:50 UTC (rev 
5882)
+++ GNUnet/src/applications/session/connect.c   2007-12-12 21:02:30 UTC (rev 
5883)
@@ -509,19 +509,18 @@
     hello = transport->createhello (GNUNET_TRANSPORT_PROTOCOL_NUMBER_ANY);
   if (NULL == hello)
     {
-      char * tports;
+      char *tports;
 
       tports = NULL;
-      GNUNET_GC_get_configuration_value_string(coreAPI->cfg,
-                                              "GNUNETD",
-                                              "TRANSPORTS",
-                                              NULL,
-                                              &tports);
+      GNUNET_GC_get_configuration_value_string (coreAPI->cfg,
+                                                "GNUNETD",
+                                                "TRANSPORTS", NULL, &tports);
       GNUNET_GE_LOG (ectx,
                      GNUNET_GE_ERROR | GNUNET_GE_USER | GNUNET_GE_IMMEDIATE,
-                     _("Could not create any HELLO for myself (have transports 
`%s')!\n"),
-                    tports);
-      GNUNET_free_non_null(tports);
+                     _
+                     ("Could not create any HELLO for myself (have transports 
`%s')!\n"),
+                     tports);
+      GNUNET_free_non_null (tports);
     }
 #if DEBUG_SESSION
   GNUNET_GE_LOG (ectx,

Modified: GNUnet/src/applications/session/sessiontest_http.c
===================================================================
--- GNUnet/src/applications/session/sessiontest_http.c  2007-12-12 20:52:50 UTC 
(rev 5882)
+++ GNUnet/src/applications/session/sessiontest_http.c  2007-12-12 21:02:30 UTC 
(rev 5883)
@@ -79,26 +79,25 @@
     {
       sock1 = GNUNET_client_connection_create (NULL, cfg1);
       sock2 = GNUNET_client_connection_create (NULL, cfg2);
-      if ( (sock1 != NULL)&&
-          (sock2 != NULL) ) 
-       {
-         h1 = NULL;
-         fprintf (stderr, "Notifying NATed peer about other peer");
-         if ((GNUNET_OK == GNUNET_IDENTITY_get_self (sock1,
-                                                     &h1)) &&
-             (GNUNET_OK == GNUNET_IDENTITY_peer_add (sock2, h1)))
-           {
-             fprintf (stderr, "!\n");
-             ret = GNUNET_OK;
-           }
-         else
-           fprintf (stderr, "?\n");
-         GNUNET_free_non_null (h1);
-       }
+      if ((sock1 != NULL) && (sock2 != NULL))
+        {
+          h1 = NULL;
+          fprintf (stderr, "Notifying NATed peer about other peer");
+          if ((GNUNET_OK == GNUNET_IDENTITY_get_self (sock1,
+                                                      &h1)) &&
+              (GNUNET_OK == GNUNET_IDENTITY_peer_add (sock2, h1)))
+            {
+              fprintf (stderr, "!\n");
+              ret = GNUNET_OK;
+            }
+          else
+            fprintf (stderr, "?\n");
+          GNUNET_free_non_null (h1);
+        }
       if (sock1 != NULL)
-       GNUNET_client_connection_destroy (sock1);
+        GNUNET_client_connection_destroy (sock1);
       if (sock2 != NULL)
-       GNUNET_client_connection_destroy (sock2);
+        GNUNET_client_connection_destroy (sock2);
     }
   else
     {

Modified: GNUnet/src/applications/transport/transport.c
===================================================================
--- GNUnet/src/applications/transport/transport.c       2007-12-12 20:52:50 UTC 
(rev 5882)
+++ GNUnet/src/applications/transport/transport.c       2007-12-12 21:02:30 UTC 
(rev 5883)
@@ -495,13 +495,13 @@
   else
     {
       if ((ttype >= tapis_count) || (tapis[ttype] == NULL))
-       {
-         GNUNET_GE_LOG (ectx,
-                        GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_USER,
-                        _("No transport of type %d known.\n"), ttype);
-         GNUNET_mutex_unlock (tapis_lock);
-         return NULL;
-       }
+        {
+          GNUNET_GE_LOG (ectx,
+                         GNUNET_GE_DEBUG | GNUNET_GE_BULK | GNUNET_GE_USER,
+                         _("No transport of type %d known.\n"), ttype);
+          GNUNET_mutex_unlock (tapis_lock);
+          return NULL;
+        }
     }
   tapi = tapis[ttype];
   if (tapi->hello == NULL)

Modified: GNUnet/src/server/connection.c
===================================================================
--- GNUnet/src/server/connection.c      2007-12-12 20:52:50 UTC (rev 5882)
+++ GNUnet/src/server/connection.c      2007-12-12 21:02:30 UTC (rev 5883)
@@ -4189,7 +4189,7 @@
  * @return GNUNET_OK on success, GNUNET_SYSERR if there is a problem
  */
 int
-GNUNET_CORE_connection_register_send_notification_callback
+  GNUNET_CORE_connection_register_send_notification_callback
   (GNUNET_P2PRequestHandler callback)
 {
   if (callback == NULL)
@@ -4212,7 +4212,7 @@
  * @return GNUNET_OK on success, GNUNET_SYSERR if there is a problem
  */
 int
-GNUNET_CORE_connection_unregister_send_notification_callback
+  GNUNET_CORE_connection_unregister_send_notification_callback
   (GNUNET_P2PRequestHandler callback)
 {
   int i;

Modified: GNUnet/src/server/connection.h
===================================================================
--- GNUnet/src/server/connection.h      2007-12-12 20:52:50 UTC (rev 5882)
+++ GNUnet/src/server/connection.h      2007-12-12 21:02:30 UTC (rev 5883)
@@ -323,8 +323,8 @@
  * @return GNUNET_OK on success, GNUNET_SYSERR if there is a problem
  */
 int
-GNUNET_CORE_connection_register_send_notification_callback
-(GNUNET_P2PRequestHandler callback);
+  GNUNET_CORE_connection_register_send_notification_callback
+  (GNUNET_P2PRequestHandler callback);
 
 /**
  * Unregister a handler that is to be called for each
@@ -335,8 +335,8 @@
  * @return GNUNET_OK on success, GNUNET_SYSERR if there is a problem
  */
 int
-GNUNET_CORE_connection_unregister_send_notification_callback
-(GNUNET_P2PRequestHandler callback);
+  GNUNET_CORE_connection_unregister_send_notification_callback
+  (GNUNET_P2PRequestHandler callback);
 
 /**
  * Verify that the given session handle is not in use.

Modified: GNUnet/src/transports/smtp.c
===================================================================
--- GNUnet/src/transports/smtp.c        2007-12-12 20:52:50 UTC (rev 5882)
+++ GNUnet/src/transports/smtp.c        2007-12-12 21:02:30 UTC (rev 5883)
@@ -135,7 +135,12 @@
 
 static int stat_bytesDropped;
 
+/**
+ * How many e-mails are we allowed to send per hour?
+ */
+static unsigned long long rate_limit;
 
+static GNUNET_CronTime last_transmission;
 
 /** ******************** Base64 encoding ***********/
 
@@ -531,6 +536,7 @@
   smtp_recipient_t recipient;
 #define EBUF_LEN 128
   char ebuf[EBUF_LEN];
+  GNUNET_CronTime now;
 
   if (smtp_shutdown == GNUNET_YES)
     return GNUNET_SYSERR;
@@ -539,6 +545,12 @@
       GNUNET_GE_BREAK (ectx, 0);
       return GNUNET_SYSERR;
     }
+  now = GNUNET_get_time ();
+  if ((important != GNUNET_YES) &&
+      ((now - last_transmission) * rate_limit) < GNUNET_CRON_HOURS)
+    return GNUNET_NO;           /* rate too high */
+  last_transmission = now;
+
   hello = (const GNUNET_MessageHello *) tsession->internal;
   if (hello == NULL)
     return GNUNET_SYSERR;
@@ -808,6 +820,10 @@
                                             1200,
                                             SMTP_MESSAGE_SIZE,
                                             SMTP_MESSAGE_SIZE, &mtu);
+  GNUNET_GC_get_configuration_value_number (coreAPI->cfg,
+                                            "SMTP",
+                                            "RATELIMIT",
+                                            0, 0, 1024 * 1024, &rate_limit);
   stats = coreAPI->GNUNET_CORE_request_service ("stats");
   if (stats != NULL)
     {

Modified: GNUnet/todo
===================================================================
--- GNUnet/todo 2007-12-12 20:52:50 UTC (rev 5882)
+++ GNUnet/todo 2007-12-12 21:02:30 UTC (rev 5883)
@@ -5,7 +5,6 @@
 
 0.7.3 [12'07] (aka "features"):
 - sqlite index migration (1298)
-- man pages (1258)
 - gnunet-setup qt plugin:
   * integration (into gnunet-setup.c)
   * make it actually work: 





reply via email to

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