hive-gateway: hoist publicScheme/Port helpers to outer let (argus 🟡 on #848)
This commit is contained in:
parent
314f1774d8
commit
c7777f3d58
1 changed files with 18 additions and 17 deletions
|
|
@ -385,6 +385,20 @@ in
|
||||||
sslCertificate = tlsCert;
|
sslCertificate = tlsCert;
|
||||||
sslCertificateKey = tlsKey;
|
sslCertificateKey = tlsKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Public-facing scheme + port-suffix for URLs the gateway
|
||||||
|
# mints into responses (well-known JSON, the deprecated
|
||||||
|
# `<hive>/matrix/*` 301 redirect, future absolute-URL needs).
|
||||||
|
# When self-signed TLS is on, prefer `https://<host>` (matrix-
|
||||||
|
# spec compliance) — 443 elides the port. Otherwise fall back
|
||||||
|
# to the plain-http listen with the bare port. See
|
||||||
|
# `docs/gateway.md` ("Self-signed TLS"). Shared at this scope
|
||||||
|
# (was inlined twice, argus 🟡 on #848).
|
||||||
|
publicScheme = if cfg.selfSignedTls then "https" else "http";
|
||||||
|
publicPort = if cfg.selfSignedTls then cfg.httpsPort else cfg.port;
|
||||||
|
publicPortDefault = if cfg.selfSignedTls then 443 else 80;
|
||||||
|
publicPortSuffix =
|
||||||
|
if publicPort == publicPortDefault then "" else ":${toString publicPort}";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
system.stateVersion = "26.05";
|
system.stateVersion = "26.05";
|
||||||
|
|
@ -458,16 +472,7 @@ in
|
||||||
# map.
|
# map.
|
||||||
lib.optionalAttrs (matrixCfg.enable && matrixCfg.gui.enable && matrixCfg.gatewayHost != null) (
|
lib.optionalAttrs (matrixCfg.enable && matrixCfg.gui.enable && matrixCfg.gatewayHost != null) (
|
||||||
let
|
let
|
||||||
# Public-facing scheme + port-suffix. When self-signed TLS
|
target = "${publicScheme}://${matrixCfg.gatewayHost}${publicPortSuffix}";
|
||||||
# is on, prefer https://<host> (matrix-spec compliance);
|
|
||||||
# 443 elides the port. Otherwise fall back to the
|
|
||||||
# plain-http listen with the bare port. See
|
|
||||||
# `docs/gateway.md` ("Self-signed TLS").
|
|
||||||
scheme = if cfg.selfSignedTls then "https" else "http";
|
|
||||||
activePort = if cfg.selfSignedTls then cfg.httpsPort else cfg.port;
|
|
||||||
defaultPort = if cfg.selfSignedTls then 443 else 80;
|
|
||||||
portSuffix = if activePort == defaultPort then "" else ":${toString activePort}";
|
|
||||||
target = "${scheme}://${matrixCfg.gatewayHost}${portSuffix}";
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
"/matrix/" = {
|
"/matrix/" = {
|
||||||
|
|
@ -486,18 +491,14 @@ in
|
||||||
# client-bootstrap sequence.
|
# client-bootstrap sequence.
|
||||||
lib.optionalAttrs (matrixCfg.enable && hyperhiveDomain != null) (
|
lib.optionalAttrs (matrixCfg.enable && hyperhiveDomain != null) (
|
||||||
let
|
let
|
||||||
scheme = if cfg.selfSignedTls then "https" else "http";
|
|
||||||
activePort = if cfg.selfSignedTls then cfg.httpsPort else cfg.port;
|
|
||||||
defaultPort = if cfg.selfSignedTls then 443 else 80;
|
|
||||||
portSuffix = if activePort == defaultPort then "" else ":${toString activePort}";
|
|
||||||
clientBaseUrl =
|
clientBaseUrl =
|
||||||
if matrixCfg.gatewayHost != null then
|
if matrixCfg.gatewayHost != null then
|
||||||
"${scheme}://${matrixCfg.gatewayHost}${portSuffix}"
|
"${publicScheme}://${matrixCfg.gatewayHost}${publicPortSuffix}"
|
||||||
else
|
else
|
||||||
"${scheme}://${hyperhiveDomain}:${toString matrixCfg.httpPort}";
|
"${publicScheme}://${hyperhiveDomain}:${toString matrixCfg.httpPort}";
|
||||||
serverHostPort =
|
serverHostPort =
|
||||||
if matrixCfg.gatewayHost != null then
|
if matrixCfg.gatewayHost != null then
|
||||||
"${matrixCfg.gatewayHost}${portSuffix}"
|
"${matrixCfg.gatewayHost}${publicPortSuffix}"
|
||||||
else
|
else
|
||||||
"${hyperhiveDomain}:${toString matrixCfg.httpPort}";
|
"${hyperhiveDomain}:${toString matrixCfg.httpPort}";
|
||||||
in
|
in
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue