Affected files are lib/silccore/silcnotify.c and
silcargument.c.
+ * Fixed SILC_PACKET_FLAG_LONG_PAD bitmask value. Affected
+ file lib/silccore/silcpacket.h.
+
Sat Jun 30 21:48:08 EEST 2007 Pekka Riikonen <priikone@silcnet.org>
* Set the destination ID to packet stream as SKE responder
channel = silc_server_create_new_channel(server, server->id, cipher,
hmac, channel_name, TRUE);
if (!channel) {
- silc_server_command_send_status_data(
- cmd, SILC_COMMAND_JOIN,
- SILC_STATUS_ERR_UNKNOWN_ALGORITHM,
- 0, 2, cipher, strlen(cipher));
+ if (cipher) {
+ silc_server_command_send_status_data(
+ cmd, SILC_COMMAND_JOIN,
+ SILC_STATUS_ERR_UNKNOWN_ALGORITHM,
+ 0, 2, cipher, strlen(cipher));
+ } else if (hmac) {
+ silc_server_command_send_status_data(
+ cmd, SILC_COMMAND_JOIN,
+ SILC_STATUS_ERR_UNKNOWN_ALGORITHM,
+ 0, 2, hmac, strlen(hmac));
+ } else {
+ silc_server_command_send_status_reply(
+ cmd, SILC_COMMAND_JOIN,
+ SILC_STATUS_ERR_RESOURCE_LIMIT,
+ 0);
+ }
goto out;
}
channel = silc_server_create_new_channel(server, server->id, cipher,
hmac, channel_name, TRUE);
if (!channel) {
- silc_server_command_send_status_data(
- cmd, SILC_COMMAND_JOIN,
- SILC_STATUS_ERR_UNKNOWN_ALGORITHM, 0,
- 2, cipher, strlen(cipher));
+ if (cipher) {
+ silc_server_command_send_status_data(
+ cmd, SILC_COMMAND_JOIN,
+ SILC_STATUS_ERR_UNKNOWN_ALGORITHM,
+ 0, 2, cipher, strlen(cipher));
+ } else if (hmac) {
+ silc_server_command_send_status_data(
+ cmd, SILC_COMMAND_JOIN,
+ SILC_STATUS_ERR_UNKNOWN_ALGORITHM,
+ 0, 2, hmac, strlen(hmac));
+ } else {
+ silc_server_command_send_status_reply(
+ cmd, SILC_COMMAND_JOIN,
+ SILC_STATUS_ERR_RESOURCE_LIMIT,
+ 0);
+ }
goto out;
}
channel = silc_server_create_new_channel(server, server->id, cipher,
hmac, channel_name, TRUE);
if (!channel) {
- silc_server_command_send_status_data(
- cmd, SILC_COMMAND_JOIN,
- SILC_STATUS_ERR_UNKNOWN_ALGORITHM, 0,
- 2, cipher, strlen(cipher));
+ if (cipher) {
+ silc_server_command_send_status_data(
+ cmd, SILC_COMMAND_JOIN,
+ SILC_STATUS_ERR_UNKNOWN_ALGORITHM,
+ 0, 2, cipher, strlen(cipher));
+ } else if (hmac) {
+ silc_server_command_send_status_data(
+ cmd, SILC_COMMAND_JOIN,
+ SILC_STATUS_ERR_UNKNOWN_ALGORITHM,
+ 0, 2, hmac, strlen(hmac));
+ } else {
+ silc_server_command_send_status_reply(
+ cmd, SILC_COMMAND_JOIN,
+ SILC_STATUS_ERR_RESOURCE_LIMIT,
+ 0);
+ }
goto out;
}
username = silc_identifier_check(username, tmp_len, SILC_STRING_UTF8, 128,
&tmp_len);
if (!username) {
- silc_server_command_send_status_reply(cmd, SILC_COMMAND_OPER,
+ silc_server_command_send_status_reply(cmd, SILC_COMMAND_SILCOPER,
SILC_STATUS_ERR_BAD_USERNAME,
0);
goto out;
}
if (!result) {
/* Authentication failed */
- silc_server_command_send_status_reply(cmd, SILC_COMMAND_OPER,
+ silc_server_command_send_status_reply(cmd, SILC_COMMAND_SILCOPER,
SILC_STATUS_ERR_AUTH_FAILED, 0);
goto out;
}
client = (SilcClientEntry)id_cache->context;
- /* Remove the old entry and add a new one */
-
- if (!silc_idcache_del_by_context(id_list->clients, client, server))
- return NULL;
-
/* Check if anyone is watching old nickname */
if (server->server_type == SILC_ROUTER)
silc_server_check_watcher_list(server, client, nickname,
SILC_NOTIFY_TYPE_NICK_CHANGE);
+ /* Replace */
+ if (!silc_idcache_update(id_list->clients, id_cache, new_id, nicknamec,
+ TRUE))
+ return NULL;
+
silc_free(client->nickname);
- *client->id = *new_id;
client->nickname = nickname ? strdup(nickname) : NULL;
/* Check if anyone is watching new nickname */
silc_server_check_watcher_list(server, client, nickname,
SILC_NOTIFY_TYPE_NICK_CHANGE);
- if (!silc_idcache_add(id_list->clients, nicknamec, client->id,
- client))
- return NULL;
-
SILC_LOG_DEBUG(("Replaced"));
return client;
SilcUInt32 tmp_len, tmp2_len;
SilcBool local, ret;
- if (idata->conn_type == SILC_CONN_CLIENT ||
- packet->src_id_type != SILC_ID_SERVER || !packet->dst_id) {
+ if (idata->conn_type == SILC_CONN_CLIENT) {
+ SILC_LOG_DEBUG(("Notify received from client, drop it"));
+ return;
+ }
+
+ if (packet->src_id_type != SILC_ID_SERVER){
+ SILC_LOG_DEBUG(("Bad notify packet received"));
+ return;
+ }
+
+ if (!packet->dst_id) {
SILC_LOG_DEBUG(("Bad notify packet received"));
return;
}
/* Parse the Notify Payload */
payload = silc_notify_payload_parse(buffer->data, silc_buffer_len(buffer));
- if (!payload)
+ if (!payload) {
+ SILC_LOG_DEBUG(("Marlformed notify payload"));
return;
+ }
/* If we are router and this packet is not already broadcast packet
we will broadcast it. The sending socket really cannot be router or
/* Packet is destined to channel */
if (!silc_id_str2id(packet->dst_id, packet->dst_id_len,
packet->dst_id_type, &channel_id,
- sizeof(channel_id)))
+ sizeof(channel_id))) {
+ SILC_LOG_DEBUG(("Malformed destination ID in notify packet"));
goto out;
+ }
silc_server_packet_send_dest(server, SILC_PRIMARY_ROUTE(server),
packet->type, packet->flags |
type = silc_notify_get_type(payload);
args = silc_notify_get_args(payload);
- if (!args)
+ if (!args) {
+ SILC_LOG_DEBUG(("Notify doesn't have any arguments, drop it"));
goto out;
+ }
switch(type) {
case SILC_NOTIFY_TYPE_JOIN:
channel = silc_idlist_find_channel_by_id(server->local_list,
SILC_ID_GET_ID(id), NULL);
if (!channel) {
- SILC_LOG_DEBUG(("Notify for unknown channel"));
+ SILC_LOG_DEBUG(("Notify for unknown channel %s",
+ silc_id_render(SILC_ID_GET_ID(id), SILC_ID_CHANNEL)));
goto out;
}
}
channel = silc_idlist_find_channel_by_id(server->local_list,
&channel_id, NULL);
if (!channel) {
- SILC_LOG_DEBUG(("Notify for unknown channel"));
+ SILC_LOG_DEBUG(("Notify for unknown channel %s",
+ silc_id_render(&channel_id, SILC_ID_CHANNEL)));
goto out;
}
}
channel = silc_idlist_find_channel_by_id(server->local_list,
&channel_id, NULL);
if (!channel) {
- SILC_LOG_DEBUG(("Notify for unknown channel"));
+ SILC_LOG_DEBUG(("Notify for unknown channel %s",
+ silc_id_render(&channel_id, SILC_ID_CHANNEL)));
goto out;
}
}
channel = silc_idlist_find_channel_by_id(server->local_list,
&channel_id, NULL);
if (!channel) {
- SILC_LOG_DEBUG(("Notify for unknown channel"));
+ SILC_LOG_DEBUG(("Notify for unknown channel %s",
+ silc_id_render(&channel_id, SILC_ID_CHANNEL)));
goto out;
}
}
channel = silc_idlist_find_channel_by_id(server->local_list,
&channel_id, NULL);
if (!channel) {
- SILC_LOG_DEBUG(("Notify for unknown channel"));
+ SILC_LOG_DEBUG(("Notify for unknown channel %s",
+ silc_id_render(&channel_id, SILC_ID_CHANNEL)));
goto out;
}
}
channel = silc_idlist_find_channel_by_id(server->local_list,
SILC_ID_GET_ID(id), NULL);
if (!channel) {
- SILC_LOG_DEBUG(("Notify for unknown channel"));
+ SILC_LOG_DEBUG(("Notify for unknown channel %s",
+ silc_id_render(SILC_ID_GET_ID(id), SILC_ID_CHANNEL)));
goto out;
}
}
channel = silc_idlist_find_channel_by_id(server->global_list,
SILC_ID_GET_ID(id), NULL);
if (!channel) {
- SILC_LOG_DEBUG(("Notify for unknown channel"));
+ SILC_LOG_DEBUG(("Notify for unknown channel %s",
+ silc_id_render(SILC_ID_GET_ID(id), SILC_ID_CHANNEL)));
goto out;
}
}
/* Get client entry */
client = silc_idlist_find_client_by_id(server->global_list,
- SILC_ID_GET_ID(id),
+ SILC_ID_GET_ID(id2),
TRUE, &cache);
local = FALSE;
if (!client) {
client = silc_idlist_find_client_by_id(server->local_list,
- SILC_ID_GET_ID(id),
+ SILC_ID_GET_ID(id2),
TRUE, &cache);
local = TRUE;
if (!client)
channel = silc_idlist_find_channel_by_id(server->local_list,
&channel_id, NULL);
if (!channel) {
- SILC_LOG_DEBUG(("Notify for unknown channel"));
+ SILC_LOG_DEBUG(("Notify for unknown channel %s",
+ silc_id_render(SILC_ID_GET_ID(id), SILC_ID_CHANNEL)));
goto out;
}
}
channel = silc_idlist_find_channel_by_id(server->local_list,
SILC_ID_GET_ID(id), NULL);
if (!channel) {
- SILC_LOG_DEBUG(("Notify for unknown channel"));
+ SILC_LOG_DEBUG(("Notify for unknown channel %s",
+ silc_id_render(SILC_ID_GET_ID(id), SILC_ID_CHANNEL)));
goto out;
}
}
break;
default:
+ SILC_LOG_DEBUG(("Unsupported notify %d", type));
break;
}
/* As a router we keep information of all global information in our
global list. Cell wide information however is kept in the local
list. */
- entry = silc_idlist_add_server(id_list, NULL, 0, &id, router,
+ entry = silc_idlist_add_server(id_list, NULL, 0,
+ silc_id_dup(&id, SILC_ID_SERVER), router,
router_sock);
if (!entry) {
SILC_LOG_ERROR(("Could not add new server to the ID Cache"));
}
/* Create the channel with the provided Channel ID */
- channel = silc_server_create_new_channel_with_id(server, NULL, NULL,
- channel_name,
- &channel_id, FALSE);
+ channel =
+ silc_server_create_new_channel_with_id(
+ server, NULL, NULL,
+ channel_name,
+ silc_id_dup(&channel_id, SILC_ID_CHANNEL),
+ FALSE);
if (!channel) {
silc_channel_payload_free(payload);
return;
SILC_TASK_CALLBACK(silc_server_get_stats);
SILC_TASK_CALLBACK(silc_server_connect_router);
+SILC_TASK_CALLBACK(silc_server_connect_to_router_retry);
SILC_TASK_CALLBACK(silc_server_do_rekey);
SILC_TASK_CALLBACK(silc_server_purge_expired_clients);
static void silc_server_accept_new_connection(SilcNetStatus status,
the ID list. */
id_entry =
silc_idlist_add_server(server->local_list, strdup(server->server_name),
- server->server_type, server->id, NULL, NULL);
+ server->server_type,
+ silc_id_dup(server->id, SILC_ID_SERVER),
+ NULL, NULL);
if (!id_entry) {
SILC_LOG_ERROR(("Could not add local server to cache"));
goto err;
}
id_entry->data.status |= SILC_IDLIST_STATUS_REGISTERED;
+ id_entry->data.conn_type = (server->server_type == SILC_SERVER ?
+ SILC_CONN_SERVER : SILC_CONN_ROUTER);
server->id_entry = id_entry;
/* Create secondary TCP listeners */
silc_server_free_sock_user_data(server, ps,
"Server is shutting down");
}
- silc_dlist_uninit(list);
+ silc_packet_engine_free_streams_list(list);
}
/* We are not connected to network anymore */
silc_server_http_uninit(server);
+ /* Cancel any possible retry timeouts */
+ silc_schedule_task_del_by_callback(server->schedule,
+ silc_server_connect_router);
+ silc_schedule_task_del_by_callback(server->schedule,
+ silc_server_connect_to_router_retry);
+
silc_schedule_stop(server->schedule);
SILC_LOG_DEBUG(("Server stopped"));
SILC_STATUS_ERR_AUTH_FAILED, NULL);
if (sconn->callback)
(*sconn->callback)(server, NULL, sconn->callback_context);
+ silc_server_connection_free(sconn);
return;
}
silc_server_backup_add(server, server->id_entry, ip,
sconn->remote_port, TRUE);
}
+#if 0
} else {
/* We already have primary router. Disconnect this connection */
SILC_LOG_DEBUG(("We already have primary router, disconnect"));
silc_server_connection_free(sconn);
silc_free(entry);
return;
+#endif /* 0 */
}
} else {
/* Add this server to be our backup router */
if (sconn && sconn->callback)
(*sconn->callback)(server, id_entry, sconn->callback_context);
- /* Free the temporary connection data context */
- if (sconn) {
- silc_server_config_unref(&sconn->conn);
- silc_free(sconn->remote_host);
- silc_free(sconn->backup_replace_ip);
- silc_free(sconn);
- }
if (sconn == server->router_conn)
server->router_conn = NULL;
}
}
+ entry->data.rekey = rekey;
+
/* Start connection authentication */
sconn->op =
- silc_connauth_initiator(connauth, server->server_type == SILC_ROUTER ?
- SILC_CONN_ROUTER : SILC_CONN_SERVER, auth_meth,
+ silc_connauth_initiator(connauth, server->server_type == SILC_SERVER ?
+ SILC_CONN_SERVER : SILC_CONN_ROUTER, auth_meth,
auth_data, auth_data_len,
silc_server_ke_auth_compl, sconn);
}
silc_schedule_task_add_timeout(sconn->server->schedule,
silc_server_connect_to_router_retry,
sconn, 1, 0);
+ silc_dlist_del(server->conns, sconn);
} else {
if (sconn->callback)
(*sconn->callback)(server, NULL, sconn->callback_context);
"normal server" : server->server_type == SILC_ROUTER ?
"router" : "backup router/normal server")));
- /* XXX */
if (!server->config->routers) {
/* There wasn't a configured router, we will continue but we don't
have a connection to outside world. We will be standalone server. */
return;
}
+ /* Cancel any possible retry timeouts */
+ silc_schedule_task_del_by_callback(server->schedule,
+ silc_server_connect_router);
+ silc_schedule_task_del_by_callback(server->schedule,
+ silc_server_connect_to_router_retry);
+
/* Create the connections to all our routes */
for (ptr = server->config->routers; ptr; ptr = ptr->next) {
sconn = silc_calloc(1, sizeof(*sconn));
if (!sconn)
continue;
+ sconn->server = server;
sconn->remote_host = strdup(ptr->host);
sconn->remote_port = ptr->port;
sconn->backup = ptr->backup_router;
SILC_LOG_DEBUG(("Created connection %p", sconn));
- /* XXX */
if (!server->router_conn && !sconn->backup)
server->router_conn = sconn;
if (entry->data.conn_type == SILC_CONN_SERVER) {
server->stat.my_servers++;
server->stat.servers++;
+ SILC_LOG_DEBUG(("my_servers %d", server->stat.my_servers));
} else {
server->stat.my_routers++;
server->stat.routers++;
+ SILC_LOG_DEBUG(("my_routers %d", server->stat.my_routers));
}
/* Check whether this connection is to be our primary router connection
SILC_CONNTYPE_STRING(idata->conn_type)));
/* Allocate SKE */
- ske = silc_ske_alloc(server->rng, server->schedule, server->repository,
- server->public_key, server->private_key, sock);
+ ske = silc_ske_alloc(server->rng, server->schedule, NULL,
+ server->public_key, NULL, sock);
if (!ske)
return;
SILC_CONNTYPE_STRING(idata->conn_type)));
/* Allocate SKE */
- ske = silc_ske_alloc(server->rng, server->schedule, server->repository,
- server->public_key, server->private_key, sock);
+ ske = silc_ske_alloc(server->rng, server->schedule, NULL,
+ server->public_key, NULL, sock);
if (!ske) {
silc_packet_free(packet);
return;
if (idata->sconn)
silc_server_connection_free(idata->sconn);
- /* Free the server entry */
- silc_server_backup_del(server, user_data);
- silc_server_backup_replaced_del(server, user_data);
- silc_idlist_del_data(user_data);
- if (!silc_idlist_del_server(server->local_list, user_data))
- silc_idlist_del_server(server->global_list, user_data);
+ /* Statistics */
if (idata->conn_type == SILC_CONN_SERVER) {
server->stat.my_servers--;
server->stat.servers--;
- } else {
+ SILC_LOG_DEBUG(("my_servers %d", server->stat.my_servers));
+ } else if (idata->conn_type == SILC_CONN_ROUTER) {
server->stat.my_routers--;
server->stat.routers--;
+ SILC_LOG_DEBUG(("my_routers %d", server->stat.my_routers));
}
if (server->server_type == SILC_ROUTER)
server->stat.cell_servers--;
+ /* Free the server entry */
+ silc_server_backup_del(server, user_data);
+ silc_server_backup_replaced_del(server, user_data);
+ silc_idlist_del_data(user_data);
+ if (!silc_idlist_del_server(server->local_list, user_data))
+ silc_idlist_del_server(server->global_list, user_data);
+
if (backup_router && backup_router != server->id_entry) {
/* Announce all of our stuff that was created about 5 minutes ago.
The backup router knows all the other stuff already. */
if (!client->connection && !client->router)
continue;
+ SILC_LOG_DEBUG(("Announce Client ID %s",
+ silc_id_render(client->id, SILC_ID_CLIENT)));
+
idp = silc_id_payload_encode(client->id, SILC_ID_CLIENT);
*clients = silc_buffer_realloc(*clients,
while (silc_hash_table_get(&htl, NULL, (void *)&chl)) {
clidp = silc_id_payload_encode(chl->client->id, SILC_ID_CLIENT);
+ SILC_LOG_DEBUG(("JOIN Client %s", silc_id_render(chl->client->id,
+ SILC_ID_CLIENT)));
+
/* JOIN Notify */
tmp = silc_server_announce_encode_notify(SILC_NOTIFY_TYPE_JOIN, 2,
clidp->data,
else
announce = TRUE;
+ SILC_LOG_DEBUG(("Announce Channel ID %s",
+ silc_id_render(channel->id, SILC_ID_CHANNEL)));
+
silc_id_id2str(channel->id, SILC_ID_CHANNEL, cid, sizeof(cid), &id_len);
name_len = strlen(channel->channel_name);
/* Assembles user list and users mode list from the `channel'. */
SilcBool silc_server_get_users_on_channel(SilcServer server,
- SilcChannelEntry channel,
- SilcBuffer *user_list,
- SilcBuffer *mode_list,
- SilcUInt32 *user_count)
+ SilcChannelEntry channel,
+ SilcBuffer *user_list,
+ SilcBuffer *mode_list,
+ SilcUInt32 *user_count)
{
SilcChannelClientEntry chl;
SilcHashTableList htl;
}
SILC_LOG_DEBUG(("Backup router %s will replace %s",
- backup_server->data.sconn->remote_host, ip, port));
+ backup_server->data.sconn ?
+ backup_server->data.sconn->remote_host : "(me)", ip));
for (i = 0; i < server->backup->servers_count; i++) {
if (!server->backup->servers[i].server) {
/* The primary is not down, refuse to serve the server as primary */
SILC_LOG_DEBUG(("PING received, primary is up"));
silc_server_backup_send_start_use(pc->server, pc->sock, TRUE);
+ silc_packet_free(pc->packet);
}
silc_packet_stream_unref(pc->sock);
- silc_packet_free(pc->packet);
silc_free(pc);
}
/* Try again */
silc_schedule_task_add_timeout(server->schedule,
silc_server_backup_connected_again,
- context, 0, 1);
+ context, 5, 0);
return;
}
if (sock == ctx->sock)
continue;
- send_to_backup:
+ server_entry = silc_packet_get_context(sock);
server_entry->data.status &= ~SILC_IDLIST_STATUS_DISABLED;
SILC_LOG_DEBUG(("Sending RESUMED to %s", server_entry->server_name));
silc_server_packet_send(server, sock, SILC_PACKET_RESUME_ROUTER, 0,
data, sizeof(data));
}
- silc_packet_engine_free_streams_list(list);
/* Now send the same packet to backup */
if (sock != ctx->sock) {
sleep(1);
sock = ctx->sock;
- goto send_to_backup;
+ server_entry = silc_packet_get_context(sock);
+ server_entry->data.status &= ~SILC_IDLIST_STATUS_DISABLED;
+
+ SILC_LOG_DEBUG(("Sending RESUMED to %s", server_entry->server_name));
+ SILC_LOG_INFO(("Sending RESUMED to %s", server_entry->server_name));
+
+ /* This connection is performing this protocol too now */
+ server_entry->backup = TRUE;
+ server_entry->backup_proto = ctx;
+
+ data[0] = SILC_SERVER_BACKUP_RESUMED;
+ data[1] = 0;
+ silc_server_packet_send(server, sock, SILC_PACKET_RESUME_ROUTER, 0,
+ data, sizeof(data));
}
+ silc_packet_engine_free_streams_list(list);
/* We are now resumed and are back as primary router in the cell. */
SILC_LOG_INFO(("We are now the primary router of our cell again"));
/* For us this is the end of this protocol. */
silc_schedule_task_add_timeout(server->schedule,
silc_server_protocol_backup_done,
- ctx->sock, 0, 1);
+ ctx, 0, 1);
}
break;
/* Protocol has ended, call the final callback */
silc_schedule_task_add_timeout(server->schedule,
silc_server_protocol_backup_done,
- ctx->sock, 0, 1);
+ ctx, 0, 1);
}
break;
/* Protocol has ended, call the final callback */
silc_schedule_task_add_timeout(server->schedule,
silc_server_protocol_backup_done,
- ctx->sock, 0, 1);
+ ctx, 0, 1);
break;
case 252:
ctx->received_failure = TRUE;
silc_schedule_task_add_timeout(server->schedule,
silc_server_protocol_backup_done,
- ctx->sock, 0, 1);
+ ctx, 0, 1);
break;
default:
if (ctx->sock) {
SilcServerEntry r = silc_packet_get_context(ctx->sock);
- r->backup = FALSE;
- r->backup_proto = NULL;
+ if (r) {
+ r->backup = FALSE;
+ r->backup_proto = NULL;
+ }
silc_packet_stream_unref(ctx->sock);
}
silc_free(ctx->sessions);
if (server_signoff) {
idp = silc_id_payload_encode(entry->id, SILC_ID_SERVER);
- if (idp) {
- argv = silc_realloc(argv, sizeof(*argv) * (argc + 1));
- argv_lens = silc_realloc(argv_lens, sizeof(*argv_lens) * (argc + 1));
- argv_types = silc_realloc(argv_types, sizeof(*argv_types) * (argc + 1));
- argv[argc] = silc_calloc(silc_buffer_len(idp), sizeof(*argv[0]));
- memcpy(argv[argc], idp->data, silc_buffer_len(idp));
- argv_lens[argc] = silc_buffer_len(idp);
- argv_types[argc] = argc + 1;
- argc++;
- silc_buffer_free(idp);
- }
+ argv = silc_realloc(argv, sizeof(*argv) * (argc + 1));
+ argv_lens = silc_realloc(argv_lens, sizeof(*argv_lens) * (argc + 1));
+ argv_types = silc_realloc(argv_types, sizeof(*argv_types) * (argc + 1));
+ argv[argc] = silc_calloc(silc_buffer_len(idp), sizeof(*argv[0]));
+ memcpy(argv[argc], idp->data, silc_buffer_len(idp));
+ argv_lens[argc] = silc_buffer_len(idp);
+ argv_types[argc] = argc + 1;
+ argc++;
+ silc_buffer_free(idp);
}
if (silc_idcache_get_all(server->local_list->clients, &list)) {
since the server is local. */
if (!local) {
SILC_LOG_DEBUG(("Moving client to local list"));
- silc_idcache_add(server->local_list->clients, client_cache->name,
- client_cache->id, client_cache->context);
- silc_idcache_del_by_context(server->global_list->clients, client,
- NULL);
+ silc_idcache_move(server->global_list->clients,
+ server->local_list->clients, client_cache);
}
server_entry = server_entry->router;
} else {
since the server is local. */
if (server_entry->server_type != SILC_BACKUP_ROUTER && !local) {
SILC_LOG_DEBUG(("Moving client to local list"));
- silc_idcache_add(server->local_list->clients, client_cache->name,
- client_cache->id, client_cache->context);
- silc_idcache_del_by_context(server->global_list->clients, client,
- NULL);
+ silc_idcache_move(server->global_list->clients,
+ server->local_list->clients, client_cache);
} else if (server->server_type == SILC_BACKUP_ROUTER && local) {
/* If we are backup router and this client is on local list, we
must move it to global list, as it is not currently local to
us (we are not primary). */
SILC_LOG_DEBUG(("Moving client to global list"));
- silc_idcache_add(server->global_list->clients, client_cache->name,
- client_cache->id, client_cache->context);
- silc_idcache_del_by_context(server->local_list->clients, client,
- NULL);
+ silc_idcache_move(server->local_list->clients,
+ server->global_list->clients, client_cache);
}
}
since the server is global. */
if (local) {
SILC_LOG_DEBUG(("Moving client to global list"));
- silc_idcache_add(server->global_list->clients, client_cache->name,
- client_cache->id, client_cache->context);
- silc_idcache_del_by_context(server->local_list->clients, client,
- NULL);
+ silc_idcache_move(server->local_list->clients,
+ server->global_list->clients, client_cache);
}
server_entry = server_entry->router;
} else {
since the server is global. */
if (server_entry->server_type != SILC_BACKUP_ROUTER && local) {
SILC_LOG_DEBUG(("Moving client to global list"));
- silc_idcache_add(server->global_list->clients, client_cache->name,
- client_cache->id, client_cache->context);
- silc_idcache_del_by_context(server->local_list->clients, client,
- NULL);
+ silc_idcache_move(server->local_list->clients,
+ server->global_list->clients, client_cache);
}
}
return server_entry;
if (!ip && !hostname)
return 0;
+ SILC_LOG_DEBUG(("Num connections %d", silc_dlist_count(server->conns)));
+
silc_dlist_start(server->conns);
while ((conn = silc_dlist_get(server->conns))) {
if (conn->sock) {
global->connections_max_per_host);
if (max_hosts && conn_number >= max_hosts) {
+ SILC_LOG_DEBUG(("Server is full, %d >= %d", conn_number, max_hosts));
SILC_LOG_INFO(("Server is full, closing %s (%s) connection",
hostname, ip));
silc_server_disconnect_remote(server, sock,
}
if (num_sockets >= max_per_host) {
+ SILC_LOG_DEBUG(("Too many connections, %d >= %d", num_sockets,
+ max_per_host));
SILC_LOG_INFO(("Too many connections from %s (%s), closing connection",
hostname, ip));
silc_server_disconnect_remote(server, sock,
silc_schedule_task_del_by_callback(server->schedule,
silc_server_connect_to_router);
silc_schedule_task_add_timeout(server->schedule,
- silc_server_connect_to_router, server, 0, 1);
+ silc_server_connect_to_router, server, 1, 0);
}
static void
ret = FALSE;
}
+ if (!config->server_info->public_key ||
+ !config->server_info->private_key) {
+ SILC_SERVER_LOG_ERROR(("\nError: Server keypair is missing"));
+ ret = FALSE;
+ }
+
+ if (!config->server_info->primary) {
+ SILC_SERVER_LOG_ERROR(("\nError: Missing mandatory block `Primary' "
+ "in `ServerInfo'"));
+ ret = FALSE;
+ }
+
+ if (!config->server_info->primary->server_ip) {
+ SILC_SERVER_LOG_ERROR(("\nError: Missing mandatory field `Ip' "
+ "in `Primary' in `ServerInfo'"));
+ ret = FALSE;
+ }
+
/* RouterConnection sanity checks */
if (config->routers && config->routers->backup_router == TRUE &&
"connection. You have marked it incorrectly as backup router."));
ret = FALSE;
}
-#if 0
- if (config->routers && config->routers->initiator == FALSE &&
- config->routers->backup_router == FALSE) {
- SILC_SERVER_LOG_ERROR((
- "\nError: First RouterConnection block must be primary router "
- "connection and it must be marked as Initiator."));
- ret = FALSE;
- }
-#endif
if (config->routers && config->routers->backup_router == TRUE &&
!config->servers && !config->routers->next) {
SILC_SERVER_LOG_ERROR((
silc_pkcs_register_default();
silc_hash_register_default();
silc_hmac_register_default();
- silc_create_key_pair(opt_pkcs, opt_bits, pubfile, prvfile,
- opt_identifier, "", NULL, NULL, FALSE);
+ if (!silc_create_key_pair(opt_pkcs, opt_bits, pubfile, prvfile,
+ opt_identifier, "", NULL, NULL, FALSE))
+ exit(1);
exit(0);
}