mirror of
https://github.com/logicog/RTLPlayground.git
synced 2026-10-29 17:54:14 +08:00
Merge pull request #333 from DrDoof/feat/syslog-hostname-port
syslog: send a hostname, allow a port other than 514, and stop the save from dropping the address
This commit is contained in:
8 files changed
+112
-14
No files matched your search
+18
-1
@@ -7,6 +7,7 @@ const conf_cmds = [
|
||||
/^netmask\s+(\d{1,3}\.){3}\d{1,3}$/,
|
||||
/^syslog\s+(on|off)$/,
|
||||
/^syslog\s+ip\s+(\d{1,3}\.){3}\d{1,3}$/,
|
||||
/^syslog\s+port\s+\d{1,5}$/,
|
||||
/^passwd\s+\S+$/,
|
||||
/^vlan\s+\d{1,4}\s+d$/,
|
||||
/^vlan\s+\d{1,4}\s+mgmt$/,
|
||||
@@ -36,12 +37,21 @@ const conf_cmds = [
|
||||
/^bw\s+(in|out)\s+\d{1,2}\s+\S+$/,
|
||||
/^hostname\s+.{1,23}$/,
|
||||
];
|
||||
/* Commands that come in an on/off pair replace each other, which the list
|
||||
* below cannot express: it drops lines starting with the text it matched, and
|
||||
* "syslog off" does not start with "syslog on". Naming the stem separately
|
||||
* keeps the pair collapsed without widening the match to the whole family. */
|
||||
const conf_toggle = [
|
||||
/^(syslog)\s+(?:on|off)$/,
|
||||
];
|
||||
|
||||
const conf_overwrite = [
|
||||
/^ip\b/,
|
||||
/^gw\b/,
|
||||
/^netmask\b/,
|
||||
/^syslog\s+ip\b/,
|
||||
/^syslog\b/,
|
||||
/^syslog\s+port\b/,
|
||||
/^syslog\s+(on|off)$/,
|
||||
/^passwd\b/,
|
||||
/^vlan\s+\d{1,4}\s+mgmt$/,
|
||||
/^vlan\s+\d{1,4}(?!\s+mgmt\b)/,
|
||||
@@ -79,6 +89,13 @@ function parseConf(s){
|
||||
for (const x of conf_cmds)
|
||||
if (x.test(line)) { ignore = false; break; }
|
||||
if (ignore) continue;
|
||||
for (const x of conf_toggle) {
|
||||
const t = line.match(x);
|
||||
if (t) {
|
||||
configuration = configuration.filter(item => item !== t[1] + " on" && item !== t[1] + " off");
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (const x of conf_overwrite) {
|
||||
if (x.test(line)) {
|
||||
let m = line.match(x);
|
||||
|
||||
Reference in new issue
Block a user