Page 1 of 1

[bug] Address-list address stored as string

Posted: Wed Aug 02, 2017 3:56 pm
by ovdeathiam
I believe I've found a bug in one of the recent versions of ROS as one of my scripts stopped working properly. After some investigation I've found out that addresses in address lists are stored as srings. This variable type used to be ip for ips [127.0.0.1] and str for subnets [127.0.0.1/24].
> :put [:typeof [/ip address get number=0 value-name=address]]
ip
> :put [:typeof [/ip firewall address-list get number=0 value-name=address]]
str
It is possible to use :toip as a workaround:
> :put [:typeof [:toip [/ip firewall address-list get number=0 value-name=address]]]
ip
This workaround returns ip for ips [127.0.0.1] but nil for subnets [127.0.0.1/24].

I'd like to know if the change is a bug or is it intentional.

Re: [bug] Address-list address stored as string

Posted: Wed Aug 02, 2017 3:59 pm
by strods
In latest RouterOS version both values are acceptable since IP address and domain name can be specified as address parameter.

Re: [bug] Address-list address stored as string

Posted: Wed Aug 02, 2017 4:02 pm
by ovdeathiam
I understand that strings are acceptable, but I need to test each entry in the address-list and check if it's an actual ip or not. I used to be able to do this:
:foreach address in=[/ip firewall address-list find comment~"^\$"] do={
    :if ([:typeof [:toip [/ip firewall address-list get $address address]]]="ip") do={
(...)
The script adds comments for uncommented ips by running a few checks on them. I don't want it to run the check if it's a entire subnet.

Re: [bug] Address-list address stored as string

Posted: Wed Aug 02, 2017 4:15 pm
by mrz
127.0.0.1/24 is not an IP address, it is IP prefix, if you want to con vert it to IP, then strip off netmask and then convert.

Re: [bug] Address-list address stored as string

Posted: Wed Aug 02, 2017 4:56 pm
by ovdeathiam
No I don't want to convert ip prefix to ip. I want IPs to be identified as variable type "ip" if they are in address-list just when they are elsewhere.
Right now since a few paches ago both ip prefixes and ips are identified as strings.