diff --git a/cli/src/generate.js b/cli/src/generate.js index 311272e..881cb2c 100644 --- a/cli/src/generate.js +++ b/cli/src/generate.js @@ -112,6 +112,8 @@ const generateConfig = async () => { const externalIPAddresses = configData.publicIps.split(','); + const wireguardPortsList = configData.wireguardPorts ? configData.wireguardPorts.split(',') : null; + // Add name to config config.name = configData.name.toLowerCase().replace(/\s/g, '-'); @@ -142,7 +144,7 @@ const generateConfig = async () => { config = { ...config, ...await generateServiceConfig(configData, config.nodesNumber) }; // Adding wireguard config - config = { ...config, ...await generateWireguardConfig(externalIPAddresses) }; + config = { ...config, ...await generateWireguardConfig(externalIPAddresses, wireguardPortsList) }; // Adding Archipel config config = { ...config, ...await generateArchipelConfig(config.nodesNumber) }; diff --git a/cli/src/init.js b/cli/src/init.js index bd53091..6bed27b 100644 --- a/cli/src/init.js +++ b/cli/src/init.js @@ -11,6 +11,7 @@ const { const configTemplate = { name: 'Archipel Name', publicIps: '1.1.1.1,2.2.2.2,3.3.3.3,4.4.4.4,5.5.5.5,6.6.6.6', + wireguardPorts : '51820,51820,51820,51820,51820,51820', nodesRole: 'operator,operator,operator,sentryExternal,sentryExternal,sentryExternal', nexmoApiKey :'null,null,null', nexmoApiSecret :'null,null,null', diff --git a/cli/src/wireguard.js b/cli/src/wireguard.js index faf2cb7..31e6a48 100644 --- a/cli/src/wireguard.js +++ b/cli/src/wireguard.js @@ -20,11 +20,21 @@ const generateWireguardKeys = async keysNumber => { }; // Generate Wireguard configuration -const generateWireguardConfig = async externalIPAddresses => { +const generateWireguardConfig = async (externalIPAddresses, wireguardPortsList) => { const config = {}; // Add port number to addresses and add to config - config.wireguardExternalAddrList = externalIPAddresses.map(element => `${element}:51820`).join(','); + config.wireguardExternalAddrList = externalIPAddresses.map((element, index) => + { + if (wireguardPortsList && wireguardPortsList.length >= index && wireguardPortsList[index]){ + const port = wireguardPortsList[index]; + return `${element}:${port}` + } + else{ + return `${element}:51820` + } + } + ).join(','); // Generate Wireguard keys const wireGuardKeys = await generateWireguardKeys(externalIPAddresses.length);