fix: use either HEADSCALE_URL or config.server_url

This commit is contained in:
Aarnav Tale 2024-03-30 19:00:59 -04:00
parent a47fb61549
commit 78140927ad
No known key found for this signature in database
3 changed files with 29 additions and 8 deletions

View file

@ -161,6 +161,7 @@ type Context = {
hasConfigWrite: boolean;
hasAcl: boolean;
hasAclWrite: boolean;
headscaleUrl: string;
}
export let context: Context
@ -172,13 +173,29 @@ export async function getContext() {
hasConfig: await hasConfig(),
hasConfigWrite: await hasConfigW(),
hasAcl: await hasAcl(),
hasAclWrite: await hasAclW()
hasAclWrite: await hasAclW(),
headscaleUrl: await getHeadscaleUrl()
}
}
return context
}
async function getHeadscaleUrl() {
if (process.env.HEADSCALE_URL) {
return process.env.HEADSCALE_URL
}
try {
const config = await getConfig()
if (config.server_url) {
return config.server_url
}
} catch {}
return ''
}
async function checkSock() {
try {
await access('/var/run/docker.sock', constants.R_OK)