mirror of
https://github.com/unrealircd/unrealircd.git
synced 2026-07-08 05:23:13 +02:00
Add security-group::server-port and similary in match item, to match
users by server port (eg 6667, 6697, 8000, etc).
This also adds security-group::exclude-server-port for consistency.
And in crules the function server_port() returns the server port number,
so you can use rule 'server_port()>6690' for example.
Note that for remote clients this will only work after previous
commit (b2d0ec1af3) is loaded on all
servers, otherwise all remote clients are seen as having a server_port
of zero (0). Though you probably usually only care about this on local
users anyway.
This commit is contained in:
@@ -145,6 +145,7 @@ static int crule_match_asn(crule_context *, int, void **);
|
||||
static int crule_match_certfp(crule_context *, int, void **);
|
||||
static int crule_match_realname(crule_context *, int, void **);
|
||||
static int crule_unicode_count(crule_context *, int, void **);
|
||||
static int crule_server_port(crule_context *, int, void **);
|
||||
|
||||
/* parsing function prototypes - local! */
|
||||
static int crule_gettoken(crule_token *next_tokp, const char **str);
|
||||
@@ -206,6 +207,7 @@ struct crule_funclistent crule_funclist[] = {
|
||||
{"match_certfp", 1, crule_match_certfp},
|
||||
{"match_realname", 1, crule_match_realname},
|
||||
{"unicode_count", 1, crule_unicode_count},
|
||||
{"server_port", 0, crule_server_port},
|
||||
{"", 0, NULL} /* this must be here to mark end of list */
|
||||
};
|
||||
|
||||
@@ -566,6 +568,14 @@ static int crule_unicode_count(crule_context *context, int numargs, void *crulea
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int crule_server_port(crule_context *context, int numargs, void *crulearg[])
|
||||
{
|
||||
if (context && context->client)
|
||||
return get_server_port(context->client);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Evaluate a connection rule.
|
||||
* @param[in] rule Rule to evalute.
|
||||
* @return Non-zero if the rule allows the connection, zero otherwise.
|
||||
|
||||
Reference in New Issue
Block a user