-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use an actual config, systemd template, minor fixes
- Loading branch information
Showing
7 changed files
with
111 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ | |
/node_modules | ||
|
||
/.idea | ||
|
||
/config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,30 @@ | ||
import { mkdir, readdir, readFile, writeFile } from 'fs/promises'; | ||
import { mkdir, readdir, readFile, writeFile, realpath } from 'fs/promises'; | ||
|
||
async function main() { | ||
|
||
const args = process.argv.slice(2); | ||
|
||
if (args.length != 4) { | ||
console.log('Usage: node build.js base_host ip4_host ip6_host root_dir'); | ||
return; | ||
} | ||
|
||
const [BASE_HOST, IP4_HOST, IP6_HOST, DIST_DIR] = args; | ||
const vars = { BASE_HOST, IP4_HOST, IP6_HOST, DIST_DIR }; | ||
console.log(vars); | ||
|
||
|
||
const { default: config } = await import('./config.js'); | ||
|
||
await mkdir('dist', { recursive: true }); | ||
await mkdir('conf', { recursive: true }); | ||
|
||
|
||
const DIST_DIR = await realpath('dist'); | ||
const CONF_DIR = await realpath('conf'); | ||
const [BASE_HOST, IP4_HOST, IP6_HOST, PONG_PORT] = [config.baseHost, config.ipv4Host, config.ipv4Host, config.pongServerPort]; | ||
const CONFIG_JSON = JSON.stringify(config); | ||
|
||
const vars = { BASE_HOST, IP4_HOST, IP6_HOST, DIST_DIR, CONF_DIR, PONG_PORT, CONFIG_JSON }; | ||
console.log(vars); | ||
|
||
const files = await readdir('template'); | ||
for (const fn of files) { | ||
let src = await readFile(`template/${fn}`, 'utf-8'); | ||
for (const [key, val] of Object.entries(vars)) { | ||
src = src.replaceAll(key, val); | ||
} | ||
const out = fn.match(/\.conf$/) ? 'conf' : 'dist'; | ||
const out = fn.match(/\.(conf|service)$/) ? 'conf' : 'dist'; | ||
await writeFile(`${out}/${fn}`, src); | ||
} | ||
|
||
} | ||
|
||
await main(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const baseHost = 'this.computer'; | ||
|
||
export default { | ||
|
||
baseHost, | ||
|
||
// This should only have an A record. | ||
ipv4Host: `4.${baseHost}`, | ||
// This should only have an AAAA record. | ||
ipv6Host: `6.${baseHost}`, | ||
|
||
graphWindow: 30_000, | ||
jitterWindow: 10_000, | ||
graphScale: 500, // ms | ||
|
||
pingServers: [ | ||
{ | ||
label: 'EU', | ||
host: baseHost, | ||
}, | ||
/*{ | ||
label: 'EU', | ||
host: baseHost, | ||
},*/ | ||
], | ||
|
||
pingServerPort: 1234, | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters