if (client) {
silc_server_remove_from_channels(server, NULL, client, TRUE,
NULL, TRUE);
+ silc_idlist_del_data(client);
silc_idlist_del_client(server->global_list, client);
}
silc_free(client_id);
client = silc_idlist_add_client(server->global_list, nick,
strdup(username),
strdup(realname), client_id,
- cmd->sock->user_data, NULL,
- time(NULL) + 300);
+ cmd->sock->user_data, NULL, 0);
if (!client) {
SILC_LOG_ERROR(("Could not add new client to the ID Cache"));
return FALSE;
/* Create new cache entry */
silc_idcache_add(global ? server->global_list->clients :
server->local_list->clients, nick, client->id,
- client, 0, &cache);
+ client, 0, NULL);
silc_free(client_id);
}
silc_server_save_user_channels(server, cmd->sock, client, NULL, NULL);
}
- if (cache)
- /* 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))
+ /* If client is global and is not on any channel then add that we'll
+ expire the entry after a while. */
+ if (global) {
+ silc_idlist_find_client_by_id(server->global_list, client->id,
+ FALSE, &cache);
+ if (!silc_hash_table_count(client->channels))
cache->expire = time(NULL) + 300;
+ else
+ cache->expire = 0;
+ }
}
if (fingerprint && flen == sizeof(client->data.fingerprint))
client, 0, NULL);
}
+ /* If client is global and is not on any channel then add that we'll
+ expire the entry after a while. */
+ if (global) {
+ silc_idlist_find_client_by_id(server->global_list, client->id,
+ FALSE, &cache);
+ if (!silc_hash_table_count(client->channels))
+ cache->expire = SILC_ID_CACHE_EXPIRE_DEF;
+ else
+ cache->expire = 0;
+ }
+
silc_free(client_id);
return TRUE;
global. */
client = silc_idlist_add_client(server->global_list, nick,
info ? strdup(info) : NULL, NULL,
- client_id, cmd->sock->user_data, NULL,
- time(NULL) + 300);
+ 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, expire, NULL);
}
+ /* If client is global and is not on any channel then add that we'll
+ expire the entry after a while. */
+ if (global && server->server_type == SILC_SERVER) {
+ SilcIDCacheEntry cache = NULL;
+ silc_idlist_find_client_by_id(server->global_list, client->id,
+ FALSE, &cache);
+ if (!silc_hash_table_count(client->channels))
+ cache->expire = time(NULL) + 300;
+ else
+ cache->expire = 0;
+ }
+
silc_free(client_id);
}
/* We don't have that server anywhere, add it. */
server_entry = silc_idlist_add_server(server->global_list,
strdup(name), 0,
- server_id, NULL, NULL);
+ server_id, server->router,
+ SILC_PRIMARY_ROUTE(server));
if (!server_entry) {
silc_free(server_id);
goto error;
if (server->server_type != SILC_SERVER)
goto error;
- /* We don't have that server anywhere, add it. */
+ /* We don't have that channel anywhere, add it. */
channel = silc_idlist_add_channel(server->global_list, strdup(name),
SILC_CHANNEL_MODE_NONE, channel_id,
server->router, NULL, NULL, 0);
/* Add the server to global list */
server_id = silc_id_dup(server_id, SILC_ID_SERVER);
entry = silc_idlist_add_server(server->global_list, name, 0,
- server_id, NULL, NULL);
+ server_id, cmd->sock->user_data,
+ cmd->sock);
if (!entry) {
silc_free(server_id);
goto out;
goto out;
}
server->stat.my_channels++;
+ server->stat.channels++;
} else {
/* The entry exists. */
goto out;
idp = silc_id_payload_encode(channel_id, SILC_ID_CHANNEL);
- silc_server_send_command(server, server->router->connection,
+ silc_server_send_command(server, SILC_PRIMARY_ROUTE(server),
SILC_COMMAND_IDENTIFY, ++server->cmd_ident,
1, 5, idp->data, idp->len);
silc_buffer_free(idp);