Added anonymous client connections support.
authorPekka Riikonen <priikone@silcnet.org>
Sat, 7 Sep 2002 20:33:58 +0000 (20:33 +0000)
committerPekka Riikonen <priikone@silcnet.org>
Sat, 7 Sep 2002 20:33:58 +0000 (20:33 +0000)
CHANGES
apps/silcd/packet_receive.c
apps/silcd/server.c
apps/silcd/serverconfig.c
apps/silcd/serverconfig.h
doc/example_silcd.conf.in

diff --git a/CHANGES b/CHANGES
index e2348abdda7633b34f577cb40dca23ff012dbce8..8884906448b7aa201dc6686ef5e2dbe71f8668b7 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,13 @@ Sat Sep  7 22:26:50 EEST 2002  Pekka Riikonen <priikone@silcnet.org>
          channel, do not re-create the channel since it creates
          duplicate same channels.  Affected file silcd/server.c.
 
+       * Added anonymous client connections support to server.  New
+         "anonymous" configuration option to ConnectionParams section
+         added.  If set to true, the username and hostname information
+         of the client will be scrambled and anonymous user mode is
+         set automatically to the user.  Affected files are
+         silcd/serverconfig.[ch], silcd/packet_receive.c and server.c.
+
 Sat Sep  7 16:02:09 EEST 2002  Pekka Riikonen <priikone@silcnet.org>
 
        * In JOIN notify handling, mark that the cache entry of the
index c0bda1432fee1a80bf82967dcf251b208ac041f0..d3f03aae0bca0667e643715008640924f39f2955 100644 (file)
@@ -2290,6 +2290,25 @@ SilcClientEntry silc_server_new_client(SilcServer server,
     snprintf(&nickname[strlen(nickname) - 1], 1, "%d", nickfail);
   }
 
+  /* If client marked as anonymous, scramble the username and hostname */
+  if (client->mode & SILC_UMODE_ANONYMOUS) {
+    char *scramble;
+
+    if (strlen(username) >= 2) {
+      username[0] = silc_rng_get_byte_fast(server->rng);
+      username[1] = silc_rng_get_byte_fast(server->rng);
+    }
+
+    scramble = silc_hash_babbleprint(server->sha1hash, username,
+                                    strlen(username));
+    scramble[5] = '@';
+    scramble[11] = '.';
+    memcpy(&scramble[16], ".silc", 5);
+    scramble[21] = '\0';
+    silc_free(username);
+    username = scramble;
+  }
+
   /* Update client entry */
   idata->status |= SILC_IDLIST_STATUS_REGISTERED;
   client->nickname = nickname;
index f95613aae683ff5e849f1d67d084e323d2cb87d6..10c72d22b511a8148d188dd76fe7aecce0b385b6 100644 (file)
@@ -1852,6 +1852,10 @@ SILC_TASK_CALLBACK(silc_server_accept_new_connection_final)
       if (conn->param) {
        if (conn->param->keepalive_secs)
          hearbeat_timeout = conn->param->keepalive_secs;
+
+       /* Check if to be anonymous connection */
+       if (conn->param->anonymous)
+         client->mode |= SILC_UMODE_ANONYMOUS;
       }
 
       id_entry = (void *)client;
index 6bb799d6cbd6a3447a6f3e2d720b56716b2fb295..f90a6938e3aefa235a4a43f28f21ab3a8745d027 100644 (file)
@@ -671,6 +671,9 @@ SILC_CONFIG_CALLBACK(fetch_connparam)
     tmp->version_software_vendor =
       (*(char *)val ? strdup((char *) val) : NULL);
   }
+  else if (!strcmp(name, "anonymous")) {
+    tmp->anonymous = *(bool *)val;
+  }
   else
     return SILC_CONFIG_EINTERNAL;
 
@@ -1108,7 +1111,8 @@ static const SilcConfigTable table_connparam[] = {
   { "key_exchange_pfs",               SILC_CONFIG_ARG_TOGGLE, fetch_connparam, NULL },
   { "version_protocol",               SILC_CONFIG_ARG_STR,    fetch_connparam, NULL },
   { "version_software",               SILC_CONFIG_ARG_STR,    fetch_connparam, NULL },
-  { "version_software_vendor", SILC_CONFIG_ARG_STR,     fetch_connparam,       NULL },
+  { "version_software_vendor", SILC_CONFIG_ARG_STR,    fetch_connparam,        NULL },
+  { "anonymous",               SILC_CONFIG_ARG_TOGGLE, fetch_connparam,        NULL },
   { 0, 0, 0, 0 }
 };
 
index a55d2af909aaaeb412b4525c630dd9a4aca483ce..ef9ce8b75e97378e1d16ac345a141cb7f3c755fa 100644 (file)
@@ -79,18 +79,19 @@ typedef struct SilcServerConfigLoggingStruct {
 /* Connection parameters */
 typedef struct SilcServerConfigConnParams {
   char *name;
+  char *version_protocol;
+  char *version_software;
+  char *version_software_vendor;
   SilcUInt32 connections_max;
   SilcUInt32 connections_max_per_host;
   SilcUInt32 keepalive_secs;
   SilcUInt32 reconnect_count;
   SilcUInt32 reconnect_interval;
   SilcUInt32 reconnect_interval_max;
-  bool reconnect_keep_trying;
   SilcUInt32 key_exchange_rekey;
   bool key_exchange_pfs;
-  char *version_protocol;
-  char *version_software;
-  char *version_software_vendor;
+  bool reconnect_keep_trying;
+  bool anonymous;
   struct SilcServerConfigConnParams *next;
 } SilcServerConfigConnParams;
 
index 9a79a679760774ec982f1097e67847bed9e1df89..aa7df35a65bb25257793034cd8e6652aae0296bd 100644 (file)
@@ -351,6 +351,13 @@ ConnectionParams {
        # process somewhat slower, than without PFS.
        #key_exchange_pfs = true;
 
+       # Anonymous connection.  This setting has effect only when this
+       # this is used with client connections.  If set to true then clients
+       # using this connection parameter will be anonymous connections.
+       # This means that the client's username and hostname information
+       # is scrambled and anonymous mode is set for the user.
+       #anonymous = true;
+
        #TODO:
        #connections_interval - incoming connection interval limit ?
 };