Make the compose file work with older docker-compose

List the variables instead of an optional env_file; the proxy treats empty
variables as unset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 21:46:45 +02:00
co-authored by Claude Opus 5.5
parent 5159d8a518
commit e649062d67
3 changed files with 24 additions and 4 deletions
+13 -3
View File
@@ -9,8 +9,18 @@ services:
# forwarding it would often see Docker's own) and a Mumble server on this machine is
# reachable as localhost. The proxy listens on 127.0.0.1:8080 for nginx and on UDP 3478.
network_mode: host
env_file:
- path: .env
required: false
# Passed on from .env (or the shell); empty means the proxy's default. Written out one by
# one because older docker-compose versions cannot mark an env_file as optional.
environment:
MUMH5_SERVERS: ${MUMH5_SERVERS:-}
MUMH5_ALLOW_ANY: ${MUMH5_ALLOW_ANY:-}
MUMH5_ALLOW_PRIVATE: ${MUMH5_ALLOW_PRIVATE:-}
MUMH5_PORT: ${MUMH5_PORT:-8080}
MUMH5_BIND: ${MUMH5_BIND:-127.0.0.1}
MUMH5_ORIGINS: ${MUMH5_ORIGINS:-}
MUMH5_TRUST_PROXY: ${MUMH5_TRUST_PROXY:-}
MUMH5_SEND_PROXY: ${MUMH5_SEND_PROXY:-}
MUMH5_STUN_PORT: ${MUMH5_STUN_PORT:-3478}
MUMH5_STUN_BIND: ${MUMH5_STUN_BIND:-}
MUMH5_MAX_CONNECTIONS: ${MUMH5_MAX_CONNECTIONS:-}
MUMH5_MAX_PER_ADDRESS: ${MUMH5_MAX_PER_ADDRESS:-}
+3 -1
View File
@@ -55,7 +55,9 @@ export function parseServers(list: string): AllowedServer[] {
});
}
export function configFromEnv(env: NodeJS.ProcessEnv): ProxyConfig {
export function configFromEnv(source: NodeJS.ProcessEnv): ProxyConfig {
// A variable set to nothing counts as not set (docker-compose passes unset ones on that way)
const env = Object.fromEntries(Object.entries(source).filter(([, v]) => v !== '')) as NodeJS.ProcessEnv;
const on = (v?: string) => v === '1' || v === 'true';
return {
...defaults,
+8
View File
@@ -6,6 +6,7 @@ import dgram from 'node:dgram';
import assert from 'node:assert/strict';
import { proxyLine } from '../electron/tls-transport.ts';
import { stunResponse } from '../server/proxy.ts';
import { configFromEnv } from '../server/proxy.ts';
import { startProxy, defaults, parseServers, isPrivateAddress, type ProxyConfig } from '../server/proxy.ts';
import { WebSocket as WsClient } from 'ws';
import { WebSocketTransport } from '../src/core/ws-transport.ts';
@@ -31,6 +32,13 @@ test('server list parsing', () => {
assert.deepEqual(parseServers(''), []);
});
test('empty environment variables fall back to the defaults', () => {
const c = configFromEnv({ MUMH5_PORT: '', MUMH5_BIND: '', MUMH5_STUN_PORT: '', MUMH5_STUN_BIND: '', MUMH5_MAX_CONNECTIONS: '', MUMH5_SERVERS: 'a.example', MUMH5_ALLOW_ANY: '' });
assert.deepEqual([c.port, c.bind, c.stunPort, c.stunBind, c.maxConnections, c.allowAny], [8080, '127.0.0.1', 3478, '::', 200, false]);
assert.equal(configFromEnv({ MUMH5_STUN_PORT: '0' }).stunPort, null);
assert.equal(configFromEnv({ MUMH5_PORT: '8089' }).port, 8089);
});
test('private address detection', () => {
for (const a of ['127.0.0.1', '10.1.2.3', '192.168.1.1', '172.20.0.1', '169.254.1.1', '100.64.0.1', '::1', 'fd00::1', 'fe80::1', '::ffff:10.0.0.1']) assert.ok(isPrivateAddress(a), a);
for (const a of ['8.8.8.8', '172.32.0.1', '2001:4860:4860::8888', '::ffff:8.8.8.8']) assert.ok(!isPrivateAddress(a), a);