mirror of
https://github.com/alice-lg/birdwatcher.git
synced 2025-03-09 00:00:05 +01:00
relaxed regex for extracting the version, see #38
This commit is contained in:
parent
7ae4d4723b
commit
0eef5cc49d
3 changed files with 21 additions and 1 deletions
|
@ -60,7 +60,7 @@ func init() {
|
|||
const re_ip = `[0-9a-f\.\:]+`
|
||||
const re_prefix = `[0-9a-f\.\:\/]+`
|
||||
|
||||
regex.status.startLine = regexp.MustCompile(`^BIRD\s([0-9\.]+)\s*$`)
|
||||
regex.status.startLine = regexp.MustCompile(`^BIRD\s(.+)\s*$`)
|
||||
regex.status.routerID = regexp.MustCompile(`^Router\sID\sis\s([0-9\.]+)\s*$`)
|
||||
regex.status.currentServer = regexp.MustCompile(`^Current\sserver\stime\sis\s([0-9\-]+\s[0-9\:\.]+)\s*$`)
|
||||
regex.status.lastReboot = regexp.MustCompile(`^Last\sreboot\son\s([0-9\-]+\s[0-9\:\.]+)\s*$`)
|
||||
|
|
|
@ -44,6 +44,18 @@ func TestParseStatus(t *testing.T) {
|
|||
"version": "2.0.7",
|
||||
},
|
||||
},
|
||||
// Test with advanced version
|
||||
{
|
||||
"status3.sample",
|
||||
Parsed{
|
||||
"current_server": "2022-06-07 08:28:16",
|
||||
"last_reboot": "2022-06-03 12:35:43",
|
||||
"last_reconfig": "2022-06-03 12:35:43",
|
||||
"message": "Daemon is up and running",
|
||||
"router_id": "1.2.3.4",
|
||||
"version": "v2.0.9-11-g207ac485",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
|
8
test/status3.sample
Normal file
8
test/status3.sample
Normal file
|
@ -0,0 +1,8 @@
|
|||
BIRD v2.0.9-11-g207ac485 ready.
|
||||
BIRD v2.0.9-11-g207ac485
|
||||
Router ID is 1.2.3.4
|
||||
Hostname is rs42
|
||||
Current server time is 2022-06-07 08:28:16
|
||||
Last reboot on 2022-06-03 12:35:43
|
||||
Last reconfiguration on 2022-06-03 12:35:43
|
||||
Daemon is up and running
|
Loading…
Add table
Reference in a new issue