char global = FALSE;
char *nick;
uint32 mode = 0, len, id_len, flen;
+ int expire = 0;
id_data = silc_argument_get_arg_type(cmd->args, 2, &id_len);
nickname = silc_argument_get_arg_type(cmd->args, 3, &len);
client = silc_idlist_add_client(server->global_list, nick,
strdup(username),
strdup(realname), client_id,
- cmd->sock->user_data, NULL);
+ cmd->sock->user_data, NULL,
+ time(NULL) + 300);
if (!client) {
SILC_LOG_ERROR(("Could not add new client to the ID Cache"));
return FALSE;
client->data.status |= SILC_IDLIST_STATUS_RESOLVED;
client->data.status &= ~SILC_IDLIST_STATUS_RESOLVING;
+ /* If client is global and is not on any channel then add that we'll
+ expire the entry after a while. */
+ if (global && !silc_hash_table_count(client->channels) &&
+ server->server_type == SILC_SERVER)
+ expire = time(NULL) + 300;
+
/* Create new cache entry */
silc_idcache_add(global ? server->global_list->clients :
server->local_list->clients, nick, client->id,
- client, FALSE);
+ client, expire, NULL);
silc_free(client_id);
}
SILC_SERVER_CMD_REPLY_FUNC(whois)
{
SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
+ SilcServer server = cmd->server;
SilcCommandStatus status;
COMMAND_CHECK_STATUS_LIST;
}
out:
+ /* If we received notify for invalid ID we'll remove the ID if we
+ have it cached. */
+ if (status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID &&
+ cmd->sock->type == SILC_SOCKET_TYPE_ROUTER) {
+ SilcClientEntry client;
+ uint32 tmp_len;
+ unsigned char *tmp = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
+ if (tmp) {
+ SilcClientID *client_id = silc_id_payload_parse_id(tmp, tmp_len);
+ if (client_id) {
+ SILC_LOG_DEBUG(("Received invalid client ID notification, deleting "
+ "the entry from cache"));
+ client = silc_idlist_find_client_by_id(server->global_list,
+ client_id, FALSE, NULL);
+ if (client)
+ silc_idlist_del_client(server->global_list, client);
+ silc_free(client_id);
+ }
+ }
+ }
+
SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_WHOIS);
SILC_SERVER_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_WHOIS);
silc_server_command_reply_free(cmd);
client = silc_idlist_add_client(server->global_list, nick,
strdup(username), strdup(realname),
silc_id_dup(client_id, SILC_ID_CLIENT),
- cmd->sock->user_data, NULL);
+ cmd->sock->user_data, NULL,
+ SILC_ID_CACHE_EXPIRE_DEF);
if (!client) {
SILC_LOG_ERROR(("Could not add new client to the ID Cache"));
return FALSE;
}
client->data.status &= ~SILC_IDLIST_STATUS_REGISTERED;
- client = silc_idlist_find_client_by_id(server->global_list,
- client_id, TRUE, &cache);
- cache->expire = SILC_ID_CACHE_EXPIRE_DEF;
client->servername = servername;
} else {
/* We have the client already, update the data */
server->local_list->clients, client);
silc_idcache_add(global ? server->global_list->clients :
server->local_list->clients, nick, client->id,
- client, FALSE);
+ client, 0, NULL);
}
silc_free(client_id);
char *nick = NULL;
SilcIDPayload idp = NULL;
SilcIdType id_type;
+ int expire = 0;
id_data = silc_argument_get_arg_type(cmd->args, 2, &id_len);
if (!id_data)
global. */
client = silc_idlist_add_client(server->global_list, nick,
info ? strdup(info) : NULL, NULL,
- client_id, cmd->sock->user_data, NULL);
+ client_id, cmd->sock->user_data, NULL,
+ time(NULL) + 300);
if (!client) {
SILC_LOG_ERROR(("Could not add new client to the ID Cache"));
goto error;
client->data.status &= ~SILC_IDLIST_STATUS_RESOLVING;
if (name) {
+ /* If client is global and is not on any channel then add that we'll
+ expire the entry after a while. */
+ if (global && !silc_hash_table_count(client->channels) &&
+ server->server_type == SILC_SERVER)
+ expire = time(NULL) + 300;
+
/* Add new cache entry */
silc_idcache_add(global ? server->global_list->clients :
server->local_list->clients, nick, client->id,
- client, FALSE);
+ client, expire, NULL);
}
silc_free(client_id);
/* We don't have that server anywhere, add it. */
channel = silc_idlist_add_channel(server->global_list, strdup(name),
SILC_CHANNEL_MODE_NONE, channel_id,
- server->router,
- NULL, NULL);
+ server->router, NULL, NULL, 0);
if (!channel) {
silc_free(channel_id);
goto error;
SILC_SERVER_CMD_REPLY_FUNC(identify)
{
SilcServerCommandReplyContext cmd = (SilcServerCommandReplyContext)context;
+ SilcServer server = cmd->server;
SilcCommandStatus status;
COMMAND_CHECK_STATUS_LIST;
}
out:
+ /* If we received notify for invalid ID we'll remove the ID if we
+ have it cached. */
+ if (status == SILC_STATUS_ERR_NO_SUCH_CLIENT_ID &&
+ cmd->sock->type == SILC_SOCKET_TYPE_ROUTER) {
+ SilcClientEntry client;
+ uint32 tmp_len;
+ unsigned char *tmp = silc_argument_get_arg_type(cmd->args, 2, &tmp_len);
+ if (tmp) {
+ SilcClientID *client_id = silc_id_payload_parse_id(tmp, tmp_len);
+ if (client_id) {
+ SILC_LOG_DEBUG(("Received invalid client ID notification, deleting "
+ "the entry from cache"));
+ client = silc_idlist_find_client_by_id(server->global_list,
+ client_id, FALSE, NULL);
+ if (client)
+ silc_idlist_del_client(server->global_list, client);
+ silc_free(client_id);
+ }
+ }
+ }
+
SILC_SERVER_PENDING_EXEC(cmd, SILC_COMMAND_IDENTIFY);
SILC_SERVER_PENDING_DESTRUCTOR(cmd, SILC_COMMAND_IDENTIFY);
silc_server_command_reply_free(cmd);
/* Add the channel to our local list. */
entry = silc_idlist_add_channel(server->local_list, strdup(channel_name),
SILC_CHANNEL_MODE_NONE, id,
- server->router, NULL, hmac);
+ server->router, NULL, hmac, 0);
if (!entry) {
silc_free(id);
goto out;
uint32 len;
unsigned char *tmp, *name, *topic;
uint32 usercount = 0;
+ bool global_list = FALSE;
COMMAND_CHECK_STATUS_LIST;
/* Add the channel entry if we do not have it already */
channel = silc_idlist_find_channel_by_name(server->local_list,
name, &cache);
- if (!channel)
+ if (!channel) {
channel = silc_idlist_find_channel_by_name(server->global_list,
name, &cache);
+ global_list = TRUE;
+ }
if (!channel) {
/* If router did not find such channel in its lists then this must
be bogus channel or some router in the net is buggy. */
channel = silc_idlist_add_channel(server->global_list, strdup(name),
SILC_CHANNEL_MODE_NONE, channel_id,
- server->router, NULL, NULL);
+ server->router, NULL, NULL,
+ time(NULL) + 60);
if (!channel)
goto out;
-
- /* Update cache entry expiry */
- if (silc_idlist_find_channel_by_id(server->global_list, channel_id,
- &cache))
- cache->expire = time(NULL) + 60;
-
channel_id = NULL;
} else {
/* Found, update expiry */
- cache->expire = time(NULL) + 60;
+ if (global_list && server->server_type == SILC_SERVER)
+ cache->expire = time(NULL) + 60;
}
if (topic) {