Browse Source

Merge branch 'unrealircd:unreal60_dev' into piss60

piss60
angryce 2 months ago committed by GitHub
parent
commit
ac69125bfd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      doc/conf/rpc.modules.default.conf
  2. 2
      include/h.h
  3. 2
      src/api-efunctions.c
  4. 2
      src/json.c
  5. 2
      src/modules/protoctl.c
  6. 2
      src/modules/rpc/Makefile.in
  7. 45
      src/modules/rpc/server_ban.c
  8. 220
      src/modules/rpc/spamfilter.c
  9. 6
      src/modules/rpc/user.c
  10. 19
      src/modules/server-time.c
  11. 47
      src/modules/server.c

1
doc/conf/rpc.modules.default.conf

@ -31,3 +31,4 @@ loadmodule "rpc/rpc";
loadmodule "rpc/user";
loadmodule "rpc/channel";
loadmodule "rpc/server_ban";
loadmodule "rpc/spamfilter";

2
include/h.h

@ -783,7 +783,7 @@ extern MODVAR int (*join_viruschan)(Client *client, TKL *tk, int type);
extern MODVAR const char *(*StripColors)(const char *text);
extern MODVAR void (*spamfilter_build_user_string)(char *buf, const char *nick, Client *acptr);
extern MODVAR void (*send_protoctl_servers)(Client *client, int response);
extern MODVAR int (*verify_link)(Client *client, ConfigItem_link **link_out);
extern MODVAR ConfigItem_link *(*verify_link)(Client *client);
extern MODVAR void (*send_server_message)(Client *client);
extern MODVAR void (*broadcast_md_client)(ModDataInfo *mdi, Client *acptr, ModData *md);
extern MODVAR void (*broadcast_md_channel)(ModDataInfo *mdi, Channel *channel, ModData *md);

2
src/api-efunctions.c

@ -78,7 +78,7 @@ int (*join_viruschan)(Client *client, TKL *tk, int type);
const char *(*StripColors)(const char *text);
void (*spamfilter_build_user_string)(char *buf, const char *nick, Client *client);
void (*send_protoctl_servers)(Client *client, int response);
int (*verify_link)(Client *client, ConfigItem_link **link_out);
ConfigItem_link *(*verify_link)(Client *client);
void (*introduce_user)(Client *to, Client *client);
void (*send_server_message)(Client *client);
void (*broadcast_md_client)(ModDataInfo *mdi, Client *client, ModData *md);

2
src/json.c

@ -416,6 +416,8 @@ void json_expand_tkl(json_t *root, const char *key, TKL *tkl, int detail)
json_object_set_new(j, "name", json_string_unreal(tkl->ptr.spamfilter->match->str));
json_object_set_new(j, "match_type", json_string_unreal(unreal_match_method_valtostr(tkl->ptr.spamfilter->match->type)));
json_object_set_new(j, "ban_action", json_string_unreal(banact_valtostring(tkl->ptr.spamfilter->action)));
json_object_set_new(j, "ban_duration", json_integer(tkl->ptr.spamfilter->tkl_duration));
json_object_set_new(j, "ban_duration_string", json_string_unreal(pretty_time_val_r(buf, sizeof(buf), tkl->ptr.spamfilter->tkl_duration)));
json_object_set_new(j, "spamfilter_targets", json_string_unreal(spamfilter_target_inttostring(tkl->ptr.spamfilter->target)));
json_object_set_new(j, "reason", json_string_unreal(unreal_decodespace(tkl->ptr.spamfilter->tkl_reason)));
}

2
src/modules/protoctl.c

@ -264,7 +264,7 @@ CMD_FUNC(cmd_protoctl)
*/
strlcpy(client->name, servername, sizeof(client->name));
if (!verify_link(client, &aconf))
if (!(aconf = verify_link(client)))
return;
/* note: software, protocol and flags may be NULL */

2
src/modules/rpc/Makefile.in

@ -32,7 +32,7 @@ INCLUDES = ../../include/channel.h \
../../include/version.h ../../include/whowas.h
R_MODULES= \
rpc.so user.so channel.so server_ban.so
rpc.so user.so channel.so server_ban.so spamfilter.so
MODULES=$(R_MODULES)
MODULEFLAGS=@MODULEFLAGS@

45
src/modules/rpc/server_ban.c

@ -132,34 +132,34 @@ RPC_CALL_FUNC(rpc_server_ban_get)
name = json_object_get_string(params, "name");
if (!name)
{
rpc_error(client, NULL, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'name'");
rpc_error(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'name'");
return;
}
type_name = json_object_get_string(params, "type");
if (!type_name)
{
rpc_error(client, NULL, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'type'");
rpc_error(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'type'");
return;
}
tkl_type_char = tkl_configtypetochar(type_name);
if (!tkl_type_char)
{
rpc_error_fmt(client, NULL, JSON_RPC_ERROR_INVALID_PARAMS, "Invalid type: '%s'", type_name);
rpc_error_fmt(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Invalid type: '%s'", type_name);
return;
}
tkl_type_int = tkl_chartotype(tkl_type_char);
if (!server_ban_parse_mask(client, 0, tkl_type_int, name, &usermask, &hostmask, &soft, &error))
{
rpc_error_fmt(client, NULL, JSON_RPC_ERROR_INVALID_PARAMS, "Error: %s", error);
rpc_error_fmt(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Error: %s", error);
return;
}
if (!(tkl = find_tkl_serverban(tkl_type_int, usermask, hostmask, soft)))
{
rpc_error(client, NULL, JSON_RPC_ERROR_NOT_FOUND, "Ban not found");
rpc_error(client, request, JSON_RPC_ERROR_NOT_FOUND, "Ban not found");
return;
}
@ -186,21 +186,21 @@ RPC_CALL_FUNC(rpc_server_ban_del)
name = json_object_get_string(params, "name");
if (!name)
{
rpc_error(client, NULL, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'name'");
rpc_error(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'name'");
return;
}
type_name = json_object_get_string(params, "type");
if (!type_name)
{
rpc_error(client, NULL, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'type'");
rpc_error(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'type'");
return;
}
tkl_type_char = tkl_configtypetochar(type_name);
if (!tkl_type_char)
{
rpc_error_fmt(client, NULL, JSON_RPC_ERROR_INVALID_PARAMS, "Invalid type: '%s'", type_name);
rpc_error_fmt(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Invalid type: '%s'", type_name);
return;
}
tkl_type_int = tkl_chartotype(tkl_type_char);
@ -209,13 +209,13 @@ RPC_CALL_FUNC(rpc_server_ban_del)
if (!server_ban_parse_mask(client, 0, tkl_type_int, name, &usermask, &hostmask, &soft, &error))
{
rpc_error_fmt(client, NULL, JSON_RPC_ERROR_INVALID_PARAMS, "Error: %s", error);
rpc_error_fmt(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Error: %s", error);
return;
}
if (!(tkl = find_tkl_serverban(tkl_type_int, usermask, hostmask, soft)))
{
rpc_error(client, NULL, JSON_RPC_ERROR_NOT_FOUND, "Ban not found");
rpc_error(client, request, JSON_RPC_ERROR_NOT_FOUND, "Ban not found");
return;
}
@ -237,7 +237,7 @@ RPC_CALL_FUNC(rpc_server_ban_del)
/* Actually this may not be an internal error, it could be an
* incorrect request, such as asking to remove a config-based ban.
*/
rpc_error(client, NULL, JSON_RPC_ERROR_INTERNAL_ERROR, "Unable to remove item");
rpc_error(client, request, JSON_RPC_ERROR_INTERNAL_ERROR, "Unable to remove item");
}
json_decref(result);
}
@ -262,21 +262,21 @@ RPC_CALL_FUNC(rpc_server_ban_add)
name = json_object_get_string(params, "name");
if (!name)
{
rpc_error(client, NULL, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'name'");
rpc_error(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'name'");
return;
}
type_name = json_object_get_string(params, "type");
if (!type_name)
{
rpc_error(client, NULL, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'type'");
rpc_error(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'type'");
return;
}
tkl_type_char = tkl_configtypetochar(type_name);
if (!tkl_type_char)
{
rpc_error_fmt(client, NULL, JSON_RPC_ERROR_INVALID_PARAMS, "Invalid type: '%s'", type_name);
rpc_error_fmt(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Invalid type: '%s'", type_name);
return;
}
tkl_type_int = tkl_chartotype(tkl_type_char);
@ -286,7 +286,7 @@ RPC_CALL_FUNC(rpc_server_ban_add)
reason = json_object_get_string(params, "reason");
if (!reason)
{
rpc_error(client, NULL, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'reason'");
rpc_error(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'reason'");
return;
}
@ -297,23 +297,28 @@ RPC_CALL_FUNC(rpc_server_ban_add)
} else
if ((str = json_object_get_string(params, "expire_at")))
{
// TODO: handle this
tkl_expire_at = 5;
tkl_expire_at = server_time_to_unix_time(str);
} else
{
/* Never expire */
tkl_expire_at = 0;
}
if ((tkl_expire_at != 0) && (tkl_expire_at < TStime()))
{
rpc_error_fmt(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Error: the specified expiry time is before current time (before now)");
return;
}
if (!server_ban_parse_mask(client, 0, tkl_type_int, name, &usermask, &hostmask, &soft, &error))
{
rpc_error_fmt(client, NULL, JSON_RPC_ERROR_INVALID_PARAMS, "Error: %s", error);
rpc_error_fmt(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Error: %s", error);
return;
}
if (find_tkl_serverban(tkl_type_int, usermask, hostmask, soft))
{
rpc_error(client, NULL, JSON_RPC_ERROR_ALREADY_EXISTS, "A ban with that mask already exists");
rpc_error(client, request, JSON_RPC_ERROR_ALREADY_EXISTS, "A ban with that mask already exists");
return;
}
@ -323,7 +328,7 @@ RPC_CALL_FUNC(rpc_server_ban_add)
if (!tkl)
{
rpc_error(client, NULL, JSON_RPC_ERROR_INTERNAL_ERROR, "Unable to add item");
rpc_error(client, request, JSON_RPC_ERROR_INTERNAL_ERROR, "Unable to add item");
return;
}

220
src/modules/rpc/spamfilter.c

@ -0,0 +1,220 @@
/* spamfilter.* RPC calls
* (C) Copyright 2022-.. Bram Matthys (Syzop) and the UnrealIRCd team
* License: GPLv2 or later
*/
#include "unrealircd.h"
ModuleHeader MOD_HEADER
= {
"rpc/spamfilter",
"1.0.0",
"spamfilter.* RPC calls",
"UnrealIRCd Team",
"unrealircd-6",
};
/* Forward declarations */
RPC_CALL_FUNC(rpc_spamfilter_list);
RPC_CALL_FUNC(rpc_spamfilter_get);
RPC_CALL_FUNC(rpc_spamfilter_del);
RPC_CALL_FUNC(rpc_spamfilter_add);
MOD_INIT()
{
RPCHandlerInfo r;
MARK_AS_OFFICIAL_MODULE(modinfo);
memset(&r, 0, sizeof(r));
r.method = "spamfilter.list";
r.call = rpc_spamfilter_list;
if (!RPCHandlerAdd(modinfo->handle, &r))
{
config_error("[rpc/spamfilter] Could not register RPC handler");
return MOD_FAILED;
}
r.method = "spamfilter.get";
r.call = rpc_spamfilter_get;
if (!RPCHandlerAdd(modinfo->handle, &r))
{
config_error("[rpc/spamfilter] Could not register RPC handler");
return MOD_FAILED;
}
r.method = "spamfilter.del";
r.call = rpc_spamfilter_del;
if (!RPCHandlerAdd(modinfo->handle, &r))
{
config_error("[rpc/spamfilter] Could not register RPC handler");
return MOD_FAILED;
}
r.method = "spamfilter.add";
r.call = rpc_spamfilter_add;
if (!RPCHandlerAdd(modinfo->handle, &r))
{
config_error("[rpc/spamfilter] Could not register RPC handler");
return MOD_FAILED;
}
return MOD_SUCCESS;
}
MOD_LOAD()
{
return MOD_SUCCESS;
}
MOD_UNLOAD()
{
return MOD_SUCCESS;
}
RPC_CALL_FUNC(rpc_spamfilter_list)
{
json_t *result, *list, *item;
int index, index2;
TKL *tkl;
result = json_object();
list = json_array();
json_object_set_new(result, "list", list);
for (index = 0; index < TKLISTLEN; index++)
{
for (tkl = tklines[index]; tkl; tkl = tkl->next)
{
if (TKLIsSpamfilter(tkl))
{
item = json_object();
json_expand_tkl(item, NULL, tkl, 1);
json_array_append_new(list, item);
}
}
}
rpc_response(client, request, result);
json_decref(result);
}
RPC_CALL_FUNC(rpc_spamfilter_get)
{
}
RPC_CALL_FUNC(rpc_spamfilter_del)
{
}
RPC_CALL_FUNC(rpc_spamfilter_add)
{
json_t *result, *list, *item;
int type = TKL_SPAMF|TKL_GLOBAL;
const char *error;
const char *str;
const char *name, *reason;
time_t ban_duration = 0;
TKL *tkl;
Match *m;
BanAction action;
int match_type = 0;
int targets = 0;
char targetbuf[64];
char actionbuf[2];
char *err = NULL;
name = json_object_get_string(params, "name");
if (!name)
{
rpc_error(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'name'");
return;
}
str = json_object_get_string(params, "match_type");
if (!str)
{
rpc_error(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'match_type'");
return;
}
match_type = unreal_match_method_strtoval(str);
if (!match_type)
{
rpc_error(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Invalid value for parameter 'match_type'");
return;
}
str = json_object_get_string(params, "spamfilter_targets");
if (!str)
{
rpc_error(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'spamfilter_targets'");
return;
}
targets = spamfilter_gettargets(str, NULL);
if (!targets)
{
rpc_error(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Invalid value(s) for parameter 'spamfilter_targets'");
return;
}
strlcpy(targetbuf, spamfilter_target_inttostring(targets), sizeof(targetbuf));
str = json_object_get_string(params, "ban_action");
if (!str)
{
rpc_error(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'ban_action'");
return;
}
action = banact_stringtoval(str);
if (!action)
{
rpc_error(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Invalid value for parameter 'ban_action'");
return;
}
actionbuf[0] = banact_valtochar(action);
actionbuf[1] = '\0';
reason = json_object_get_string(params, "reason");
if (!reason)
{
rpc_error(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'reason'");
return;
}
/* Ban duration */
if ((str = json_object_get_string(params, "ban_duration")))
{
ban_duration = config_checkval(str, CFG_TIME);
if (ban_duration < 0)
{
rpc_error(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Invalid value for parameter 'ban_duration'");
return;
}
}
if (find_tkl_spamfilter(type, name, action, targets))
{
rpc_error(client, request, JSON_RPC_ERROR_ALREADY_EXISTS, "A spamfilter with that regex+action+target already exists");
return;
}
/* now check the regex / match field (only when adding) */
m = unreal_create_match(match_type, name, &err);
if (!m)
{
rpc_error(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Invalid regex or match string specified");
return;
}
tkl = tkl_add_spamfilter(type, targets, action, m, client->name, 0, TStime(),
ban_duration, reason, 0);
if (!tkl)
{
rpc_error(client, request, JSON_RPC_ERROR_INTERNAL_ERROR, "Unable to add item");
return;
}
tkl_added(client, tkl);
result = json_object();
json_expand_tkl(result, "tkl", tkl, 1);
rpc_response(client, request, result);
json_decref(result);
}

6
src/modules/rpc/user.c

@ -93,15 +93,13 @@ RPC_CALL_FUNC(rpc_user_get)
nick = json_object_get_string(params, "nick");
if (!nick)
{
rpc_error(client, NULL, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'nick'");
rpc_error(client, request, JSON_RPC_ERROR_INVALID_PARAMS, "Missing parameter: 'nick'");
return;
}
if (!(acptr = find_user(nick, NULL)))
{
// FIXME: wrong error!
// consider re-using IRC numerics? the positive ones, eg ERR_NOSUCHNICK
rpc_error(client, NULL, JSON_RPC_ERROR_INVALID_REQUEST, "Nickname not found");
rpc_error(client, request, JSON_RPC_ERROR_NOT_FOUND, "Nickname not found");
return;
}

19
src/modules/server-time.c

@ -91,26 +91,9 @@ void mtag_add_or_inherit_time(Client *sender, MessageTag *recv_mtags, MessageTag
m = duplicate_mtag(m);
} else
{
struct timeval t;
struct tm *tm;
time_t sec;
char buf[64];
gettimeofday(&t, NULL);
sec = t.tv_sec;
tm = gmtime(&sec);
snprintf(buf, sizeof(buf), "%04d-%02d-%02dT%02d:%02d:%02d.%03dZ",
tm->tm_year + 1900,
tm->tm_mon + 1,
tm->tm_mday,
tm->tm_hour,
tm->tm_min,
tm->tm_sec,
(int)(t.tv_usec / 1000));
m = safe_alloc(sizeof(MessageTag));
safe_strdup(m->name, "time");
safe_strdup(m->value, buf);
safe_strdup(m->value, timestamp_iso8601_now());
}
AddListItem(m, *mtag_list);
}

47
src/modules/server.c

@ -45,7 +45,7 @@ EVENT(server_handshake_timeout);
void send_channel_modes_sjoin3(Client *to, Channel *channel);
CMD_FUNC(cmd_server);
CMD_FUNC(cmd_sid);
int _verify_link(Client *client, ConfigItem_link **link_out);
ConfigItem_link *_verify_link(Client *client);
void _send_protoctl_servers(Client *client, int response);
void _send_server_message(Client *client);
void _introduce_user(Client *to, Client *acptr);
@ -76,7 +76,7 @@ MOD_TEST()
MARK_AS_OFFICIAL_MODULE(modinfo);
EfunctionAddVoid(modinfo->handle, EFUNC_SEND_PROTOCTL_SERVERS, _send_protoctl_servers);
EfunctionAddVoid(modinfo->handle, EFUNC_SEND_SERVER_MESSAGE, _send_server_message);
EfunctionAdd(modinfo->handle, EFUNC_VERIFY_LINK, _verify_link);
EfunctionAddPVoid(modinfo->handle, EFUNC_VERIFY_LINK, TO_PVOIDFUNC(_verify_link));
EfunctionAddVoid(modinfo->handle, EFUNC_INTRODUCE_USER, _introduce_user);
EfunctionAdd(modinfo->handle, EFUNC_CHECK_DENY_VERSION, _check_deny_version);
EfunctionAddVoid(modinfo->handle, EFUNC_BROADCAST_SINFO, _broadcast_sinfo);
@ -639,12 +639,10 @@ void _send_server_message(Client *client)
/** Verify server link.
* This does authentication and authorization checks.
* @param cptr The client directly connected to us (cptr).
* @param client The client which (originally) issued the server command (client).
* @param link_out Pointer-to-pointer-to-link block. Will be set when auth OK. Caller may pass NULL if he doesn't care.
* @returns This function returns 1 on successful authentication, 0 otherwise - in which case the client has been killed.
* @param client The client which issued the command
* @returns On successfull authentication, the link block is returned. On failure NULL is returned (client has been killed!).
*/
int _verify_link(Client *client, ConfigItem_link **link_out)
ConfigItem_link *_verify_link(Client *client)
{
ConfigItem_link *link, *orig_link;
Client *acptr = NULL, *ocptr = NULL;
@ -656,15 +654,12 @@ int _verify_link(Client *client, ConfigItem_link **link_out)
if (client->local->hostp && client->local->hostp->h_name)
set_sockhost(client, client->local->hostp->h_name);
if (link_out)
*link_out = NULL;
if (!client->local->passwd)
{
unreal_log(ULOG_ERROR, "link", "LINK_DENIED_NO_PASSWORD", client,
"Link with server $client.details denied: No password provided. Protocol error.");
exit_client(client, NULL, "Missing password");
return 0;
return NULL;
}
if (client->server && client->server->conf)
@ -683,7 +678,7 @@ int _verify_link(Client *client, ConfigItem_link **link_out)
log_data_link_block(client->server->conf));
exit_client_fmt(client, NULL, "Servername (%s) does not match name in my link block (%s)",
client->name, client->server->conf->servername);
return 0;
return NULL;
}
link = client->server->conf;
goto skip_host_check;
@ -699,7 +694,7 @@ int _verify_link(Client *client, ConfigItem_link **link_out)
unreal_log(ULOG_ERROR, "link", "LINK_DENIED_UNKNOWN_SERVER", client,
"Link with server $client.details denied: No link block named '$client'");
exit_client(client, NULL, LINK_DEFAULT_ERROR_MSG);
return 0;
return NULL;
}
if (!link->incoming.match)
@ -708,7 +703,7 @@ int _verify_link(Client *client, ConfigItem_link **link_out)
"Link with server $client.details denied: Link block exists, but there is no link::incoming::match set.",
log_data_link_block(link));
exit_client(client, NULL, LINK_DEFAULT_ERROR_MSG);
return 0;
return NULL;
}
orig_link = link;
@ -720,7 +715,7 @@ int _verify_link(Client *client, ConfigItem_link **link_out)
"Link with server $client.details denied: Server is in link block but link::incoming::mask didn't match",
log_data_link_block(orig_link));
exit_client(client, NULL, LINK_DEFAULT_ERROR_MSG);
return 0;
return NULL;
}
skip_host_check:
@ -771,7 +766,7 @@ skip_host_check:
log_data_link_block(link));
}
exit_client(client, NULL, "Link denied (Authentication failed)");
return 0;
return NULL;
}
/* Verify the TLS certificate (if requested) */
@ -786,7 +781,7 @@ skip_host_check:
log_data_string("certificate_failure_msg", "not using TLS"),
log_data_link_block(link));
exit_client(client, NULL, "Link denied (Not using TLS)");
return 0;
return NULL;
}
if (!verify_certificate(client->local->ssl, link->servername, &errstr))
{
@ -795,7 +790,7 @@ skip_host_check:
log_data_string("certificate_failure_msg", errstr),
log_data_link_block(link));
exit_client(client, NULL, "Link denied (Certificate verification failed)");
return 0;
return NULL;
}
}
@ -807,7 +802,7 @@ skip_host_check:
log_data_string("ban_reason", bconf->reason),
log_data_link_block(link));
exit_client_fmt(client, NULL, "Banned server: %s", bconf->reason);
return 0;
return NULL;
}
if (link->class->clients + 1 > link->class->maxclients)
@ -817,7 +812,7 @@ skip_host_check:
"class '$link_block.class' is full",
log_data_link_block(link));
exit_client(client, NULL, "Full class");
return 0;
return NULL;
}
if (!IsLocalhost(client) && (iConf.plaintext_policy_server == POLICY_DENY) && !IsSecure(client))
{
@ -827,7 +822,7 @@ skip_host_check:
"See https://www.unrealircd.org/docs/FAQ#server-requires-tls",
log_data_link_block(link));
exit_client(client, NULL, "Servers need to use TLS (set::plaintext-policy::server is 'deny')");
return 0;
return NULL;
}
if (IsSecure(client) && (iConf.outdated_tls_policy_server == POLICY_DENY) && outdated_tls_client(client))
{
@ -838,7 +833,7 @@ skip_host_check:
log_data_link_block(link),
log_data_string("tls_cipher", tls_get_cipher(client)));
exit_client(client, NULL, "Server using outdates TLS protocol or cipher (set::outdated-tls-policy::server is 'deny')");
return 0;
return NULL;
}
/* This one is at the end, because it causes us to delink another server,
* so we want to be (reasonably) sure that this one will succeed before
@ -854,7 +849,7 @@ skip_host_check:
log_data_string("me_name", me.name),
log_data_link_block(link));
exit_client(client, NULL, "Server Exists (server trying to link with same name as myself)");
return 0;
return NULL;
} else {
unreal_log(ULOG_ERROR, "link", "LINK_DROPPED_REINTRODUCED", client,
"Link with server $client.details causes older link "
@ -865,9 +860,7 @@ skip_host_check:
}
}
if (link_out)
*link_out = link;
return 1;
return link;
}
/** Server command. Only for locally connected servers!!.
@ -939,7 +932,7 @@ CMD_FUNC(cmd_server)
*/
strlcpy(client->name, servername, sizeof(client->name));
if (!verify_link(client, &aconf))
if (!(aconf = verify_link(client)))
return; /* Rejected */
/* From this point the server is authenticated, so we can be more verbose

Loading…
Cancel
Save