From dc44e6c61393a3f69a02e7e5c22df5e0506eb8bc Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sat, 7 Sep 2002 20:33:58 +0000 Subject: [PATCH] Added anonymous client connections support. --- CHANGES | 7 +++++++ apps/silcd/packet_receive.c | 19 +++++++++++++++++++ apps/silcd/server.c | 4 ++++ apps/silcd/serverconfig.c | 6 +++++- apps/silcd/serverconfig.h | 9 +++++---- doc/example_silcd.conf.in | 7 +++++++ 6 files changed, 47 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index e2348abd..88849064 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,13 @@ Sat Sep 7 22:26:50 EEST 2002 Pekka Riikonen 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 * In JOIN notify handling, mark that the cache entry of the diff --git a/apps/silcd/packet_receive.c b/apps/silcd/packet_receive.c index c0bda143..d3f03aae 100644 --- a/apps/silcd/packet_receive.c +++ b/apps/silcd/packet_receive.c @@ -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; diff --git a/apps/silcd/server.c b/apps/silcd/server.c index f95613aa..10c72d22 100644 --- a/apps/silcd/server.c +++ b/apps/silcd/server.c @@ -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; diff --git a/apps/silcd/serverconfig.c b/apps/silcd/serverconfig.c index 6bb799d6..f90a6938 100644 --- a/apps/silcd/serverconfig.c +++ b/apps/silcd/serverconfig.c @@ -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 } }; diff --git a/apps/silcd/serverconfig.h b/apps/silcd/serverconfig.h index a55d2af9..ef9ce8b7 100644 --- a/apps/silcd/serverconfig.h +++ b/apps/silcd/serverconfig.h @@ -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; diff --git a/doc/example_silcd.conf.in b/doc/example_silcd.conf.in index 9a79a679..aa7df35a 100644 --- a/doc/example_silcd.conf.in +++ b/doc/example_silcd.conf.in @@ -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 ? }; -- 2.24.0