Community discussions

 
ProfLaravel
just joined
Topic Author
Posts: 1
Joined: Mon Sep 17, 2018 2:59 pm

port tracking in php PEAR2 Api

Mon Sep 17, 2018 3:15 pm

hello ,

is there any way to get a result of this command
/ip firewall connection print where src-address ~":80"

using Php PEAR2 Api i've been searching for a while and what i got that i can't use "~" in my php query

so is there any ideas on query to get the same result using the api ?

thanks
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 5934
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: port tracking in php PEAR2 Api

Mon Sep 17, 2018 4:31 pm

API cannot do this, such selection must be done on your APP side.
 
User avatar
boen_robot
Forum Guru
Forum Guru
Posts: 2411
Joined: Thu Aug 31, 2006 4:43 pm
Location: europe://Bulgaria/Plovdiv

Re: port tracking in php PEAR2 Api

Tue Sep 18, 2018 4:58 pm

… And to do it on the app side, you can use preg_match while iterating over all items. You may narrow them down with other allowed criteria if you want (e.g. search for only tcp connections that come from a known interface) to optimize the performance somewhat.

e.g. (without such criteria)
foreach ($util->setMenu('/ip firewall connection')->getAll() as $connection) {
    if (preg_match('/\:80$/', $connection->getProperty('src-address'))) {
        //Connection matches. Deal with it here
    }
}
PEAR2_Net_RouterOS(1.0.0b6) - My API client in PHP
(Rate my posts? If you want... no pressure...)

Who is online

Users browsing this forum: No registered users and 5 guests