refactor: modify string injection to use lib.optionalString instead of if-then-else
All checks were successful
ci / treefmt (push) Successful in 2m2s
All checks were successful
ci / treefmt (push) Successful in 2m2s
This commit is contained in:
parent
009ffea910
commit
e636f327ed
1 changed files with 20 additions and 31 deletions
|
|
@ -5,7 +5,7 @@
|
|||
namespace,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkIf mkEnableOption mapAttrsToList listToAttrs replaceStrings mkMerge concatStringsSep filterAttrs;
|
||||
inherit (lib) mkIf mkEnableOption mapAttrsToList listToAttrs replaceStrings mkMerge concatStringsSep filterAttrs optionalString;
|
||||
inherit (lib.${namespace}) getAttrByNamespace mkOptionsWithNamespace resolveHostIP isGateway flattenHostServices;
|
||||
inherit (config.networking) hostName;
|
||||
inherit (config.sops) secrets;
|
||||
|
|
@ -57,34 +57,25 @@
|
|||
|
||||
miasma = networkServicesFlat.miasma;
|
||||
|
||||
honeypotConfig =
|
||||
if injectHoneypot
|
||||
then ''
|
||||
AddOutputFilterByType SUBSTITUTE text/html
|
||||
SubstituteMaxLineLength 30m
|
||||
Substitute 's|</body>|<a href="${miasmaCfg.linkPrefix}/" style="display:none" aria-hidden="true" tabindex="-1">Amazing high quality data here!</a></body>|i'
|
||||
honeypotConfig = optionalString injectHoneypot ''
|
||||
AddOutputFilterByType SUBSTITUTE text/html
|
||||
SubstituteMaxLineLength 30m
|
||||
Substitute 's|</body>|<a href="${miasmaCfg.linkPrefix}/" style="display:none" aria-hidden="true" tabindex="-1">Amazing high quality data here!</a></body>|i'
|
||||
|
||||
ProxyPass ${miasmaCfg.linkPrefix}/ http://${resolveHostIP networkingCfg.devices miasma.host}:${toString miasma.port}/
|
||||
ProxyPassReverse ${miasmaCfg.linkPrefix}/ http://${resolveHostIP networkingCfg.devices miasma.host}:${toString miasma.port}/
|
||||
''
|
||||
else "";
|
||||
ProxyPass ${miasmaCfg.linkPrefix}/ http://${resolveHostIP networkingCfg.devices miasma.host}:${toString miasma.port}/
|
||||
ProxyPassReverse ${miasmaCfg.linkPrefix}/ http://${resolveHostIP networkingCfg.devices miasma.host}:${toString miasma.port}/
|
||||
|
||||
robotsConfig =
|
||||
if injectHoneypot
|
||||
then ''
|
||||
ProxyPass /robots.txt !
|
||||
Alias /robots.txt ${inputs.dotfiles}/httpd/robots/${name}.txt
|
||||
''
|
||||
else "";
|
||||
ProxyPass /robots.txt !
|
||||
Alias /robots.txt ${inputs.dotfiles}/httpd/robots/${name}.txt
|
||||
|
||||
websocketConfig =
|
||||
if service.websocket
|
||||
then ''
|
||||
# --- ${name} (websocket access) ---
|
||||
ProxyPass /socket ws://${hostIP}:${p}/socket connectiontimeout=30 timeout=300 retry=0
|
||||
ProxyPassReverse /socket ws://${hostIP}:${p}/socket
|
||||
''
|
||||
else "";
|
||||
'';
|
||||
|
||||
websocketConfig = optionalString service.websocket ''
|
||||
# --- ${name} (websocket access) ---
|
||||
ProxyPass /socket ws://${hostIP}:${p}/socket connectiontimeout=30 timeout=300 retry=0
|
||||
ProxyPassReverse /socket ws://${hostIP}:${p}/socket
|
||||
|
||||
'';
|
||||
in {
|
||||
name = replaceStrings ["*"] [name] domain;
|
||||
value =
|
||||
|
|
@ -107,8 +98,6 @@
|
|||
|
||||
${honeypotConfig}
|
||||
|
||||
${robotsConfig}
|
||||
|
||||
${websocketConfig}
|
||||
|
||||
# --- ${name} (subdomain access) ---
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue