1
0
mirror of https://github.com/unrealircd/unrealircd.git synced 2026-07-07 10:03:13 +02:00
Files
unrealircd/src/modules/user.c
T
Bram Matthys 52472a9a88 Add support for set unknown-users { } and the like:
It is now possible to override some set settings per-security group by
having a set block with a name, like `set unknown-users { }`
* You could use this to set more limitations for unknown-users:
  ```
  set unknown-users {
          max-channels-per-user 5;
          static-quit "Quit";
          static-part yes;
  }
  ```
* Or to set higher values (higher than the normal set block)
  for trusted users:
  ```
  security-group trusted-bots {
          account { BotOne; BotTwo; }
  }
  set trusted-bots {
          max-channels-per-user 25;
  }
  ```
* Currently the following settings can be used in a set xxx { } block:
  set::auto-join, set::modes-on-connect, set::restrict-usermodes,
  set::max-channels-per-user, set::static-quit, set::static-part.
2023-05-22 12:07:43 +02:00

114 lines
2.9 KiB
C

/*
* IRC - Internet Relay Chat, src/modules/user.c
* (C) 2005 The UnrealIRCd Team
*
* See file AUTHORS in IRC package for additional names of
* the programmers.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 1, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "unrealircd.h"
CMD_FUNC(cmd_user);
#define MSG_USER "USER"
ModuleHeader MOD_HEADER
= {
"user",
"5.0",
"command /user",
"UnrealIRCd Team",
"unrealircd-6",
};
MOD_INIT()
{
CommandAdd(modinfo->handle, MSG_USER, cmd_user, 4, CMD_UNREGISTERED);
MARK_AS_OFFICIAL_MODULE(modinfo);
return MOD_SUCCESS;
}
MOD_LOAD()
{
return MOD_SUCCESS;
}
MOD_UNLOAD()
{
return MOD_SUCCESS;
}
/** The USER command, together with NICK this will register a user.
* As per UnrealIRCd 5 this command is only available to local clients.
* Intraserver traffic is handled through the UID command.
* parv[1] = username
* parv[2] = client host name (ignored)
* parv[3] = server host name (ignored)
* parv[4] = real name / gecos
*
* NOTE: Be advised that multiple USER messages are possible,
* hence, always check if a certain struct is already allocated... -- Syzop
*/
CMD_FUNC(cmd_user)
{
const char *username;
const char *realname;
char *p;
if (!MyConnect(client) || IsServer(client))
return;
if (MyConnect(client) && (client->local->listener->options & LISTENER_SERVERSONLY))
{
exit_client(client, NULL, "This port is for servers only");
return;
}
if ((parc < 5) || BadPtr(parv[4]))
{
sendnumeric(client, ERR_NEEDMOREPARAMS, "USER");
return;
}
username = parv[1];
realname = parv[4];
make_user(client);
/* set::modes-on-connect */
client->umodes |= get_setting_for_user_number(client, SET_MODES_ON_CONNECT);
client->user->server = me_hash;
strlcpy(client->info, realname, sizeof(client->info));
strlcpy(client->user->username, username, sizeof(client->user->username));
/* This cuts the username off at @, uh okay.. */
if ((p = strchr(client->user->username, '@')))
*p = '\0';
if (*client->name && is_handshake_finished(client))
{
/* NICK and no-spoof already received, now we have USER... */
if (USE_BAN_VERSION && MyConnect(client))
{
sendto_one(client, NULL, ":IRC!IRC@%s PRIVMSG %s :\1VERSION\1",
me.name, client->name);
}
register_user(client);
return;
}
}