aboutsummaryrefslogtreecommitdiff
path: root/docker/netiquette/index.mjs
diff options
context:
space:
mode:
authorQuentin <quentin@deuxfleurs.fr>2020-02-09 20:09:20 +0100
committerQuentin <quentin@deuxfleurs.fr>2020-02-09 20:09:20 +0100
commit96c6da392fc3236754c273a299728ad0360b3d51 (patch)
treedb6732c726c731396b482debe329cd5894613d02 /docker/netiquette/index.mjs
parentba5590ce97953f66702b149fd7840bcb58d4b463 (diff)
downloadinfrastructure-96c6da392fc3236754c273a299728ad0360b3d51.tar.gz
infrastructure-96c6da392fc3236754c273a299728ad0360b3d51.zip
[diplomate] Skeleton for our UPNP configurator
Diffstat (limited to 'docker/netiquette/index.mjs')
-rw-r--r--docker/netiquette/index.mjs59
1 files changed, 0 insertions, 59 deletions
diff --git a/docker/netiquette/index.mjs b/docker/netiquette/index.mjs
deleted file mode 100644
index 41b27e3..0000000
--- a/docker/netiquette/index.mjs
+++ /dev/null
@@ -1,59 +0,0 @@
-'use strict'
-import consul from 'consul'
-import { exec } from './src/io/run.mjs'
-import { readFile } from './src/io/files.mjs'
-
-import ctlg_control_loop from './src/catalog/control_loop.mjs'
-import ctlg_consul from './src/catalog/consul.mjs'
-import inj_iptables from './src/injector/iptables.mjs'
-
-const get_args = () => process
- .argv
- .slice(2)
- .map(a => a.split('='))
- .reduce((dict, tuple) => {
- dict[tuple[0]] = tuple.length > 1 ? tuple[1] : null
- return dict
- }, {})
-
-/**
- * If we have multiple catalogs
- * we cache the results of the other ones
- */
-function* notifications_aggregator(injectors) {
- const states = []
- for(let idx = 0; true; idx++) {
- yield async (tag_list) => {
- states[idx] = tag_list
- const merged = states.reduce((acc, tag) => [...acc, ...tag], [])
- await Promise.all(injectors.map(notify => notify(merged)))
- }
- }
-}
-
-const main = async () => {
- try {
- const args = get_args()
-
- // Initialize all injectors
- const injectors = [
- await inj_iptables(args.ipt_base, readFile, exec, console.log),
- // await inj_upnp
- ]
-
- // Initialize all catalogs and map them to the injectors
- const aggr = notifications_aggregator(injectors)
- const catalogs = [
- // this catalog is used to defeat deriving config due to single resource updated async. by multiple prog or by external program not tracked by catalogs
- await ctlg_control_loop(setInterval, 60000, aggr.next().value),
- await ctlg_consul(args.node, consul(), console.log, aggr.next().value)
- ]
-
- console.log("[main] initialized")
- } catch(e) {
- console.error("initialization failed", e)
- process.exit(1)
- }
-}
-
-main()