diff options
-rw-r--r-- | docker/netiquette/.gitignore (renamed from docker/tag-config/.gitignore) | 0 | ||||
-rw-r--r-- | docker/netiquette/README.md (renamed from docker/tag-config/README.md) | 2 | ||||
-rw-r--r-- | docker/netiquette/index.mjs (renamed from docker/tag-config/index.mjs) | 11 | ||||
-rw-r--r-- | docker/netiquette/package-lock.json (renamed from docker/tag-config/package-lock.json) | 0 | ||||
-rw-r--r-- | docker/netiquette/package.json (renamed from docker/tag-config/package.json) | 2 | ||||
-rw-r--r-- | docker/netiquette/src/catalog/consul.mjs (renamed from docker/tag-config/src/catalog/consul.mjs) | 0 | ||||
-rw-r--r-- | docker/netiquette/src/catalog/control_loop.mjs | 10 | ||||
-rw-r--r-- | docker/netiquette/src/injector/iptables.mjs (renamed from docker/tag-config/src/injector/iptables.mjs) | 0 | ||||
-rw-r--r-- | docker/netiquette/src/injector/upnp.mjs (renamed from docker/tag-config/src/injector/upnp.mjs) | 0 | ||||
-rw-r--r-- | docker/netiquette/src/io/files.mjs (renamed from docker/tag-config/src/io/files.mjs) | 0 | ||||
-rw-r--r-- | docker/netiquette/src/io/run.mjs (renamed from docker/tag-config/src/io/run.mjs) | 0 | ||||
-rw-r--r-- | docker/netiquette/static.iptables (renamed from docker/tag-config/static.iptables) | 0 | ||||
-rw-r--r-- | docker/netiquette/test/io.mjs (renamed from docker/tag-config/test/io.mjs) | 0 | ||||
-rw-r--r-- | docker/netiquette/test/iptables.mjs (renamed from docker/tag-config/test/iptables.mjs) | 0 | ||||
-rw-r--r-- | docker/netiquette/test/runner.mjs (renamed from docker/tag-config/test/runner.mjs) | 0 |
15 files changed, 20 insertions, 5 deletions
diff --git a/docker/tag-config/.gitignore b/docker/netiquette/.gitignore index 3c3629e..3c3629e 100644 --- a/docker/tag-config/.gitignore +++ b/docker/netiquette/.gitignore diff --git a/docker/tag-config/README.md b/docker/netiquette/README.md index 0746388..e4c2f27 100644 --- a/docker/tag-config/README.md +++ b/docker/netiquette/README.md @@ -1,3 +1,5 @@ +# netiquette + ``` npm install npm test diff --git a/docker/tag-config/index.mjs b/docker/netiquette/index.mjs index a5b51fc..6aca6e4 100644 --- a/docker/tag-config/index.mjs +++ b/docker/netiquette/index.mjs @@ -3,6 +3,7 @@ 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' @@ -24,9 +25,8 @@ function* notifications_aggregator(injectors) { for(let idx = 0; true; idx++) { yield async (tag_list) => { states[idx] = tag_list - await Promise.all( - injectors.map(notify => - notify(states.reduce((acc, tag) => [...acc, ...tag], [])))) + const merged = states.reduce((acc, tag) => [...acc, ...tag], []) + await Promise.all(injectors.map(notify => notify(merged))) } } } @@ -37,12 +37,15 @@ const main = async () => { // Initialize all injectors const injectors = [ - await inj_iptables(args.ipt_base, readFile, exec, console.log) + 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) ] diff --git a/docker/tag-config/package-lock.json b/docker/netiquette/package-lock.json index a4d30b9..a4d30b9 100644 --- a/docker/tag-config/package-lock.json +++ b/docker/netiquette/package-lock.json diff --git a/docker/tag-config/package.json b/docker/netiquette/package.json index 892fb87..02fa0b3 100644 --- a/docker/tag-config/package.json +++ b/docker/netiquette/package.json @@ -1,5 +1,5 @@ { - "name": "consul-to-igd", + "name": "netiquette", "version": "1.0.0", "description": "", "main": "index.mjs", diff --git a/docker/tag-config/src/catalog/consul.mjs b/docker/netiquette/src/catalog/consul.mjs index 655c61f..655c61f 100644 --- a/docker/tag-config/src/catalog/consul.mjs +++ b/docker/netiquette/src/catalog/consul.mjs diff --git a/docker/netiquette/src/catalog/control_loop.mjs b/docker/netiquette/src/catalog/control_loop.mjs new file mode 100644 index 0000000..56ad6f5 --- /dev/null +++ b/docker/netiquette/src/catalog/control_loop.mjs @@ -0,0 +1,10 @@ +'use strict' + +let l +export default l = async (timer, interval, notify) => { + timer(() => { + notify([]) + console.log(`[control_loop] actuation (triggered every ${interval} ms)`) + }, interval) + console.log("[control_loop] initialized") +} diff --git a/docker/tag-config/src/injector/iptables.mjs b/docker/netiquette/src/injector/iptables.mjs index 584b560..584b560 100644 --- a/docker/tag-config/src/injector/iptables.mjs +++ b/docker/netiquette/src/injector/iptables.mjs diff --git a/docker/tag-config/src/injector/upnp.mjs b/docker/netiquette/src/injector/upnp.mjs index e69de29..e69de29 100644 --- a/docker/tag-config/src/injector/upnp.mjs +++ b/docker/netiquette/src/injector/upnp.mjs diff --git a/docker/tag-config/src/io/files.mjs b/docker/netiquette/src/io/files.mjs index c3eca1b..c3eca1b 100644 --- a/docker/tag-config/src/io/files.mjs +++ b/docker/netiquette/src/io/files.mjs diff --git a/docker/tag-config/src/io/run.mjs b/docker/netiquette/src/io/run.mjs index 8774043..8774043 100644 --- a/docker/tag-config/src/io/run.mjs +++ b/docker/netiquette/src/io/run.mjs diff --git a/docker/tag-config/static.iptables b/docker/netiquette/static.iptables index d9e7d38..d9e7d38 100644 --- a/docker/tag-config/static.iptables +++ b/docker/netiquette/static.iptables diff --git a/docker/tag-config/test/io.mjs b/docker/netiquette/test/io.mjs index d88ad15..d88ad15 100644 --- a/docker/tag-config/test/io.mjs +++ b/docker/netiquette/test/io.mjs diff --git a/docker/tag-config/test/iptables.mjs b/docker/netiquette/test/iptables.mjs index 1ae1cb0..1ae1cb0 100644 --- a/docker/tag-config/test/iptables.mjs +++ b/docker/netiquette/test/iptables.mjs diff --git a/docker/tag-config/test/runner.mjs b/docker/netiquette/test/runner.mjs index b4da1de..b4da1de 100644 --- a/docker/tag-config/test/runner.mjs +++ b/docker/netiquette/test/runner.mjs |