Commit a3f1b865 authored by nanahira's avatar nanahira

add LIMIT_LINKS

parent 34877995
...@@ -37,6 +37,7 @@ class InventoryBuilder { ...@@ -37,6 +37,7 @@ class InventoryBuilder {
resolver: dns.Resolver; resolver: dns.Resolver;
vars: any; vars: any;
linksOnly: string[]; linksOnly: string[];
linksLimit: string[];
constructor() { constructor() {
this.resolveCache = new Map(); this.resolveCache = new Map();
...@@ -111,6 +112,9 @@ class InventoryBuilder { ...@@ -111,6 +112,9 @@ class InventoryBuilder {
if (process.env.ONLY_LINKS) { if (process.env.ONLY_LINKS) {
this.linksOnly = process.env.ONLY_LINKS.split(","); this.linksOnly = process.env.ONLY_LINKS.split(",");
} }
if (process.env.LIMIT_LINKS) {
this.linksLimit = process.env.linksLimit.split(",");
}
this.vars = await this.loadUtilities(); this.vars = await this.loadUtilities();
const inventoryValue = { wg: {hosts: Object.fromEntries(Object.values(this.hosts).map(host => [host.name, this.getHostConnectionInfo(host)]))} }; const inventoryValue = { wg: {hosts: Object.fromEntries(Object.values(this.hosts).map(host => [host.name, this.getHostConnectionInfo(host)]))} };
await fs.promises.writeFile('result/inventory.yaml', YAML.stringify(inventoryValue)); await fs.promises.writeFile('result/inventory.yaml', YAML.stringify(inventoryValue));
...@@ -415,7 +419,7 @@ class InventoryBuilder { ...@@ -415,7 +419,7 @@ class InventoryBuilder {
console.log(`${local.name} GW ${localGateway.isp} ${inbound ? '<' : '='}=${frpType === 'frps' ? 's' : '='}=[${protocol}]=${frpType === 'frpc' ? 's' : '='}=> ${remote.name} GW ${remoteGateway.isp}`); console.log(`${local.name} GW ${localGateway.isp} ${inbound ? '<' : '='}=${frpType === 'frps' ? 's' : '='}=[${protocol}]=${frpType === 'frpc' ? 's' : '='}=> ${remote.name} GW ${remoteGateway.isp}`);
} }
const noUpdate = this.linksOnly && !(this.linksOnly.includes(remote.name) || this.linksOnly.includes(local.name)); const noUpdate = this.linksOnly && !(this.linksOnly.includes(remote.name) || this.linksOnly.includes(local.name)) || this.linksLimit && !(this.linksLimit.includes(remote.name) && this.linksLimit.includes(local.name));
return { return {
name, name,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment