forked from Telodendria/Telodendria
[MOD] Spoof some endpoints
Some checks are pending
Compile Telodendria / Compile Telodendria (x86, alpine-v3.19) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86, debian-v12.4) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86, freebsd-v14.0) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86, netbsd-v9.3) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, alpine-v3.19) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, debian-v12.4) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, freebsd-v14.0) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, netbsd-v9.3) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, openbsd-v7.4) (push) Waiting to run
Some checks are pending
Compile Telodendria / Compile Telodendria (x86, alpine-v3.19) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86, debian-v12.4) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86, freebsd-v14.0) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86, netbsd-v9.3) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, alpine-v3.19) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, debian-v12.4) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, freebsd-v14.0) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, netbsd-v9.3) (push) Waiting to run
Compile Telodendria / Compile Telodendria (x86_64, openbsd-v7.4) (push) Waiting to run
This commit is contained in:
parent
57651df1c7
commit
cc5c4bde70
8 changed files with 104 additions and 6 deletions
|
@ -93,6 +93,10 @@ RouterBuild(void)
|
||||||
R("/_matrix/client/v3/directory/room/(.*)", RouteAliasDirectory);
|
R("/_matrix/client/v3/directory/room/(.*)", RouteAliasDirectory);
|
||||||
R("/_matrix/client/v3/rooms/(.*)/aliases", RouteRoomAliases);
|
R("/_matrix/client/v3/rooms/(.*)/aliases", RouteRoomAliases);
|
||||||
|
|
||||||
|
/* Spoofed endpoints, to be TODO'd */
|
||||||
|
R("/_matrix/client/v3/keys/(query|upload)", RouteKeyQuery);
|
||||||
|
R("/_matrix/client/v3/pushrules", RoutePushrules);
|
||||||
|
|
||||||
|
|
||||||
/* Telodendria Admin API Routes */
|
/* Telodendria Admin API Routes */
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,6 @@ ROUTE_IMPL(RouteJoinRoomAlias, path, argp)
|
||||||
if (*roomId != '!')
|
if (*roomId != '!')
|
||||||
{
|
{
|
||||||
roomId = RoomResolveAlias(db, roomId);
|
roomId = RoomResolveAlias(db, roomId);
|
||||||
Log(LOG_NOTICE, "Here's my guess: %s", roomId);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -127,7 +126,6 @@ ROUTE_IMPL(RouteJoinRoomAlias, path, argp)
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(LOG_INFO, "Trying with token %s", token);
|
|
||||||
user = UserAuthenticate(db, token);
|
user = UserAuthenticate(db, token);
|
||||||
if (!user)
|
if (!user)
|
||||||
{
|
{
|
||||||
|
@ -138,7 +136,6 @@ ROUTE_IMPL(RouteJoinRoomAlias, path, argp)
|
||||||
id = UserIdParse(UserGetName(user), serverName);
|
id = UserIdParse(UserGetName(user), serverName);
|
||||||
id->sigil = '@';
|
id->sigil = '@';
|
||||||
sender = ParserRecomposeCommonID(*id);
|
sender = ParserRecomposeCommonID(*id);
|
||||||
Log(LOG_INFO, "Now as %s", sender);
|
|
||||||
|
|
||||||
room = RoomLock(db, roomId);
|
room = RoomLock(db, roomId);
|
||||||
if (!room)
|
if (!room)
|
||||||
|
@ -151,7 +148,6 @@ ROUTE_IMPL(RouteJoinRoomAlias, path, argp)
|
||||||
if (RoomContainsUser(room, sender))
|
if (RoomContainsUser(room, sender))
|
||||||
{
|
{
|
||||||
err = "User is already in the room.";
|
err = "User is already in the room.";
|
||||||
Log(LOG_INFO, "qhar for %s", sender);
|
|
||||||
|
|
||||||
HttpResponseStatus(args->context, HTTP_UNAUTHORIZED);
|
HttpResponseStatus(args->context, HTTP_UNAUTHORIZED);
|
||||||
response = MatrixErrorCreate(M_FORBIDDEN, err);
|
response = MatrixErrorCreate(M_FORBIDDEN, err);
|
||||||
|
|
47
src/Routes/RouteKeyQuery.c
Normal file
47
src/Routes/RouteKeyQuery.c
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022-2024 Jordan Bancino <@jordan:bancino.net> with
|
||||||
|
* other valuable contributors. See CONTRIBUTORS.txt for the full list.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation files
|
||||||
|
* (the "Software"), to deal in the Software without restriction,
|
||||||
|
* including without limitation the rights to use, copy, modify, merge,
|
||||||
|
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||||
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
#include <Routes.h>
|
||||||
|
|
||||||
|
#include <Cytoplasm/Json.h>
|
||||||
|
#include <Cytoplasm/Array.h>
|
||||||
|
#include <Cytoplasm/HashMap.h>
|
||||||
|
|
||||||
|
ROUTE_IMPL(RouteKeyQuery, path, argp)
|
||||||
|
{
|
||||||
|
HashMap *response = HashMapCreate();
|
||||||
|
char *action = ArrayGet(path, 0);
|
||||||
|
|
||||||
|
(void) argp;
|
||||||
|
|
||||||
|
if (StrEquals(action, "upload"))
|
||||||
|
{
|
||||||
|
HashMapSet(response,
|
||||||
|
"one_time_key_counts", JsonValueObject(HashMapCreate())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
/* TODO: Spoofed endpoint */
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
|
@ -37,7 +37,7 @@
|
||||||
#include <Schema/Filter.h>
|
#include <Schema/Filter.h>
|
||||||
|
|
||||||
|
|
||||||
ROUTE_IMPL(RoutePushRules, path, argp)
|
ROUTE_IMPL(RoutePushrules, path, argp)
|
||||||
{
|
{
|
||||||
RouteArgs *args = argp;
|
RouteArgs *args = argp;
|
||||||
Db *db = args->matrixArgs->db;
|
Db *db = args->matrixArgs->db;
|
||||||
|
|
43
src/Routes/RoutePushrules.c
Normal file
43
src/Routes/RoutePushrules.c
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022-2024 Jordan Bancino <@jordan:bancino.net> with
|
||||||
|
* other valuable contributors. See CONTRIBUTORS.txt for the full list.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation files
|
||||||
|
* (the "Software"), to deal in the Software without restriction,
|
||||||
|
* including without limitation the rights to use, copy, modify, merge,
|
||||||
|
* publish, distribute, sublicense, and/or sell copies of the Software,
|
||||||
|
* and to permit persons to whom the Software is furnished to do so,
|
||||||
|
* subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||||
|
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
* SOFTWARE.
|
||||||
|
*/
|
||||||
|
#include <Routes.h>
|
||||||
|
|
||||||
|
#include <Cytoplasm/Json.h>
|
||||||
|
#include <Cytoplasm/Array.h>
|
||||||
|
#include <Cytoplasm/HashMap.h>
|
||||||
|
|
||||||
|
ROUTE_IMPL(RouteKeyQuery, path, argp)
|
||||||
|
{
|
||||||
|
HashMap *response = HashMapCreate();
|
||||||
|
|
||||||
|
(void) path;
|
||||||
|
(void) argp;
|
||||||
|
|
||||||
|
/* TODO: Spoofed endpoint */
|
||||||
|
HashMapSet(response, "global", JsonValueObject(HashMapCreate()));
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
|
@ -312,6 +312,7 @@ UiaComplete(Array * flows, HttpServerContext * context, Db * db,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: The type may sometimes be omitted. */
|
||||||
val = HashMapGet(auth, "type");
|
val = HashMapGet(auth, "type");
|
||||||
|
|
||||||
if (!val || JsonValueType(val) != JSON_STRING)
|
if (!val || JsonValueType(val) != JSON_STRING)
|
||||||
|
|
|
@ -130,6 +130,9 @@ UserLock(Db * db, char *name)
|
||||||
user->name = StrDuplicate(name);
|
user->name = StrDuplicate(name);
|
||||||
user->deviceId = NULL;
|
user->deviceId = NULL;
|
||||||
|
|
||||||
|
user->inviteRef = DbLock(db, 3, "users", user->name, "invites");
|
||||||
|
user->joinRef = DbLock(db, 3, "users", user->name, "joins");
|
||||||
|
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,7 +198,7 @@ UserUnlock(User * user)
|
||||||
Free(user->name);
|
Free(user->name);
|
||||||
Free(user->deviceId);
|
Free(user->deviceId);
|
||||||
|
|
||||||
ret = DbUnlock(db, ref) &&
|
ret = DbUnlock(db, ref) &&
|
||||||
DbUnlock(db, user->joinRef) &&
|
DbUnlock(db, user->joinRef) &&
|
||||||
DbUnlock(db, user->inviteRef);
|
DbUnlock(db, user->inviteRef);
|
||||||
user->db = NULL;
|
user->db = NULL;
|
||||||
|
@ -1683,6 +1686,7 @@ UserNotifyUser(User *user)
|
||||||
entry = Malloc(sizeof(*entry));
|
entry = Malloc(sizeof(*entry));
|
||||||
entry->type = NOTIF_GOTTEN;
|
entry->type = NOTIF_GOTTEN;
|
||||||
|
|
||||||
|
HashMapSet(pushTable, user->name, entry);
|
||||||
pthread_mutex_unlock(&pushLock);
|
pthread_mutex_unlock(&pushLock);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,6 +115,9 @@ ROUTE(RouteRoomAliases);
|
||||||
ROUTE(RouteAdminDeactivate);
|
ROUTE(RouteAdminDeactivate);
|
||||||
|
|
||||||
ROUTE(RouteAdminTokens);
|
ROUTE(RouteAdminTokens);
|
||||||
|
|
||||||
|
ROUTE(RouteKeyQuery);
|
||||||
|
ROUTE(RoutePushrules);
|
||||||
#undef ROUTE
|
#undef ROUTE
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue