Asterisk to allow all zones
gitea/docker-discover/pipeline/head This commit looks good Details

This commit is contained in:
Juan Ferrer 2021-11-22 18:37:29 +01:00
parent 7907f7c363
commit 25bc1e2b37
2 changed files with 20 additions and 7 deletions

View File

@ -33,9 +33,7 @@ acls:
sysadmin: sysadmin:
ips: ips:
- 10.5.1.0/24 - 10.5.1.0/24
zones: zones: *
- dmz
- it
defaults: defaults:
https: true https: true
zone: public zone: public

View File

@ -154,12 +154,13 @@ async function updateProxy(firstRun) {
console.log('Saved settings hash:', lastInfoHash); console.log('Saved settings hash:', lastInfoHash);
} }
// Fetch backends
const hostMap = []; const hostMap = [];
const baseMap = []; const baseMap = [];
const https = []; const https = [];
const zoneMap = []; const zoneMap = [];
const aclMap = []; const zones = new Set();
const accessMap = [];
for (const domain in conf.domains) { for (const domain in conf.domains) {
const domainConf = conf.domains[domain]; const domainConf = conf.domains[domain];
@ -181,8 +182,10 @@ async function updateProxy(firstRun) {
if (serviceConf.https) if (serviceConf.https)
https.push(service); https.push(service);
if (serviceConf.zone) if (serviceConf.zone) {
zoneMap.push([service, serviceConf.zone]); zoneMap.push([service, serviceConf.zone]);
zones.add(serviceConf.zone);
}
rules = rules || serviceConf.rules; rules = rules || serviceConf.rules;
@ -215,19 +218,26 @@ async function updateProxy(firstRun) {
} }
} }
// Fetch ACLs
const aclMap = [];
const acls = []; const acls = [];
for (const acl in conf.acls) { for (const acl in conf.acls) {
const aclConf = conf.acls[acl]; const aclConf = conf.acls[acl];
const ips = []; const ips = [];
for (const ip of aclConf.ips) { for (const ip of aclConf.ips) {
aclMap.push([ip, acl]); aclMap.push([ip, acl]);
ips.push(parseNet(ip)); ips.push(parseNet(ip));
} }
acls.push({ acls.push({
name: acl, name: acl,
ips, ips,
zones: new Set(aclConf.zones) zones: aclConf.zones === '*'
? new Set(zones)
: new Set(aclConf.zones)
}); });
} }
@ -260,10 +270,13 @@ async function updateProxy(firstRun) {
} }
}}} }}}
const accessMap = [];
for (const acl of acls) for (const acl of acls)
for (const zone of acl.zones) for (const zone of acl.zones)
accessMap.push(`${acl.name}/${zone}`); accessMap.push(`${acl.name}/${zone}`);
// Generate maps
const files = { const files = {
host: hostMap, host: hostMap,
base: baseMap, base: baseMap,
@ -303,6 +316,8 @@ async function updateProxy(firstRun) {
await fs.close(fd); await fs.close(fd);
} }
// Initalize
await updateProxy(true); await updateProxy(true);
console.log('Listening for events.') console.log('Listening for events.')