X-Git-Url: http://git.silcnet.org/gitweb/?p=silc.git;a=blobdiff_plain;f=apps%2Fsilcd%2Fcommand.c;h=82bc2f6ee035a5af7853e0b511cfaa9b37af9b7d;hp=c11e549777c0eab75d36b8fe2e98df05f0a7475f;hb=d1e71f42379e8b5cd0748a7aeae8561b02cfe53d;hpb=34bb35a2496ec0402bb4d6c2546147cd37b27007 diff --git a/apps/silcd/command.c b/apps/silcd/command.c index c11e5497..82bc2f6e 100644 --- a/apps/silcd/command.c +++ b/apps/silcd/command.c @@ -74,6 +74,7 @@ SilcServerCommand silc_command_list[] = 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), @@ -1806,12 +1807,14 @@ SILC_SERVER_CMD_FUNC(stats) statistical information. */ if (!cmd->pending && server->server_type != SILC_ROUTER && !server->standalone) { + SilcBuffer idp; + /* Statistics */ cmd->server->stat.commands_sent++; /* Send request to our router */ - SilcBuffer idp = silc_id_payload_encode(server->router->id, - SILC_ID_SERVER); + idp = silc_id_payload_encode(server->router->id, + SILC_ID_SERVER); packet = silc_command_payload_encode_va(SILC_COMMAND_STATS, ++server->cmd_ident, 1, 1, idp->data, idp->len); @@ -2414,6 +2417,18 @@ SILC_SERVER_CMD_FUNC(join) 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); @@ -2632,8 +2647,13 @@ SILC_SERVER_CMD_FUNC(motd) /* 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, @@ -5086,6 +5106,50 @@ SILC_SERVER_CMD_FUNC(getkey) 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 */