mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 12:15:12 +00:00
[MOD] Change media path, connect to component through another address
This commit is contained in:
parent
c433e31461
commit
5e1931a19f
9 changed files with 30 additions and 9 deletions
|
|
@ -18,8 +18,7 @@ A more "up-to-date" reason may be to have a small, 'Just Werks' bridging solutio
|
||||||
and maybe as a testing ground for Cytoplasm features I sometimes add.
|
and maybe as a testing ground for Cytoplasm features I sometimes add.
|
||||||
|
|
||||||
(Well, I'm *trying* to do that, at least.
|
(Well, I'm *trying* to do that, at least.
|
||||||
Please scream at me if that fails(or just doesn't run on a overclocked Raspberry
|
Please scream at me if that fails(or just doesn't run on a overclocked Raspberry Pi 4B))
|
||||||
Pi 4B, which, by the way, is literally where Parsee+XMPP is running for now.))
|
|
||||||
|
|
||||||
### "Why not just use Matrix lol"
|
### "Why not just use Matrix lol"
|
||||||
### "Why not just use XMPP lol"
|
### "Why not just use XMPP lol"
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ ParseeCreateRequest(const ParseeConfig *conf, HttpRequestMethod meth, char *path
|
||||||
|
|
||||||
ctx = HttpRequest(
|
ctx = HttpRequest(
|
||||||
meth,
|
meth,
|
||||||
HTTP_FLAG_TLS,
|
conf->homeserver_tls ? HTTP_FLAG_TLS : HTTP_FLAG_NONE,
|
||||||
conf->homeserver_port, conf->homeserver_host,
|
conf->homeserver_port, conf->homeserver_host,
|
||||||
path
|
path
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -223,9 +223,11 @@ Main(Array *args, HashMap *env)
|
||||||
|
|
||||||
Log(LOG_NOTICE, "Connecting to XMPP...");
|
Log(LOG_NOTICE, "Connecting to XMPP...");
|
||||||
jabber = XMPPInitialiseCompStream(
|
jabber = XMPPInitialiseCompStream(
|
||||||
|
parsee_conf->component_addr,
|
||||||
parsee_conf->component_host,
|
parsee_conf->component_host,
|
||||||
parsee_conf->component_port
|
parsee_conf->component_port
|
||||||
);
|
);
|
||||||
|
Log(LOG_NOTICE, "Connecting to XMPP... %p", jabber);
|
||||||
if (!XMPPAuthenticateCompStream(
|
if (!XMPPAuthenticateCompStream(
|
||||||
jabber,
|
jabber,
|
||||||
parsee_conf->shared_comp_secret
|
parsee_conf->shared_comp_secret
|
||||||
|
|
@ -290,7 +292,6 @@ Main(Array *args, HashMap *env)
|
||||||
{
|
{
|
||||||
char *parsee = ParseeMXID(conf.handlerArgs);
|
char *parsee = ParseeMXID(conf.handlerArgs);
|
||||||
|
|
||||||
/* TODO: An hardcoded avatar like this sucks. */
|
|
||||||
ASSetAvatar(parsee_conf,
|
ASSetAvatar(parsee_conf,
|
||||||
parsee,
|
parsee,
|
||||||
"mxc://tedomum.net/"
|
"mxc://tedomum.net/"
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,9 @@ ParseeConfigLoad(char *conf)
|
||||||
#define CopyToInt(to, str) config->to = (int) ( \
|
#define CopyToInt(to, str) config->to = (int) ( \
|
||||||
JsonValueAsInteger(HashMapGet(json, str)) \
|
JsonValueAsInteger(HashMapGet(json, str)) \
|
||||||
)
|
)
|
||||||
|
#define CopyToBool(to, str) config->to = (int) ( \
|
||||||
|
JsonValueAsBoolean(HashMapGet(json, str)) \
|
||||||
|
)
|
||||||
|
|
||||||
config->http_threads = 8;
|
config->http_threads = 8;
|
||||||
config->xmpp_threads = 8;
|
config->xmpp_threads = 8;
|
||||||
|
|
@ -58,8 +61,14 @@ ParseeConfigLoad(char *conf)
|
||||||
CopyToStr(server_base, "hs_base");
|
CopyToStr(server_base, "hs_base");
|
||||||
CopyToStr(homeserver_host, "hs_host");
|
CopyToStr(homeserver_host, "hs_host");
|
||||||
CopyToInt(homeserver_port, "hs_port");
|
CopyToInt(homeserver_port, "hs_port");
|
||||||
|
CopyToBool(homeserver_tls, "hs_tls");
|
||||||
|
if (!HashMapGet(json, "hs_tls"))
|
||||||
|
{
|
||||||
|
config->homeserver_tls = true;
|
||||||
|
}
|
||||||
|
|
||||||
CopyToInt(component_port, "component_port");
|
CopyToInt(component_port, "component_port");
|
||||||
|
CopyToStr(component_addr, "component_addr");
|
||||||
CopyToStr(component_host, "component_host");
|
CopyToStr(component_host, "component_host");
|
||||||
CopyToStr(shared_comp_secret, "shared_secret");
|
CopyToStr(shared_comp_secret, "shared_secret");
|
||||||
CopyToInt(max_stanza_size, "max_stanza_size");
|
CopyToInt(max_stanza_size, "max_stanza_size");
|
||||||
|
|
@ -129,6 +138,7 @@ ParseeConfigFree(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Free(config->component_host);
|
Free(config->component_host);
|
||||||
|
Free(config->component_addr);
|
||||||
Free(config->shared_comp_secret);
|
Free(config->shared_comp_secret);
|
||||||
Free(config->db_path);
|
Free(config->db_path);
|
||||||
Free(config->homeserver_host);
|
Free(config->homeserver_host);
|
||||||
|
|
|
||||||
|
|
@ -692,7 +692,7 @@ ParseeToUnauth(ParseeData *data, char *mxc)
|
||||||
Uri *url = NULL;
|
Uri *url = NULL;
|
||||||
char *ret;
|
char *ret;
|
||||||
char *key, *hmac;
|
char *key, *hmac;
|
||||||
#define PAT "%s/_matrix/client/v1/media/download/%s%s?hmac=%s"
|
#define PAT "%s/media/%s%s?hmac=%s"
|
||||||
size_t l;
|
size_t l;
|
||||||
if (!data || !mxc)
|
if (!data || !mxc)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
#define DEFAULT_PROSODY_PORT 5347
|
#define DEFAULT_PROSODY_PORT 5347
|
||||||
|
|
||||||
XMPPComponent *
|
XMPPComponent *
|
||||||
XMPPInitialiseCompStream(char *host, int port)
|
XMPPInitialiseCompStream(char *addr, char *host, int port)
|
||||||
{
|
{
|
||||||
int sd = -1;
|
int sd = -1;
|
||||||
struct addrinfo hints, *res, *res0;
|
struct addrinfo hints, *res, *res0;
|
||||||
|
|
@ -28,12 +28,17 @@ XMPPInitialiseCompStream(char *host, int port)
|
||||||
Stream *stream;
|
Stream *stream;
|
||||||
XMPPComponent *comp;
|
XMPPComponent *comp;
|
||||||
|
|
||||||
|
if (!addr)
|
||||||
|
{
|
||||||
|
addr = host;
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(serv, sizeof(serv), "%hu", port ? port : DEFAULT_PROSODY_PORT);
|
snprintf(serv, sizeof(serv), "%hu", port ? port : DEFAULT_PROSODY_PORT);
|
||||||
|
|
||||||
memset(&hints, 0, sizeof(hints));
|
memset(&hints, 0, sizeof(hints));
|
||||||
hints.ai_family = AF_UNSPEC;
|
hints.ai_family = AF_UNSPEC;
|
||||||
hints.ai_socktype = SOCK_STREAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
error = getaddrinfo(host, serv, &hints, &res0);
|
error = getaddrinfo(addr, serv, &hints, &res0);
|
||||||
if (error)
|
if (error)
|
||||||
{
|
{
|
||||||
const char *error_str = gai_strerror(error);
|
const char *error_str = gai_strerror(error);
|
||||||
|
|
@ -66,6 +71,10 @@ XMPPInitialiseCompStream(char *host, int port)
|
||||||
|
|
||||||
if (sd < 0)
|
if (sd < 0)
|
||||||
{
|
{
|
||||||
|
Log(LOG_ERR,
|
||||||
|
"%s: cannot connect to '%s': no socket available", __func__,
|
||||||
|
host
|
||||||
|
);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
freeaddrinfo(res0);
|
freeaddrinfo(res0);
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,11 @@ typedef struct ParseeConfig {
|
||||||
/* Homeserver port info */
|
/* Homeserver port info */
|
||||||
char *homeserver_host;
|
char *homeserver_host;
|
||||||
int homeserver_port;
|
int homeserver_port;
|
||||||
|
int homeserver_tls;
|
||||||
|
|
||||||
|
|
||||||
/* ------- JABBER -------- */
|
/* ------- JABBER -------- */
|
||||||
|
char *component_addr;
|
||||||
char *component_host;
|
char *component_host;
|
||||||
char *shared_comp_secret;
|
char *shared_comp_secret;
|
||||||
int component_port;
|
int component_port;
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,7 @@ typedef struct ParseeCmdArg {
|
||||||
X_ROUTE("/_matrix/app/v1/users/(.*)", RouteUserAck) \
|
X_ROUTE("/_matrix/app/v1/users/(.*)", RouteUserAck) \
|
||||||
X_ROUTE("/_matrix/app/v1/rooms/(.*)", RouteRoomAck) \
|
X_ROUTE("/_matrix/app/v1/rooms/(.*)", RouteRoomAck) \
|
||||||
X_ROUTE("/_matrix/app/v1/ping", RoutePing) \
|
X_ROUTE("/_matrix/app/v1/ping", RoutePing) \
|
||||||
X_ROUTE("/_matrix/client/v1/media/download/(.*)/(.*)", RouteMedia)
|
X_ROUTE("/media/(.*)/(.*)", RouteMedia)
|
||||||
|
|
||||||
#define X_ROUTE(path, name) extern void * name(Array *, void *);
|
#define X_ROUTE(path, name) extern void * name(Array *, void *);
|
||||||
ROUTES
|
ROUTES
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ typedef struct XMPPComponent {
|
||||||
|
|
||||||
/* Initialises a raw component stream to host, with an optional port.
|
/* Initialises a raw component stream to host, with an optional port.
|
||||||
* If said port is 0, then it is set to the default Prosody port */
|
* If said port is 0, then it is set to the default Prosody port */
|
||||||
extern XMPPComponent * XMPPInitialiseCompStream(char *host, int port);
|
extern XMPPComponent * XMPPInitialiseCompStream(char *addr, char *host, int port);
|
||||||
|
|
||||||
/* Authenticates a component stream with a given shared secret,
|
/* Authenticates a component stream with a given shared secret,
|
||||||
* with a stream ID from the server. This should be called right
|
* with a stream ID from the server. This should be called right
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue