Goal: get all active addresses on sstp-server interfaces, add to address list without duplication
I have created a foreach loop (see below) for every item in my sstp-servers list that is running. I want to loop through these and add each IP address to an address list, but only if it does not already exist.
I have to action part:
do={/ip firewall address-list add address=[/interface sstp-server get $i client-address] list=VPNLINKS}
my problem is the if statement.
this:
:if ([/ip firewall address-list get value-name=list [find address=[/interface sstp-server get $s client-address]] = "VPNLINKS")
only works if the address is already on the address list, if it is not, it bails with an ‘interrupted \ no such item’ and the scripts quits.
:foreach s in=[/interface sstp-server find where disabled=no and running=yes] do={
:local sstpsrvr $s
:local clip [/interface sstp-server get $s client-address]
:put "Server ID $sstpsrvr"
:put "Client IP address $clip"
}
Can someone help me with an if statement that doesn’t bail if the find/get part has no match -OR- give some advice if I’m going about this the wrong way.
Thanks