+Sat Jan 5 13:37:29 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Added the silc_client_del_client to remove the client from
+ all channels as well. Affected file lib/silcclient/idlist.c.
+
+ * Fixed the client library to correctly remove the client
+ from all channels when the client entry is being destroyed.
+ Affected file lib/silcclient/client_notify.c, command.c.
+
+ * Added auto-nicking support to the client library. If the
+ applicatio now sets client->nickname it will be sent to the
+ server after connecting by the library. This way for example
+ SILCNICK (or IRCNICK) environment variables will have effect
+ and always change the nickname automatically to whatever
+ it is wanted. Affected file lib/silcclient/client.[ch].
+
+ * Renamed silc_server_command_bad_chars to the
+ silc_server_name_bad_chars and moved it to the
+ silcd/server_util.[ch]. Added also new function
+ silc_server_name_modify_bad to return nickname that
+ includes bad characters as new nickname without those
+ bad characters. This check and modify is now used in
+ silc_server_new_client when the username is initially set
+ as nickname, so it must be checked to be valid nickname.
+ Affected file silcd/packet_receive.c.
+
+ * The nickname length is now taken from the packet for real
+ and not trusted to strlen() since it clearly can return
+ wrong length for nickname including bad characters. This
+ also applies to channel names. Affected file silcd/command.c.
+
+ * Removed the lib/silcsilm/modules directory. Modules are now
+ compiled into the lib/silcsim. Fixed the copying of the
+ modules to follow symbolic links in Makefile.am.pre.
+
Wed Jan 2 18:56:21 EET 2002 Pekka Riikonen <priikone@silcnet.org>
* Fixed silc_string_regexify list creation. Fixes bugs with
fi
sim-install:
- -cp -fR $(srcdir)/lib/silcsim/modules/*.so $(modulesdir)/
+ -cp -fRL $(srcdir)/lib/silcsim/*.so $(modulesdir)/
doc-install:
$(INSTALL_DATA) $(srcdir)/doc/CodingStyle $(docdir)/
cipher, hash, hmac and pkcs configuration to the Irssi SILC's config
file.
- o Add auto-nick support to Irssi, so that the user specified nickname
- would be sent to the server immediately (automatically) after the
- client is connected to the server.
-
o Add PERL scripting support from Irssi CVS.
o Extend the /HELP command to support sub commands or something. So
not needed and its usage is buggy when the context is registered
to multiple pending commands.
- o Add perhaps an option of setting the nickname to the client context.
- If set (and username != nickname) the client libary would send NICK
- command to the server after connecting to automatically set the
- nickname.
-
o Additions to do after protocol version 1.1:
o Fix the NICK_CHANGE notify handling not to create new entry
========================
o strerror messages from premature EOF's to signoff messages.
+ (add perhaps a socket error thingy to SilcSockeConnection).
o Backup router related issues
}
/* nick */
- /* Actually take SILCUSER or IRCUSER since nickname cannot be set
- beforehand in SILC (XXX auto-nicking support should be added to Irssi). */
nick = settings_get_str("nick");
if (nick == NULL || *nick == '\0') {
- str = g_getenv("SILCUSER");
+ str = g_getenv("SILCNICK");
if (!str)
- str = g_getenv("IRCUSER");
+ str = g_getenv("IRCNICK");
settings_set_str("nick", str != NULL ? str : user_name);
nick = settings_get_str("nick");
/* Get user information */
silc_client->username = g_strdup(settings_get_str("user_name"));
+ silc_client->nickname = g_strdup(settings_get_str("nick"));
silc_client->hostname = silc_net_localhost();
silc_client->realname = g_strdup(settings_get_str("real_name"));
silc_server_command_free(cmd);
}
-/* Checks string for bad characters and returns TRUE if they are found. */
-
-static int silc_server_command_bad_chars(char *nick)
-{
- int i;
-
- for (i = 0; i < strlen(nick); i++) {
- if (!isascii(nick[i]))
- return TRUE;
- if (nick[i] <= 32) return TRUE;
- if (nick[i] == ' ') return TRUE;
- if (nick[i] == '*') return TRUE;
- if (nick[i] == '?') return TRUE;
- if (nick[i] == ',') return TRUE;
- }
-
- return FALSE;
-}
-
/* Server side of command NICK. Sets nickname for user. Setting
nickname causes generation of a new client ID for the client. The
new client ID is sent to the client after changing the nickname. */
SilcServer server = cmd->server;
SilcBuffer packet, nidp, oidp = NULL;
SilcClientID *new_id;
+ uint32 nick_len;
char *nick;
uint16 ident = silc_command_get_ident(cmd->payload);
int nickfail = 0;
SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_NICK, cmd, 1, 1);
/* Check nickname */
- nick = silc_argument_get_arg_type(cmd->args, 1, NULL);
- if (silc_server_command_bad_chars(nick) == TRUE) {
+ nick = silc_argument_get_arg_type(cmd->args, 1, &nick_len);
+ if (nick_len > 128)
+ nick[128] = '\0';
+ if (silc_server_name_bad_chars(nick, nick_len) == TRUE) {
silc_server_command_send_status_reply(cmd, SILC_COMMAND_NICK,
SILC_STATUS_ERR_BAD_NICKNAME);
goto out;
}
- if (strlen(nick) > 128)
- nick[128] = '\0';
-
/* Check for same nickname */
if (!strcmp(client->nickname, nick)) {
nidp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
}
channel_name = tmp;
- if (strlen(channel_name) > 256)
+ if (tmp_len > 256)
channel_name[255] = '\0';
- if (silc_server_command_bad_chars(channel_name) == TRUE) {
+ if (silc_server_name_bad_chars(channel_name, tmp_len) == TRUE) {
silc_server_command_send_status_reply(cmd, SILC_COMMAND_JOIN,
SILC_STATUS_ERR_BAD_CHANNEL);
goto out;
SilcBuffer reply;
SilcIDListData idata;
char *username = NULL, *realname = NULL, *id_string;
+ uint16 username_len;
uint32 id_len;
int ret;
char *hostname, *nickname;
/* Parse incoming packet */
ret = silc_buffer_unformat(buffer,
- SILC_STR_UI16_STRING_ALLOC(&username),
+ SILC_STR_UI16_NSTRING_ALLOC(&username,
+ &username_len),
SILC_STR_UI16_STRING_ALLOC(&realname),
SILC_STR_END);
if (ret == -1) {
- if (username)
- silc_free(username);
- if (realname)
- silc_free(realname);
+ silc_free(username);
+ silc_free(realname);
silc_server_disconnect_remote(server, sock, "Server closed connection: "
"Incomplete client information");
return NULL;
if (!username) {
silc_free(username);
- if (realname)
- silc_free(realname);
+ silc_free(realname);
silc_server_disconnect_remote(server, sock, "Server closed connection: "
"Incomplete client information");
return NULL;
}
- if (strlen(username) > 128)
- username[127] = '\0';
+ if (username_len > 128)
+ username[128] = '\0';
- nickname = strdup(username);
+ /* Check for bad characters for nickname, and modify the nickname if
+ it includes those. */
+ if (silc_server_name_bad_chars(username, username_len)) {
+ nickname = silc_server_name_modify_bad(username, username_len);
+ } else {
+ nickname = strdup(username);
+ }
/* Make sanity checks for the hostname of the client. If the hostname
is provided in the `username' check that it is the same than the
strcmp(sock->hostname, hostname)) {
silc_free(username);
silc_free(hostname);
- if (realname)
- silc_free(realname);
+ silc_free(realname);
silc_server_disconnect_remote(server, sock,
"Server closed connection: "
"Incomplete client information");
phostname && strcmp(phostname, hostname)) {
silc_free(username);
silc_free(hostname);
- if (phostname)
- silc_free(phostname);
- if (realname)
- silc_free(realname);
+ silc_free(phostname);
+ silc_free(realname);
silc_server_disconnect_remote(server, sock,
"Server closed connection: "
"Incomplete client information");
return NULL;
}
- if (phostname)
- silc_free(phostname);
+ silc_free(phostname);
} else {
/* The hostname is not present, add it. */
char *newusername;
return FALSE;
}
+
+/* Checks string for bad characters and returns TRUE if they are found. */
+
+bool silc_server_name_bad_chars(const char *name, uint32 name_len)
+{
+ int i;
+
+ for (i = 0; i < name_len; i++) {
+ if (!isascii(name[i]))
+ return TRUE;
+ if (name[i] <= 32) return TRUE;
+ if (name[i] == ' ') return TRUE;
+ if (name[i] == '*') return TRUE;
+ if (name[i] == '?') return TRUE;
+ if (name[i] == ',') return TRUE;
+ }
+
+ return FALSE;
+}
+
+/* Modifies the `name' if it includes bad characters and returns new
+ allocated name that does not include bad characters. */
+
+char *silc_server_name_modify_bad(const char *name, uint32 name_len)
+{
+ int i;
+ char *newname = strdup(name);
+
+ for (i = 0; i < name_len; i++) {
+ if (!isascii(newname[i])) newname[i] = '_';
+ if (newname[i] <= 32) newname[i] = '_';
+ if (newname[i] == ' ') newname[i] = '_';
+ if (newname[i] == '*') newname[i] = '_';
+ if (newname[i] == '?') newname[i] = '_';
+ if (newname[i] == ',') newname[i] = '_';
+ }
+
+ return newname;
+}
bool silc_server_client_on_channel(SilcClientEntry client,
SilcChannelEntry channel);
+/* Checks string for bad characters and returns TRUE if they are found. */
+bool silc_server_name_bad_chars(const char *name, uint32 name_len);
+
+/* Modifies the `nick' if it includes bad characters and returns new
+ allocated nickname that does not include bad characters. */
+char *silc_server_name_modify_bad(const char *name, uint32 name_len);
+
#endif /* SERVER_UTIL_H */
lib/silcmath/mpi/Makefile.defines
lib/silcmath/mpi/Makefile.defines_int
lib/silcsim/Makefile
-lib/silcsim/modules/Makefile
lib/silcske/Makefile
lib/silcutil/Makefile
lib/silcutil/unix/Makefile
SILC Client Library Manual
- Version 0.5
+ Version 0.7
1.0 Introduction
client->public_key
client->private_key
+You may also set client->nickname if you want. If it is set then the
+library will change the nickname to that one after the client is connected
+to the server. If not set, then server will initially give the nickname
+which is same as the username.
+
After setting the pointers one must call:
silc_client_init(client);
/*
- client.c
+ client.c
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2001 Pekka Riikonen
+ Copyright (C) 1997 - 2002 Pekka Riikonen
This program 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 of the License, or
- (at your option) any later version.
-
+ the Free Software Foundation; version 2 of the License.
+
This program 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
Make sure they do not do that. */
silc_schedule_task_del_by_fd(client->schedule, fd);
- conn->nickname = strdup(client->username);
+ conn->nickname = (client->nickname ? strdup(client->nickname) :
+ strdup(client->username));
conn->sock->hostname = strdup(conn->remote_host);
conn->sock->ip = strdup(conn->remote_host);
conn->sock->port = conn->remote_port;
(void *)conn->local_entry, 0, NULL);
if (connecting) {
- /* Issue INFO comqmand to fetch the real server name and server information
+ /* Send NICK command if the nickname was set by the application (and is
+ not same as the username). */
+ if (client->nickname && strcmp(client->nickname, client->username))
+ silc_client_command_send(client, conn, SILC_COMMAND_NICK,
+ ++conn->cmd_ident, 1, 1,
+ client->nickname, strlen(client->nickname));
+
+ /* Issue INFO command to fetch the real server name and server information
and other stuff. */
silc_client_command_register(client, SILC_COMMAND_INFO, NULL, NULL,
silc_client_command_reply_info_i, 0,
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2001 Pekka Riikonen
+ Copyright (C) 1997 - 2002 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* Main client structure. */
struct SilcClientStruct {
char *username; /* Username, must be set by application */
+ char *nickname; /* Nickname, may be set by application */
char *hostname; /* hostname, must be set by application */
char *realname; /* Real name, must be set be application */
/*
- client_notify.c
+ client_notify.c
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2001 Pekka Riikonen
+ Copyright (C) 1997 - 2002 Pekka Riikonen
This program 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 of the License, or
- (at your option) any later version.
-
+ the Free Software Foundation; version 2 of the License.
+
This program 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
/* Notify application. */
client->internal->ops->notify(client, conn, type, client_entry, tmp);
- if (client_entry != conn->local_entry) {
- /* Remove client from all channels */
- silc_client_remove_from_channels(client, conn, client_entry);
+ if (client_entry != conn->local_entry)
+ /* Remove the client from all channels and free it */
silc_client_del_client(client, conn, client_entry);
- }
break;
if (client_entry == conn->local_entry)
continue;
- silc_client_remove_from_channels(client, conn, client_entry);
+ /* Remove the client from all channels and free it */
silc_client_del_client(client, conn, client_entry);
}
silc_free(clients);
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2001 Pekka Riikonen
+ Copyright (C) 1997 - 2002 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
/* Get the target client */
target = silc_idlist_get_client(cmd->client, conn, nickname,
cmd->argv[1], FALSE);
- if (target) {
- silc_client_remove_from_channels(client, conn, target);
+ if (target)
+ /* Remove the client from all channels and free it */
silc_client_del_client(client, conn, target);
- }
silc_free(nickname);
silc_client_command_free(cmd);
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2001 Pekka Riikonen
+ Copyright (C) 1997 - 2002 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 2001 Pekka Riikonen
+ Copyright (C) 2001 - 2002 Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
SilcClientEntry client_entry)
{
bool ret = silc_idcache_del_by_context(conn->client_cache, client_entry);
+
+ /* Remove from channels */
+ silc_client_remove_from_channels(client, conn, client_entry);
+
+ /* Free the client entry data */
silc_client_del_client_entry(client, conn, client_entry);
+
return ret;
}
silcsim.c \
silcsimutil.c
-SIM_MODULES_DIR = modules
-
-SUBDIRS = modules
-
#
# SILC Ciphers to be compiled as modules
#
$(SIM_CIPHER_OBJS): ../silccrypt/libsilccrypt.a
$(LTCOMPILE) -c $(srcdir)/../silccrypt/$*.c
$(LIBTOOL) --mode=link $(LINK) -rpath $(silc_modulesdir) -o lib$*.la $*.lo
- cd $(srcdir)/$(SIM_MODULES_DIR) && $(LN_S) -f $(srcdir)/../.libs/lib$*.so $(srcdir)/$*.sim.so
+ cd $(srcdir) && $(LN_S) -f $(srcdir)/../.libs/lib$*.so $(srcdir)/$*.sim.so
$(SIM_HASH_OBJS): ../silccrypt/libsilccrypt.a
$(LTCOMPILE) -c $(srcdir)/../silccrypt/$*.c
$(LIBTOOL) --mode=link $(LINK) -rpath $(silc_modulesdir) -o lib$*.la $*.lo
- cd $(srcdir)/$(SIM_MODULES_DIR) && $(LN_S) -f $(srcdir)/../.libs/lib$*.so $(srcdir)/$*.sim.so
+ cd $(srcdir) && $(LN_S) -f $(srcdir)/../.libs/lib$*.so $(srcdir)/$*.sim.so
-CLEANFILES = $(SIM_MODULES_DIR)/*.sim.so *.la
+CLEANFILES = *.sim.so *.la
if SILC_DIST_TOOLKIT
include_HEADERS = silcsim.h silcsimutil.h
/*
- silcutil.c
+ silcutil.c
- Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
+ Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2000 Pekka Riikonen
+ Copyright (C) 1997 - 2002 Pekka Riikonen
This program 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 of the License, or
- (at your option) any later version.
-
+ the Free Software Foundation; version 2 of the License.
+
This program 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
/*
- silcutil.h
+ silcutil.h
- Author: Pekka Riikonen <priikone@poseidon.pspt.fi>
+ Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 2000 Pekka Riikonen
+ Copyright (C) 1997 - 2002 Pekka Riikonen
This program 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 of the License, or
- (at your option) any later version.
-
+ the Free Software Foundation; version 2 of the License.
+
This program 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