Community discussions

MikroTik App
 
ovdeathiam
just joined
Topic Author
Posts: 21
Joined: Wed Jul 16, 2014 11:15 am

[bug] Address-list address stored as string

Wed Aug 02, 2017 3:56 pm

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.
Last edited by ovdeathiam on Wed Aug 02, 2017 4:01 pm, edited 1 time in total.
 
User avatar
strods
MikroTik Support
MikroTik Support
Posts: 1661
Joined: Wed Jul 16, 2014 7:22 am
Location: Riga, Latvia

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

Wed Aug 02, 2017 3:59 pm

In latest RouterOS version both values are acceptable since IP address and domain name can be specified as address parameter.
 
ovdeathiam
just joined
Topic Author
Posts: 21
Joined: Wed Jul 16, 2014 11:15 am

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

Wed Aug 02, 2017 4:02 pm

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.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7198
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

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

Wed Aug 02, 2017 4:15 pm

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.
 
ovdeathiam
just joined
Topic Author
Posts: 21
Joined: Wed Jul 16, 2014 11:15 am

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

Wed Aug 02, 2017 4:56 pm

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.