-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add gateway name field for auth blocks #273
base: main
Are you sure you want to change the base?
Changes from all commits
a6751c0
aec5c28
16ef4c5
ad2bd7a
4d769f5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (C) 2021 David Schultz <[email protected]> | ||
* | ||
* 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 2 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | ||
* USA | ||
*/ | ||
|
||
#include <stdinc.h> | ||
#include <modules.h> | ||
#include <capability.h> | ||
#include <s_serv.h> | ||
#include <s_newconf.h> | ||
#include <client.h> | ||
#include <msgbuf.h> | ||
|
||
static char cap_gateway_desc[] = "Provides the solanum.chat/gateway capability"; | ||
|
||
static void cap_gateway_outbound_msgbuf(void *); | ||
|
||
static unsigned CLICAP_GATEWAY; | ||
|
||
mapi_cap_list_av2 cap_gateway_caps[] = { | ||
{ MAPI_CAP_CLIENT, "solanum.chat/gateway", NULL, &CLICAP_GATEWAY }, | ||
{ 0, NULL, NULL, NULL } | ||
}; | ||
|
||
mapi_hfn_list_av1 cap_gateway_hfnlist[] = { | ||
{ "outbound_msgbuf", cap_gateway_outbound_msgbuf, HOOK_NORMAL }, | ||
{ NULL, NULL, 0 } | ||
}; | ||
|
||
|
||
static void | ||
cap_gateway_outbound_msgbuf(void *data_) | ||
{ | ||
hook_data *data = data_; | ||
struct MsgBuf *msgbuf = data->arg1; | ||
|
||
if (data->client == NULL || !IsPerson(data->client)) | ||
return; | ||
|
||
if (!EmptyString(data->client->gateway)) | ||
msgbuf_append_tag(msgbuf, "solanum.chat/gateway", data->client->gateway, CLICAP_GATEWAY); | ||
} | ||
|
||
DECLARE_MODULE_AV2(cap_gateway, NULL, NULL, NULL, NULL, cap_gateway_hfnlist, cap_gateway_caps, NULL, cap_gateway_desc); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (C) 2021 David Schultz <[email protected]> | ||
* | ||
* 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 2 of the License, 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | ||
* USA | ||
*/ | ||
|
||
#include "stdinc.h" | ||
#include "modules.h" | ||
#include "client.h" | ||
#include "ircd.h" | ||
|
||
static const char extb_desc[] = "Gateway name ($w) extban type"; | ||
|
||
static int _modinit(void); | ||
static void _moddeinit(void); | ||
static int eb_gateway(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type); | ||
|
||
DECLARE_MODULE_AV2(extb_gateway, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, extb_desc); | ||
|
||
static int | ||
_modinit(void) | ||
{ | ||
extban_table['w'] = eb_gateway; | ||
|
||
return 0; | ||
} | ||
|
||
static void | ||
_moddeinit(void) | ||
{ | ||
extban_table['w'] = NULL; | ||
} | ||
|
||
static int eb_gateway(const char *data, struct Client *client_p, | ||
struct Channel *chptr, long mode_type) | ||
{ | ||
/* $w by itself will match all gateway users */ | ||
if (data == NULL) | ||
return EmptyString(client_p->gateway) ? EXTBAN_NOMATCH : EXTBAN_MATCH; | ||
return match(data, client_p->gateway) ? EXTBAN_MATCH : EXTBAN_NOMATCH; | ||
Comment on lines
+50
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
if EmptyString(client_p->gateway)
return EXTBAN_NOMATCH;
/* $w by itself will match all gateway users */
if (data == NULL)
return EXTBAN_MATCH;
return match(data, client_p->gateway) ? EXTBAN_MATCH : EXTBAN_NOMATCH; |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ | |
#define FIELD_USER 0x0400 | ||
#define FIELD_ACCOUNT 0x0800 | ||
#define FIELD_OPLEVEL 0x1000 /* meaningless and stupid, but whatever */ | ||
#define FIELD_GATEWAY 0x2000 | ||
|
||
static const char who_desc[] = | ||
"Provides the WHO command to display information for users on a channel"; | ||
|
@@ -143,6 +144,7 @@ m_who(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, | |
case 'u': fmt.fields |= FIELD_USER; break; | ||
case 'a': fmt.fields |= FIELD_ACCOUNT; break; | ||
case 'o': fmt.fields |= FIELD_OPLEVEL; break; | ||
case 'w': fmt.fields |= FIELD_GATEWAY; break; | ||
case ',': | ||
s++; | ||
fmt.querytype = s; | ||
|
@@ -496,6 +498,7 @@ do_who(struct Client *source_p, struct Client *target_p, struct membership *mspt | |
char str[510 + 1]; /* linebuf.c will add \r\n */ | ||
size_t pos; | ||
const char *q; | ||
const char *w; | ||
|
||
sprintf(status, "%c%s%s", | ||
target_p->user->away ? 'G' : 'H', SeesOper(target_p, source_p) ? "*" : "", msptr ? find_channel_status(msptr, fmt->fields || IsCapable(source_p, CLICAP_MULTI_PREFIX)) : ""); | ||
|
@@ -565,6 +568,21 @@ do_who(struct Client *source_p, struct Client *target_p, struct membership *mspt | |
q = "0"; | ||
append_format(str, sizeof str, &pos, " %s", q); | ||
} | ||
if (fmt->fields & FIELD_GATEWAY) | ||
{ | ||
/* use same the logic as account */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given the reasoning for account to do this 1, I don't think it makes sense to copy that logic for gateway. |
||
w = target_p->gateway; | ||
if (!EmptyString(w)) | ||
{ | ||
while(IsDigit(*w)) | ||
w++; | ||
if(*w == '\0') | ||
w = target_p->gateway; | ||
} | ||
else | ||
w = "0"; | ||
append_format(str, sizeof str, &pos, " %s", w); | ||
} | ||
if (fmt->fields & FIELD_OPLEVEL) | ||
append_format(str, sizeof str, &pos, " %s", is_chanop(msptr) ? "999" : "n/a"); | ||
if (fmt->fields & FIELD_INFO) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these are necessary (
MAPI_CAP_CLIENT
is defined in modules.h).