+Fri Jan 25 19:12:36 EET 2002 Pekka Riikonen <priikone@silcnet.org>
+
+ * Added server & router operator statistics updating. Affected
+ file silcd/packet_receive.c and silcd/command.c.
+
+ * Fixed the SERVER_SIGNOFF notify handling on normal server
+ not to save the history information for clients. Same was
+ fixed earlier in remove_clients_by_server function, but not
+ here. Affected file silcd/packet_receive.c.
+
+ * Raised the default connection-retry count from 4 to 7 in
+ server. Affected file silcd/server.h.
+
Tue Jan 22 18:19:36 EET 2002 Pekka Riikonen <priikone@silcnet.org>
* Removed assert()'s from the lib/silcclient/client_keyagr.c.
o IP address fields in configuration file should accept mask
format as well, IP/MASK, and not just plain IP.
+ o Lots of statistics updating is missing around the server.
+
o If client's public key is saved in the server (and doing public key
authentication) then the hostname and the username information could
be taken from the public key. Should be a configuration option!
@SYNTAX:sconnect@
Operator command. Makes an server to connect to another
-server or router.
+server or router. The <server> is the hostname or IP
+addres of the server.
+
+Example: /SCONNECT silc.silcnet.org 706
See also: OPER, SILCOPER, CLOSE, SHUTDOWN
SilcClientID *client_id;
unsigned char *tmp, *comment;
uint32 tmp_len, tmp_len2;
+ bool local;
SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_KILL, cmd, 1, 2);
/* Get the client entry */
remote_client = silc_idlist_find_client_by_id(server->local_list,
client_id, TRUE, NULL);
+ local = TRUE;
if (!remote_client) {
remote_client = silc_idlist_find_client_by_id(server->global_list,
client_id, TRUE, NULL);
+ local = FALSE;
if (!remote_client) {
silc_server_command_send_status_reply(cmd, SILC_COMMAND_KILL,
SILC_STATUS_ERR_NO_SUCH_CLIENT_ID);
silc_server_free_client_data(server, sock, remote_client, FALSE, NULL);
silc_server_close_connection(server, sock);
} else {
+ /* Update statistics */
+ if (remote_client->connection)
+ server->stat.my_clients--;
+ if (server->server_type == SILC_ROUTER)
+ server->stat.cell_clients--;
+ SILC_OPER_STATS_UPDATE(remote_client, server, SILC_UMODE_SERVER_OPERATOR);
+ SILC_OPER_STATS_UPDATE(remote_client, router, SILC_UMODE_ROUTER_OPERATOR);
+
/* Remove remote client */
- if (!silc_idlist_del_client(server->global_list, remote_client))
- silc_idlist_del_client(server->local_list, remote_client);
+ silc_idlist_del_client(local ? server->local_list :
+ server->global_list, remote_client);
}
out:
goto out;
}
} else {
- if (client->mode & SILC_UMODE_SERVER_OPERATOR)
- /* Remove the server operator rights */
+ /* Remove the server operator rights */
+ if (client->mode & SILC_UMODE_SERVER_OPERATOR) {
client->mode &= ~SILC_UMODE_SERVER_OPERATOR;
+ if (client->connection)
+ server->stat.my_server_ops--;
+ if (server->server_type == SILC_ROUTER)
+ server->stat.server_ops--;
+ }
}
if (mask & SILC_UMODE_ROUTER_OPERATOR) {
goto out;
}
} else {
- if (client->mode & SILC_UMODE_ROUTER_OPERATOR)
- /* Remove the router operator rights */
+ /* Remove the router operator rights */
+ if (client->mode & SILC_UMODE_ROUTER_OPERATOR) {
client->mode &= ~SILC_UMODE_ROUTER_OPERATOR;
+ if (client->connection)
+ server->stat.my_router_ops--;
+ if (server->server_type == SILC_ROUTER)
+ server->stat.router_ops--;
+ }
}
if (mask & SILC_UMODE_GONE) {
/* Client is now server operator */
client->mode |= SILC_UMODE_SERVER_OPERATOR;
+ /* Update statistics */
+ if (client->connection)
+ server->stat.my_server_ops++;
+ if (server->server_type == SILC_ROUTER)
+ server->stat.server_ops++;
+
/* Send UMODE change to primary router */
if (!server->standalone)
silc_server_send_notify_umode(server, server->router->connection, TRUE,
/* Client is now router operator */
client->mode |= SILC_UMODE_ROUTER_OPERATOR;
+ /* Update statistics */
+ if (client->connection)
+ server->stat.my_router_ops++;
+ if (server->server_type == SILC_ROUTER)
+ server->stat.router_ops++;
+
/* Send UMODE change to primary router */
if (!server->standalone)
silc_server_send_notify_umode(server, server->router->connection, TRUE,
if (tmp_len > 128)
tmp = NULL;
+ /* Update statistics */
+ server->stat.clients--;
+ if (server->server_type == SILC_ROUTER)
+ server->stat.cell_clients--;
+ SILC_OPER_STATS_UPDATE(client, server, SILC_UMODE_SERVER_OPERATOR);
+ SILC_OPER_STATS_UPDATE(client, router, SILC_UMODE_ROUTER_OPERATOR);
+
/* Remove the client from all channels. */
silc_server_remove_from_channels(server, NULL, client, TRUE, tmp, FALSE);
client->data.status &= ~SILC_IDLIST_STATUS_REGISTERED;
cache->expire = SILC_ID_CACHE_EXPIRE_DEF;
- server->stat.clients--;
- if (server->server_type == SILC_ROUTER)
- server->stat.cell_clients--;
break;
case SILC_NOTIFY_TYPE_TOPIC_SET:
if (server->server_type != SILC_ROUTER &&
silc_argument_get_arg_num(args) > 1) {
int i;
+ bool local;
for (i = 1; i < silc_argument_get_arg_num(args); i++) {
/* Get Client ID */
/* Get client entry */
client = silc_idlist_find_client_by_id(server->global_list,
client_id, TRUE, &cache);
+ local = TRUE;
if (!client) {
client = silc_idlist_find_client_by_id(server->local_list,
client_id, TRUE, &cache);
+ local = FALSE;
if (!client) {
silc_free(client_id);
continue;
}
silc_free(client_id);
- /* Remove the client from all channels. */
- silc_server_remove_from_channels(server, NULL, client,
- TRUE, NULL, FALSE);
-
- client->data.status &= ~SILC_IDLIST_STATUS_REGISTERED;
- cache->expire = SILC_ID_CACHE_EXPIRE_DEF;
+ /* Update statistics */
server->stat.clients--;
if (server->server_type == SILC_ROUTER)
server->stat.cell_clients--;
+ SILC_OPER_STATS_UPDATE(client, server, SILC_UMODE_SERVER_OPERATOR);
+ SILC_OPER_STATS_UPDATE(client, router, SILC_UMODE_ROUTER_OPERATOR);
+
+ /* Remove the client from all channels. */
+ silc_server_remove_from_channels(server, NULL, client,
+ TRUE, NULL, FALSE);
+
+ /* Remove the client */
+ silc_idlist_del_client(local ? server->local_list :
+ server->global_list, client);
}
}
*/
SILC_LOG_DEBUG(("UMODE_CHANGE notify"));
-
+
/* Get client ID */
tmp = silc_argument_get_arg_type(args, 1, &tmp_len);
if (!tmp)
tmp = silc_argument_get_arg_type(args, 2, &tmp_len);
if (!tmp)
goto out;
+ SILC_GET32_MSB(mode, tmp);
+
+#define SILC_UMODE_STATS_UPDATE(oper, mod) \
+do { \
+ if (client->mode & (mod)) { \
+ if (!(mode & (mod))) { \
+ if (client->connection) \
+ server->stat.my_ ## oper ## _ops--; \
+ if (server->server_type == SILC_ROUTER) \
+ server->stat. oper ## _ops--; \
+ } \
+ } else { \
+ if (mode & (mod)) { \
+ if (client->connection) \
+ server->stat.my_ ## oper ## _ops++; \
+ if (server->server_type == SILC_ROUTER) \
+ server->stat. oper ## _ops++; \
+ } \
+ } \
+} while(0)
+
+ /* Update statistics */
+ SILC_UMODE_STATS_UPDATE(server, SILC_UMODE_SERVER_OPERATOR);
+ SILC_UMODE_STATS_UPDATE(router, SILC_UMODE_ROUTER_OPERATOR);
/* Save the mode */
- SILC_GET32_MSB(client->mode, tmp);
+ client->mode = mode;
break;
}
}
}
-
break;
/* Ignore rest of the notify types for now */
server->stat.my_servers,
server->stat.my_routers));
SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
- ("%d server operators and %d router operators "
- "online",
- server->stat.my_server_ops,
- server->stat.my_router_ops));
+ ("There are %d server operators and %d router "
+ "operators online",
+ server->stat.server_ops,
+ server->stat.router_ops));
+ SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
+ ("I have %d operators online",
+ server->stat.my_router_ops +
+ server->stat.my_server_ops));
} else {
SILC_SERVER_SEND_NOTIFY(server, sock, SILC_NOTIFY_TYPE_NONE,
("I have %d clients and %d channels formed",
silc_server_remove_from_channels(server, NULL, client,
FALSE, NULL, FALSE);
+ /* Update statistics */
+ server->stat.my_clients--;
+ server->stat.clients--;
+ if (server->server_type == SILC_ROUTER)
+ server->stat.cell_clients--;
+ SILC_OPER_STATS_UPDATE(client, server, SILC_UMODE_SERVER_OPERATOR);
+ SILC_OPER_STATS_UPDATE(client, router, SILC_UMODE_ROUTER_OPERATOR);
+
/* We will not delete the client entry right away. We will take it
into history (for WHOWAS command) for 5 minutes */
i->server = server;
client->data.status &= ~SILC_IDLIST_STATUS_REGISTERED;
client->router = NULL;
client->connection = NULL;
-
- /* Free the client entry and everything in it */
- server->stat.my_clients--;
- server->stat.clients--;
- if (server->server_type == SILC_ROUTER)
- server->stat.cell_clients--;
+ client->mode = 0;
}
/* Frees user_data pointer from socket connection object. This also sends
#define SILC_BACKUP_ROUTER 2
/* Connection retry timeout. We implement exponential backoff algorithm
- in connection retry. The interval of timeuot grows when retry count
+ in connection retry. The interval of timeout grows when retry count
grows. */
-#define SILC_SERVER_RETRY_COUNT 4 /* Max retry count */
-#define SILC_SERVER_RETRY_MULTIPLIER 7 / 4 /* Interval growth */
+#define SILC_SERVER_RETRY_COUNT 7 /* Max retry count */
+#define SILC_SERVER_RETRY_MULTIPLIER 2 /* Interval growth */
#define SILC_SERVER_RETRY_RANDOMIZER 2 /* timeout += rnd % 2 */
#define SILC_SERVER_RETRY_INTERVAL_MIN 10 /* Min retry timeout */
#define SILC_SERVER_RETRY_INTERVAL_MAX 600 /* Max generated timeout */
silc_schedule_set_listen_fd((s), (fd), (SILC_TASK_READ | SILC_TASK_WRITE)); \
} while(0)
+#define SILC_OPER_STATS_UPDATE(c, type, mod) \
+do { \
+ if ((c)->mode & (mod)) { \
+ if ((c)->connection) \
+ server->stat.my_ ## type ## _ops--; \
+ if (server->server_type == SILC_ROUTER) \
+ server->stat. type ## _ops--; \
+ } \
+} while(0)
+
/* Prototypes */
SILC_TASK_CALLBACK_GLOBAL(silc_server_rekey_final);
silc_buffer_free(idp);
}
+ /* Update statistics */
+ server->stat.clients--;
+ if (server->server_type == SILC_ROUTER)
+ server->stat.cell_clients--;
+ SILC_OPER_STATS_UPDATE(client, server, SILC_UMODE_SERVER_OPERATOR);
+ SILC_OPER_STATS_UPDATE(client, router, SILC_UMODE_ROUTER_OPERATOR);
+
/* Remove the client entry */
silc_server_remove_clients_channels(server, NULL, client, channels);
if (!server_signoff) {
} else {
silc_idlist_del_client(server->local_list, client);
}
- server->stat.clients--;
- if (server->server_type == SILC_ROUTER)
- server->stat.cell_clients--;
if (!silc_idcache_list_next(list, &id_cache))
break;
silc_buffer_free(idp);
}
+ /* Update statistics */
+ server->stat.clients--;
+ if (server->server_type == SILC_ROUTER)
+ server->stat.cell_clients--;
+ SILC_OPER_STATS_UPDATE(client, server, SILC_UMODE_SERVER_OPERATOR);
+ SILC_OPER_STATS_UPDATE(client, router, SILC_UMODE_ROUTER_OPERATOR);
+
/* Remove the client entry */
silc_server_remove_clients_channels(server, NULL, client, channels);
if (!server_signoff) {
} else {
silc_idlist_del_client(server->global_list, client);
}
- server->stat.clients--;
- if (server->server_type == SILC_ROUTER)
- server->stat.cell_clients--;
if (!silc_idcache_list_next(list, &id_cache))
break;