fix: web access
This commit is contained in:
1 file changed
+20
-25
+20
-25
@@ -20,8 +20,7 @@ let
|
|||||||
wgIf = "wg-seedbox";
|
wgIf = "wg-seedbox";
|
||||||
dataDir = "/var/lib/seedbox";
|
dataDir = "/var/lib/seedbox";
|
||||||
downloadsDir = "${dataDir}/downloads";
|
downloadsDir = "${dataDir}/downloads";
|
||||||
webuiProxyPort = 8081; # localhost of this host only
|
webuiPort = 8081;
|
||||||
webuiPort = 8080; # inside the namespace
|
|
||||||
sharePort = 8091;
|
sharePort = 8091;
|
||||||
|
|
||||||
secret = name: config.sops.secrets."seedbox/${name}".path;
|
secret = name: config.sops.secrets."seedbox/${name}".path;
|
||||||
@@ -130,8 +129,8 @@ in
|
|||||||
InaccessiblePaths = [ "-/run/nscd" ];
|
InaccessiblePaths = [ "-/run/nscd" ];
|
||||||
ReadWritePaths = [ dataDir ];
|
ReadWritePaths = [ dataDir ];
|
||||||
|
|
||||||
# Initial settings, and the incoming port from the secret on every start. Other
|
# Defaults on first start, and the settings this setup depends on on every
|
||||||
# settings are left to the web interface.
|
# start. Everything else is left to the web interface.
|
||||||
ExecStartPre = pkgs.writeShellScript "seedbox-config" ''
|
ExecStartPre = pkgs.writeShellScript "seedbox-config" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
PATH=${
|
PATH=${
|
||||||
@@ -139,33 +138,29 @@ in
|
|||||||
with pkgs;
|
with pkgs;
|
||||||
[
|
[
|
||||||
coreutils
|
coreutils
|
||||||
gnused
|
crudini
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
port=$(tr -dc 0-9 < ${secret "port"})
|
|
||||||
cfg=${dataDir}/qBittorrent/config/qBittorrent.conf
|
cfg=${dataDir}/qBittorrent/config/qBittorrent.conf
|
||||||
mkdir -p ${downloadsDir} "$(dirname "$cfg")"
|
mkdir -p ${downloadsDir} "$(dirname "$cfg")"
|
||||||
|
set_() { crudini --set "$cfg" "$@"; }
|
||||||
|
|
||||||
if [ ! -f "$cfg" ]; then
|
if [ ! -f "$cfg" ]; then
|
||||||
cat > "$cfg" <<EOF
|
touch "$cfg"
|
||||||
[BitTorrent]
|
set_ BitTorrent 'Session\DefaultSavePath' ${downloadsDir}
|
||||||
Session\DefaultSavePath=${downloadsDir}
|
set_ BitTorrent 'Session\LSDEnabled' false
|
||||||
Session\Interface=${wgIf}
|
set_ BitTorrent 'Session\QueueingSystemEnabled' false
|
||||||
Session\InterfaceName=${wgIf}
|
|
||||||
Session\LSDEnabled=false
|
|
||||||
Session\QueueingSystemEnabled=false
|
|
||||||
Session\Port=$port
|
|
||||||
|
|
||||||
[Network]
|
|
||||||
PortForwardingEnabled=false
|
|
||||||
|
|
||||||
[Preferences]
|
|
||||||
WebUI\Address=127.0.0.1
|
|
||||||
WebUI\Port=${toString webuiPort}
|
|
||||||
EOF
|
|
||||||
else
|
|
||||||
sed -i -E "s|^Session\\\\Port=.*|Session\\\\Port=$port|" "$cfg"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
set_ BitTorrent 'Session\Port' "$(tr -dc 0-9 < ${secret "port"})"
|
||||||
|
set_ BitTorrent 'Session\Interface' ${wgIf}
|
||||||
|
set_ BitTorrent 'Session\InterfaceName' ${wgIf}
|
||||||
|
set_ Network PortForwardingEnabled false
|
||||||
|
set_ Preferences 'WebUI\Address' 127.0.0.1
|
||||||
|
set_ Preferences 'WebUI\Port' ${toString webuiPort}
|
||||||
|
# Only reachable through this host's localhost
|
||||||
|
set_ Preferences 'WebUI\HostHeaderValidation' false
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -173,7 +168,7 @@ in
|
|||||||
# Web interface on this host's localhost, proxied into the namespace
|
# Web interface on this host's localhost, proxied into the namespace
|
||||||
systemd.sockets.seedbox-webui = {
|
systemd.sockets.seedbox-webui = {
|
||||||
wantedBy = [ "sockets.target" ];
|
wantedBy = [ "sockets.target" ];
|
||||||
listenStreams = [ "127.0.0.1:${toString webuiProxyPort}" ];
|
listenStreams = [ "127.0.0.1:${toString webuiPort}" ];
|
||||||
};
|
};
|
||||||
systemd.services.seedbox-webui = netnsDeps // {
|
systemd.services.seedbox-webui = netnsDeps // {
|
||||||
requires = [ "qbittorrent.service" ];
|
requires = [ "qbittorrent.service" ];
|
||||||
|
|||||||
Reference in new issue
Block a user