aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2020-05-06 22:08:27 +0300
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2020-05-22 13:39:09 +0300
commit723572b4b0f36a4ce69d4c799b052de67ba5ed26 (patch)
tree9257b9783c87b6e53cb7799d2d85026400a0001f
parent0d38a7c9aec18da3102d7286ff41a9c960bc1f06 (diff)
downloaddmvpn-tools-723572b4b0f36a4ce69d4c799b052de67ba5ed26.tar.gz
dmvpn-tools-723572b4b0f36a4ce69d4c799b052de67ba5ed26.tar.bz2
dmvpn-tools-723572b4b0f36a4ce69d4c799b052de67ba5ed26.tar.xz
dmvpn-ca: scan_hub function
-rwxr-xr-xdmvpn-ca15
1 files changed, 12 insertions, 3 deletions
diff --git a/dmvpn-ca b/dmvpn-ca
index 2d04a70..d20599b 100755
--- a/dmvpn-ca
+++ b/dmvpn-ca
@@ -492,6 +492,15 @@ function scan_param(choices, desc, optional)
end
+function scan_hub(active)
+ local id = toid(scan_next('hub number'))
+ check_exists(
+ 'vpnc', {site='', id=id}, 'Invalid hub number: '..id, active
+ )
+ return id
+end
+
+
function scan_site_code() return scan_next('site code'):upper() end
function validate_site(code, active)
@@ -1039,7 +1048,7 @@ commands = {
'name <value> <id>',
function()
local _, name = scan_param('name', 'attribute')
- local id = toid(scan_next('hub number'))
+ local id = scan_hub()
scan_finished()
update('vpnc', {name=name}, {site='', id=id})
@@ -1049,7 +1058,7 @@ commands = {
'name <id>',
function()
scan_name_token()
- local id = toid(scan_next('hub number'))
+ local id = scan_hub()
scan_finished()
update('vpnc', {name=false}, {site='', id=id})
@@ -1066,7 +1075,7 @@ commands = {
deactivate={
'<id>',
function()
- local id = toid(scan_next('hub number'))
+ local id = scan_hub(true)
scan_finished()
confirm(
'hub',