mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 21:15:11 +00:00
[ADD] MUC whitelists, part II
This commit is contained in:
parent
af2d08a431
commit
0b00a665bf
5 changed files with 48 additions and 3 deletions
|
|
@ -30,7 +30,9 @@ and speeds up Parsee a tad bit.
|
||||||
- Start dealing with some basic PEP-based avatars.
|
- Start dealing with some basic PEP-based avatars.
|
||||||
- Allows MbedTLS through a specific Cytoplasm patch.
|
- Allows MbedTLS through a specific Cytoplasm patch.
|
||||||
- Kicking/Banning Parsee from XMPP effectively unlinks it.
|
- Kicking/Banning Parsee from XMPP effectively unlinks it.
|
||||||
- Start adding documentation to Parsee;
|
- Start adding documentation to Parsee
|
||||||
|
- Add MUC whitelists for plumbing, alongside a `whitelist` tool
|
||||||
|
|
||||||
#### Bugfixes
|
#### Bugfixes
|
||||||
- Adds more information to media events so that clients can
|
- Adds more information to media events so that clients can
|
||||||
behave.
|
behave.
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,8 @@ CommandHead(CmdPlumb, cmd, argp)
|
||||||
BotRequired(room);
|
BotRequired(room);
|
||||||
|
|
||||||
/* Check MUC viability */
|
/* Check MUC viability */
|
||||||
if (ParseeManageBan(args->data, muc, NULL))
|
if (ParseeManageBan(args->data, muc, NULL) ||
|
||||||
|
ParseeIsMUCWhitelisted(args->data, muc))
|
||||||
{
|
{
|
||||||
ReplySprintf("MUC '%s' is not allowed on this bridge.", muc);
|
ReplySprintf("MUC '%s' is not allowed on this bridge.", muc);
|
||||||
goto end;
|
goto end;
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include <Cytoplasm/Str.h>
|
#include <Cytoplasm/Str.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <Routes.h>
|
#include <Routes.h>
|
||||||
#include <AS.h>
|
#include <AS.h>
|
||||||
|
|
@ -573,3 +574,37 @@ ParseeUnlinkRoom(ParseeData *data, char *chat_id)
|
||||||
Free(muc);
|
Free(muc);
|
||||||
Free(room);
|
Free(room);
|
||||||
}
|
}
|
||||||
|
bool
|
||||||
|
ParseeIsMUCWhitelisted(ParseeData *data, char *muc)
|
||||||
|
{
|
||||||
|
char *server, *serv_start;
|
||||||
|
DbRef *ref;
|
||||||
|
bool ret;
|
||||||
|
if (!data || !muc)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!DbExists(data->db, 1, "whitelist"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
serv_start = strchr(muc, '@');
|
||||||
|
serv_start = serv_start ? serv_start : muc;
|
||||||
|
server = StrDuplicate(serv_start + 1);
|
||||||
|
if (strchr(server, '/'))
|
||||||
|
{
|
||||||
|
*(strchr(server, '/')) = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
ref = DbLockIntent(data->db,
|
||||||
|
DB_HINT_READONLY,
|
||||||
|
1, "whitelist"
|
||||||
|
);
|
||||||
|
ret = HashMapGet(DbJson(ref), server);
|
||||||
|
DbUnlock(data->db, ref);
|
||||||
|
Free(server);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,8 @@ RouteHead(RouteRoomAck, arr, argp)
|
||||||
}
|
}
|
||||||
|
|
||||||
muc = ParseeDecodeLocalMUC(args->data->config, room);
|
muc = ParseeDecodeLocalMUC(args->data->config, room);
|
||||||
if (ParseeManageBan(args->data, muc, NULL))
|
if (ParseeManageBan(args->data, muc, NULL) ||
|
||||||
|
ParseeIsMUCWhitelisted(args->data, muc))
|
||||||
{
|
{
|
||||||
HttpResponseStatus(args->ctx, HTTP_METHOD_NOT_ALLOWED);
|
HttpResponseStatus(args->ctx, HTTP_METHOD_NOT_ALLOWED);
|
||||||
response = MatrixCreateError(
|
response = MatrixCreateError(
|
||||||
|
|
|
||||||
|
|
@ -420,4 +420,10 @@ extern void ParseeBroadcastStanza(ParseeData *data, char *from, XMLElement *s);
|
||||||
* Returns: NOTHING */
|
* Returns: NOTHING */
|
||||||
extern void ParseeUnlinkRoom(ParseeData *data, char *chat_id);
|
extern void ParseeUnlinkRoom(ParseeData *data, char *chat_id);
|
||||||
|
|
||||||
|
/** Verifies if there is no whitelists OR that a MUC's server is whitelisted.
|
||||||
|
* ----------------------
|
||||||
|
* Returns: if a MUC is to be allowed
|
||||||
|
* Modifies: NOTHING */
|
||||||
|
extern bool ParseeIsMUCWhitelisted(ParseeData *data, char *muc);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue