fix: matrix rtc mapping

This commit is contained in:
Katharina Heidenreich 2026-04-06 13:22:22 +02:00
parent 1a3d1f1fdd
commit 20f8049d64
4 changed files with 49 additions and 15 deletions

View file

@ -29,6 +29,19 @@ in
proxyWebsockets = true; proxyWebsockets = true;
}; };
} }
# {
# type = "proxy";
# domain = net.devices.remote_proxy.domain;
# endpoint = "/.well-known/matrix/";
# force_ssl = true;
# port = 443;
# content = {
# type = "service";
# ip = net.devices.pi.ip;
# port = services.continuwuity.port;
# proxyWebsockets = true;
# };
# }
{ {
type = "inline"; type = "inline";
domain = net.devices.remote_proxy.domain; domain = net.devices.remote_proxy.domain;
@ -37,6 +50,11 @@ in
port = 443; port = 443;
content = { content = {
contentType = "application/json"; contentType = "application/json";
headers = {
Access-Control-Allow-Origin = "*";
Access-Control-Allow-Methods = "GET, POST, PUT, DELETE, OPTIONS";
Access-Control-Allow-Headers = "X-Requested-With, Content-Type, Authorization";
};
status = 200; status = 200;
body = ''{"m.server":"${net.devices.remote_proxy.domain}:443"}''; body = ''{"m.server":"${net.devices.remote_proxy.domain}:443"}'';
}; };
@ -49,20 +67,13 @@ in
port = 443; port = 443;
content = { content = {
contentType = "application/json"; contentType = "application/json";
headers = {
Access-Control-Allow-Origin = "*";
Access-Control-Allow-Methods = "GET, POST, PUT, DELETE, OPTIONS";
Access-Control-Allow-Headers = "X-Requested-With, Content-Type, Authorization";
};
status = 200; status = 200;
body = '' body = ''{"m.homeserver": {"base_url": "https://${net.devices.remote_proxy.domain}"},"org.matrix.msc3575.proxy":{"url":"https://nudelerde.de/"},"org.matrix.msc4143.rtc_foci": [{"type": "livekit","livekit_service_url": "https://livekit.${net.devices.remote_proxy.domain}"}]}'';
{
"m.homeserver": {
"base_url": "https://${net.devices.remote_proxy.domain}"
},
"org.matrix.msc4143.rtc_foci": [
{
"type": "livekit",
"livekit_service_url": "https://livekit.${net.devices.remote_proxy.domain}"
}
]
}
'';
}; };
} }
] ]

View file

@ -8,7 +8,7 @@ rec {
server_name = "nudelerde.de"; server_name = "nudelerde.de";
trusted_servers = [ "matrix.org" ]; trusted_servers = [ "matrix.org" ];
memory_max = "512M"; memory_max = "512M";
livekit_url = "https://livekit.nudelerde.de/livekit/jwt"; livekit_url = "https://livekit.nudelerde.de";
package = { package = {
version = "0.5.6"; version = "0.5.6";

View file

@ -241,6 +241,14 @@ let
route.content.contentType route.content.contentType
else else
"text/plain; charset=utf-8"; "text/plain; charset=utf-8";
inlineHeaders =
if builtins.isAttrs route.content && route.content ? headers then
route.content.headers
else
{};
inlineHeaderLines = lib.concatStringsSep "\n" (
lib.mapAttrsToList (name: value: " add_header ${name} ${builtins.toJSON value} always;") inlineHeaders
);
in in
{ {
name = "= ${route.endpoint}"; name = "= ${route.endpoint}";
@ -248,6 +256,7 @@ let
return = "${toString inlineStatus} ${builtins.toJSON inlineBody}"; return = "${toString inlineStatus} ${builtins.toJSON inlineBody}";
extraConfig = '' extraConfig = ''
default_type ${inlineContentType}; default_type ${inlineContentType};
${lib.optionalString (inlineHeaderLines != "") inlineHeaderLines}
''; '';
}; };
} }

View file

@ -5,7 +5,7 @@ let
allowedProxyContentKeys = [ "type" "ip" "port" "proxyWebsockets" ]; allowedProxyContentKeys = [ "type" "ip" "port" "proxyWebsockets" ];
allowedWebContentKeys = [ "type" "files" ]; allowedWebContentKeys = [ "type" "files" ];
allowedWebFileKeys = [ "path" "filePath" "contentType" "status" ]; allowedWebFileKeys = [ "path" "filePath" "contentType" "status" ];
allowedInlineContentKeys = [ "body" "contentType" "status" ]; allowedInlineContentKeys = [ "body" "contentType" "headers" "status" ];
allowedRedirectContentKeys = [ "target" "status" ]; allowedRedirectContentKeys = [ "target" "status" ];
ensureNoUnknownKeys = context: obj: allowedKeys: ensureNoUnknownKeys = context: obj: allowedKeys:
@ -168,6 +168,20 @@ let
null null
else else
throw "Inline endpoint at index ${toString index} content.contentType must be a non-empty string when provided."; throw "Inline endpoint at index ${toString index} content.contentType must be a non-empty string when provided.";
________ =
if contentValue ? headers then
if builtins.isAttrs contentValue.headers then
let
headerValues = builtins.attrValues contentValue.headers;
in
if lib.all (value: builtins.isString value && value != "") headerValues then
null
else
throw "Inline endpoint at index ${toString index} content.headers values must be non-empty strings."
else
throw "Inline endpoint at index ${toString index} content.headers must be an attrset when provided."
else
null;
_______ = _______ =
if !(contentValue ? status) || builtins.isInt contentValue.status then if !(contentValue ? status) || builtins.isInt contentValue.status then
null null