Commit 6fa71ae5 authored by Johannes Zellner's avatar Johannes Zellner

Fix server line detection

parent bb14d4d3
......@@ -63,14 +63,14 @@ function getOpenVPNSetting() {
tmp = tmp.filter((l) => { return l && l[0] !== '#'; });
function findItem(prefix) {
let idx = tmp.findIndex((l) => { return l.indexOf(prefix) === 0; });
let idx = tmp.findIndex((l) => { return l.indexOf(prefix) !== -1; });
if (idx === -1) return null;
return tmp[idx].slice(prefix.length).trim().replace(/["]+$/g, '');
}
settings.address = findItem('server').split(' ')[0];
settings.netmask = findItem('server').split(' ')[1];
settings.address = findItem('server ').split(' ')[0];
settings.netmask = findItem('server ').split(' ')[1];
settings.dnsServer = findItem('push "dhcp-option DNS');
settings.allowICC = findItem('client-to-client') !== null;
......@@ -97,7 +97,7 @@ function setOpenVPNSetting(settings) {
else tmp[idx] = value;
// server
idx = tmp.findIndex((l) => { return l.indexOf('server ') !== -1; });
idx = tmp.findIndex((l) => { return l.indexOf('server ') === 0 || l.indexOf('# server ') === 0; });
value = `server ${settings.address} ${settings.netmask}`;
if (idx === -1) tmp.push(value);
else tmp[idx] = value;
......
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