Create configurations for user-facing messages within registration (#238)

This commit is contained in:
Melissa Draper 2021-07-10 17:02:06 -07:00 committed by Doug Freed
parent 05bc814d83
commit e4a62bbc85
7 changed files with 177 additions and 12 deletions

View file

@ -580,6 +580,15 @@ general {
hide_tkdline_duration = no; hide_tkdline_duration = no;
kline_reason = "K-Lined"; kline_reason = "K-Lined";
sasl_only_client_message = "You need to identify via SASL to use to use this server."; sasl_only_client_message = "You need to identify via SASL to use to use this server.";
identd_only_client_message = "You need to install identd to use this server.";
sctp_forbidden_client_message = "You are not allowed to use SCTP on this server.";
ssltls_only_client_message = "You need to use SSL/TLS to use this server.";
not_authorised_client_message = "You are not authorised to access this server.";
illegal_hostname_client_message = "You have an illegal character in your hostname.";
server_full_client_message = "Sorry, server is full - try later";
illegal_name_long_client_message = "Your username is invalid. Please make sure that your username contains "
"only alphanumeric characters.";
illegal_name_short_client_message = "Invalid username";
identify_service = "NickServ@services.int"; identify_service = "NickServ@services.int";
identify_command = "IDENTIFY"; identify_command = "IDENTIFY";
non_redundant_klines = yes; non_redundant_klines = yes;

View file

@ -1153,6 +1153,47 @@ general {
*/ */
sasl_only_client_message = "You need to identify via SASL to use to use this server."; sasl_only_client_message = "You need to identify via SASL to use to use this server.";
/* Identd access only client message: give users a message that
* informs them
*/
identd_only_client_message = "You need to install identd to use this server.";
/* SCTP forbidden client message: give users a message that
* informs them
*/
sctp_forbidden_client_message = "You are not allowed to use SCTP on this server.";
/* SSL/TLS access only client message: give users a message that
* informs them
*/
ssltls_only_client_message = "You need to use SSL/TLS to use this server.";
/* Not authorised client message: tell users that they are not
* authorised
*/
not_authorised_client_message = "You are not authorised to access this server.";
/* Illegal hostname client message: tell users that they have illegal
* chars in their hostname
*/
illegal_hostname_client_message = "You have an illegal character in your hostname.";
/* Server full client message: tell users that the server they're connecting
* to is full
*/
server_full_client_message = "Sorry, server is full - try later";
/* illegal name long client message: long-form explanation that their username
* contains illegal characters
*/
illegal_name_long_client_message = "Your username is invalid. Please make sure that your username contains "
"only alphanumeric characters.";
/* illegal name short client message: short-form notification that their username
* contains illegal characters; will be followed by ": their_username"
*/
illegal_name_short_client_message = "Invalid username";
/* identify to services via server password /* identify to services via server password
* if auth{} block had no password but the user specified a * if auth{} block had no password but the user specified a
* server password anyway, send a PRIVMSG to <identify_service> * server password anyway, send a PRIVMSG to <identify_service>

View file

@ -258,6 +258,14 @@ struct config_file_entry
char *drain_reason; char *drain_reason;
char *sasl_only_client_message; char *sasl_only_client_message;
char *identd_only_client_message;
char *sctp_forbidden_client_message;
char *ssltls_only_client_message;
char *not_authorised_client_message;
char *illegal_hostname_client_message;
char *server_full_client_message;
char *illegal_name_long_client_message;
char *illegal_name_short_client_message;
}; };
struct config_channel_entry struct config_channel_entry

View file

@ -2708,6 +2708,14 @@ static struct ConfEntry conf_general_table[] =
{ "certfp_method", CF_STRING, conf_set_general_certfp_method, 0, NULL }, { "certfp_method", CF_STRING, conf_set_general_certfp_method, 0, NULL },
{ "drain_reason", CF_QSTRING, NULL, BUFSIZE, &ConfigFileEntry.drain_reason }, { "drain_reason", CF_QSTRING, NULL, BUFSIZE, &ConfigFileEntry.drain_reason },
{ "sasl_only_client_message", CF_QSTRING, NULL, BUFSIZE, &ConfigFileEntry.sasl_only_client_message }, { "sasl_only_client_message", CF_QSTRING, NULL, BUFSIZE, &ConfigFileEntry.sasl_only_client_message },
{ "identd_only_client_message", CF_QSTRING, NULL, BUFSIZE, &ConfigFileEntry.identd_only_client_message },
{ "sctp_forbidden_client_message", CF_QSTRING, NULL, BUFSIZE, &ConfigFileEntry.sctp_forbidden_client_message },
{ "ssltls_only_client_message", CF_QSTRING, NULL, BUFSIZE, &ConfigFileEntry.ssltls_only_client_message },
{ "not_authorised_client_message", CF_QSTRING, NULL, BUFSIZE, &ConfigFileEntry.not_authorised_client_message },
{ "illegal_hostname_client_message", CF_QSTRING, NULL, BUFSIZE, &ConfigFileEntry.not_authorised_client_message },
{ "server_full_client_message", CF_QSTRING, NULL, BUFSIZE, &ConfigFileEntry.server_full_client_message },
{ "illegal_name_long_client_message", CF_QSTRING, NULL, BUFSIZE, &ConfigFileEntry.illegal_name_long_client_message },
{ "illegal_name_short_client_message", CF_QSTRING, NULL, BUFSIZE, &ConfigFileEntry.illegal_name_short_client_message },
{ "tls_ciphers_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.tls_ciphers_oper_only }, { "tls_ciphers_oper_only", CF_YESNO, NULL, 0, &ConfigFileEntry.tls_ciphers_oper_only },
{ "oper_secure_only", CF_YESNO, NULL, 0, &ConfigFileEntry.oper_secure_only }, { "oper_secure_only", CF_YESNO, NULL, 0, &ConfigFileEntry.oper_secure_only },
{ "\0", 0, NULL, 0, NULL } { "\0", 0, NULL, 0, NULL }

View file

@ -1552,6 +1552,22 @@ clear_out_old_conf(void)
ConfigFileEntry.drain_reason = NULL; ConfigFileEntry.drain_reason = NULL;
rb_free(ConfigFileEntry.sasl_only_client_message); rb_free(ConfigFileEntry.sasl_only_client_message);
ConfigFileEntry.sasl_only_client_message = NULL; ConfigFileEntry.sasl_only_client_message = NULL;
rb_free(ConfigFileEntry.identd_only_client_message);
ConfigFileEntry.identd_only_client_message = NULL;
rb_free(ConfigFileEntry.sctp_forbidden_client_message);
ConfigFileEntry.sctp_forbidden_client_message = NULL;
rb_free(ConfigFileEntry.ssltls_only_client_message);
ConfigFileEntry.ssltls_only_client_message = NULL;
rb_free(ConfigFileEntry.not_authorised_client_message);
ConfigFileEntry.not_authorised_client_message = NULL;
rb_free(ConfigFileEntry.illegal_hostname_client_message);
ConfigFileEntry.illegal_hostname_client_message = NULL;
rb_free(ConfigFileEntry.server_full_client_message);
ConfigFileEntry.server_full_client_message = NULL;
rb_free(ConfigFileEntry.illegal_name_long_client_message);
ConfigFileEntry.illegal_name_long_client_message = NULL;
rb_free(ConfigFileEntry.illegal_name_short_client_message);
ConfigFileEntry.illegal_name_short_client_message = NULL;
if (ConfigFileEntry.hidden_caps != NULL) if (ConfigFileEntry.hidden_caps != NULL)
{ {

View file

@ -428,7 +428,12 @@ register_local_user(struct Client *client_p, struct Client *source_p)
if(!valid_hostname(source_p->host)) if(!valid_hostname(source_p->host))
{ {
sendto_one_notice(source_p, ":*** Notice -- You have an illegal character in your hostname"); const char *illegal_hostname_client_message = ConfigFileEntry.illegal_hostname_client_message;
if (illegal_hostname_client_message == NULL)
illegal_hostname_client_message = "You have an illegal character in your hostname.";
sendto_one_notice(source_p, ":*** Notice -- %s", illegal_hostname_client_message);
rb_strlcpy(source_p->host, source_p->sockhost, sizeof(source_p->host)); rb_strlcpy(source_p->host, source_p->sockhost, sizeof(source_p->host));
} }
@ -437,23 +442,40 @@ register_local_user(struct Client *client_p, struct Client *source_p)
if(aconf == NULL) if(aconf == NULL)
{ {
exit_client(client_p, source_p, &me, "*** Not Authorised"); const char *not_authorised_client_message = ConfigFileEntry.not_authorised_client_message;
if (not_authorised_client_message == NULL)
not_authorised_client_message = "You are not authorised to access this server.";
exit_client(client_p, source_p, &me, not_authorised_client_message);
return (CLIENT_EXITED); return (CLIENT_EXITED);
} }
if(IsConfSSLNeeded(aconf) && !IsSecure(source_p)) if(IsConfSSLNeeded(aconf) && !IsSecure(source_p))
{ {
const char *ssltls_only_client_message = ConfigFileEntry.ssltls_only_client_message;
if (ssltls_only_client_message == NULL)
ssltls_only_client_message = "You need to use SSL/TLS to use this server.";
ServerStats.is_ref++; ServerStats.is_ref++;
sendto_one_notice(source_p, ":*** Notice -- You need to use SSL/TLS to use this server"); sendto_one_notice(source_p, ":*** Notice -- %s", ssltls_only_client_message);
exit_client(client_p, source_p, &me, "Use SSL/TLS");
exit_client(client_p, source_p, &me, ssltls_only_client_message);
return (CLIENT_EXITED); return (CLIENT_EXITED);
} }
if(IsSCTP(source_p) && !IsConfAllowSCTP(aconf)) if(IsSCTP(source_p) && !IsConfAllowSCTP(aconf))
{ {
const char *sctp_forbidden_client_message = ConfigFileEntry.sctp_forbidden_client_message;
if (sctp_forbidden_client_message == NULL)
sctp_forbidden_client_message = "You are not allowed to use SCTP on this server.";
ServerStats.is_ref++; ServerStats.is_ref++;
sendto_one_notice(source_p, ":*** Notice -- You are not allowed to use SCTP on this server"); sendto_one_notice(source_p, ":*** Notice -- %s", sctp_forbidden_client_message);
exit_client(client_p, source_p, &me, "SCTP not allowed");
exit_client(client_p, source_p, &me, sctp_forbidden_client_message);
return (CLIENT_EXITED); return (CLIENT_EXITED);
} }
@ -464,9 +486,16 @@ register_local_user(struct Client *client_p, struct Client *source_p)
if(IsNeedIdentd(aconf)) if(IsNeedIdentd(aconf))
{ {
const char *identd_only_client_message = ConfigFileEntry.identd_only_client_message;
if (identd_only_client_message == NULL)
identd_only_client_message = "You need to install identd to use this server.";
ServerStats.is_ref++; ServerStats.is_ref++;
sendto_one_notice(source_p, ":*** Notice -- You need to install identd to use this server"); sendto_one_notice(source_p, ":*** Notice -- %s", identd_only_client_message);
exit_client(client_p, source_p, &me, "Install identd");
exit_client(client_p, source_p, &me, identd_only_client_message);
return (CLIENT_EXITED); return (CLIENT_EXITED);
} }
@ -552,8 +581,13 @@ register_local_user(struct Client *client_p, struct Client *source_p)
sendto_realops_snomask(SNO_FULL, L_NETWIDE, sendto_realops_snomask(SNO_FULL, L_NETWIDE,
"Too many clients, rejecting %s[%s].", source_p->name, source_p->host); "Too many clients, rejecting %s[%s].", source_p->name, source_p->host);
const char *server_full_client_message = ConfigFileEntry.server_full_client_message;
if (server_full_client_message == NULL)
server_full_client_message = "Sorry, server is full - try later";
ServerStats.is_ref++; ServerStats.is_ref++;
exit_client(client_p, source_p, &me, "Sorry, server is full - try later"); exit_client(client_p, source_p, &me, server_full_client_message);
return (CLIENT_EXITED); return (CLIENT_EXITED);
} }
@ -578,10 +612,19 @@ register_local_user(struct Client *client_p, struct Client *source_p)
sendto_realops_snomask(SNO_REJ, L_NETWIDE, sendto_realops_snomask(SNO_REJ, L_NETWIDE,
"Invalid username: %s (%s@%s)", "Invalid username: %s (%s@%s)",
source_p->name, source_p->username, source_p->host); source_p->name, source_p->username, source_p->host);
const char *illegal_name_long_client_message = ConfigFileEntry.illegal_name_long_client_message;
const char *illegal_name_short_client_message = ConfigFileEntry.illegal_name_short_client_message;
if (illegal_name_long_client_message == NULL)
illegal_name_long_client_message = "Your username is invalid. Please make sure that your username contains "
"only alphanumeric characters.";
if (illegal_name_short_client_message == NULL)
illegal_name_short_client_message = "Invalid username";
ServerStats.is_ref++; ServerStats.is_ref++;
sendto_one_notice(source_p, ":*** Your username is invalid. Please make sure that your username contains " sendto_one_notice(source_p, ":*** %s", illegal_name_long_client_message);
"only alphanumeric characters."); sprintf(tmpstr2, "%s [%s]", illegal_name_short_client_message, source_p->username);
sprintf(tmpstr2, "Invalid username [%s]", source_p->username);
exit_client(client_p, source_p, &me, tmpstr2); exit_client(client_p, source_p, &me, tmpstr2);
return (CLIENT_EXITED); return (CLIENT_EXITED);
} }

View file

@ -205,6 +205,46 @@ static struct InfoStruct info_table[] = {
"Message to quit users with if they require SASL authentication.", "Message to quit users with if they require SASL authentication.",
INFO_STRING(&ConfigFileEntry.sasl_only_client_message), INFO_STRING(&ConfigFileEntry.sasl_only_client_message),
}, },
{
"identd_only_client_message",
"Message to quit users with if they require Identd.",
INFO_STRING(&ConfigFileEntry.identd_only_client_message),
},
{
"sctp_forbidden_client_message",
"Message to quit users with if they attempt using SCTP.",
INFO_STRING(&ConfigFileEntry.sctp_forbidden_client_message),
},
{
"ssltls_only_client_message",
"Message to quit users with if they require SSL/TLS.",
INFO_STRING(&ConfigFileEntry.ssltls_only_client_message),
},
{
"not_authorised_client_message",
"Message to quit users with if they are not authorised.",
INFO_STRING(&ConfigFileEntry.not_authorised_client_message),
},
{
"illegal_hostname_client_message",
"Message to users when their hostname contains illegal characters.",
INFO_STRING(&ConfigFileEntry.illegal_hostname_client_message),
},
{
"server_full_client_message",
"Message to users when the server is full.",
INFO_STRING(&ConfigFileEntry.server_full_client_message),
},
{
"illegal_name_long_client_message",
"Long message to users when their username contains illegal characters.",
INFO_STRING(&ConfigFileEntry.illegal_name_long_client_message),
},
{
"illegal_name_short_client_message",
"Short message to users when their username contains illegal characters.",
INFO_STRING(&ConfigFileEntry.illegal_name_short_client_message),
},
{ {
"disable_auth", "disable_auth",
"Controls whether auth checking is disabled or not", "Controls whether auth checking is disabled or not",