SILC_SERVER_CMD(leave, LEAVE, SILC_CF_LAG_STRICT | SILC_CF_REG),
SILC_SERVER_CMD(users, USERS, SILC_CF_LAG | SILC_CF_REG),
SILC_SERVER_CMD(getkey, GETKEY, SILC_CF_LAG | SILC_CF_REG),
+ SILC_SERVER_CMD(service, SERVICE, SILC_CF_LAG_STRICT | SILC_CF_REG),
SILC_SERVER_CMD(connect, PRIV_CONNECT,
SILC_CF_LAG | SILC_CF_REG | SILC_CF_OPER),
goto out;
}
+#ifndef SILC_DIST_INPLACE
+ /* Limit how many channels client can join */
+ if (!cmd->pending && entry->channels &&
+ silc_hash_table_count(entry->channels) >=
+ server->config->param.chlimit) {
+ silc_server_command_send_status_reply(cmd, SILC_COMMAND_JOIN,
+ SILC_STATUS_ERR_RESOURCE_LIMIT,
+ 0);
+ goto out;
+ }
+#endif /* SILC_DIST_INPLACE */
+
silc_free(client_id);
client_id = silc_id_dup(entry->id, SILC_ID_CLIENT);
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);
+ }
silc_free(client_id);
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);
+ }
silc_free(client_id);
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);
+ }
silc_free(client_id);
goto out;
}
/* Send motd */
motd = silc_file_readfile(server->config->server_info->motd_file,
&motd_len);
- if (!motd)
+ if (!motd) {
+ /* No motd */
+ silc_server_send_command_reply(server, cmd->sock, SILC_COMMAND_MOTD,
+ SILC_STATUS_OK, 0, ident, 1,
+ 2, idp->data, idp->len);
goto out;
+ }
motd[motd_len] = 0;
silc_server_send_command_reply(server, cmd->sock, SILC_COMMAND_MOTD,
new channel key. Clients are not using private channel keys
anymore after this. */
+ /* if we don't remove the flag from the mode
+ * silc_server_create_channel_key won't create a new key */
+ channel->mode &= ~SILC_CHANNEL_MODE_PRIVKEY;
+
/* Re-generate channel key */
if (!silc_server_create_channel_key(server, channel, 0))
goto out;
if (mode_mask & SILC_CHANNEL_MODE_HMAC) {
if (!(channel->mode & SILC_CHANNEL_MODE_HMAC)) {
/* HMAC to use protect the traffic */
- unsigned char hash[32];
+ unsigned char hash[SILC_HASH_MAXLEN];
SilcHmac newhmac;
/* Get hmac */
/* Hmac mode is unset. Remove the hmac and revert back to
default hmac */
SilcHmac newhmac;
- unsigned char hash[32];
+ unsigned char hash[SILC_HASH_MAXLEN];
hmac = channel->hmac_name;
/* Delete old hmac and allocate default one */
SilcServer server = cmd->server;
char *add_nick, *del_nick;
SilcUInt32 add_nick_len, del_nick_len, tmp_len, pk_len;
- unsigned char hash[16], *tmp, *pk, *nick;
+ unsigned char hash[SILC_HASH_MAXLEN], *tmp, *pk, *nick;
SilcClientEntry client;
SilcClientID *client_id = NULL;
SilcUInt16 old_ident;
silc_server_command_free(cmd);
}
+/* Server side of command SERVICE. */
+/* XXX currently this just sends empty reply back */
+
+SILC_SERVER_CMD_FUNC(service)
+{
+ SilcServerCommandContext cmd = (SilcServerCommandContext)context;
+ SilcServer server = cmd->server;
+ SilcUInt32 tmp_len, auth_len;
+ unsigned char *service_name, *auth;
+ bool send_list = FALSE;
+ SilcUInt16 ident = silc_command_get_ident(cmd->payload);
+
+ SILC_SERVER_COMMAND_CHECK(SILC_COMMAND_SERVICE, cmd, 0, 256);
+
+ /* Get requested service */
+ service_name = silc_argument_get_arg_type(cmd->args, 1, &tmp_len);
+ if (service_name && tmp_len) {
+ /* Verify service name */
+ if (!silc_identifier_verify(service_name, tmp_len,
+ SILC_STRING_UTF8, 256)) {
+ silc_server_command_send_status_reply(cmd, SILC_COMMAND_SERVICE,
+ SILC_STATUS_ERR_NOT_ENOUGH_PARAMS,
+ 0);
+ goto out;
+ }
+ }
+
+ /* Get authentication payload if present */
+ auth = silc_argument_get_arg_type(cmd->args, 2, &auth_len);
+ if (auth) {
+ /* XXX */
+ }
+
+
+ send_list = TRUE;
+
+ /* Send our service list back */
+ silc_server_send_command_reply(server, cmd->sock, SILC_COMMAND_SERVICE,
+ SILC_STATUS_OK, 0, ident, 0);
+
+ out:
+ silc_server_command_free(cmd);
+}
+
/* Private range commands, specific to this implementation */