Net_RouterOS icon indicating copy to clipboard operation
Net_RouterOS copied to clipboard

Special dummy fasttrack counters rule

Open gaztelugatxe opened this issue 7 years ago • 3 comments
trafficstars

Commands that should work such as:

$util->setMenu('/ip firewall filter');
$util->disable();

don't work when the special dummy rule to show fasttrack counters is present. PHP throws this error:

PEAR2\Net\RouterOS\RouterErrorException: Error when disabling items in /var/www/html/pru/PEAR2_Net_RouterOS-1.0.0b6/src/PEAR2/Net/RouterOS/Util.php:634 
Stack trace: #0 /var/www/html/pru/ros_4_fw.php(73): PEAR2\Net\RouterOS\Util->disable() #1 {main} 
Response collection: Array ( [0] => PEAR2\Net\RouterOS\Response Object ( [unrecognizedWords:protected] => Array ( ) [_type:PEAR2\Net\RouterOS\Response:private] => !trap [attributes:protected] => Array ( [message] => failure: cannot change builtin ) [_tag:PEAR2\Net\RouterOS\Message:private] => ) [1] => PEAR2\Net\RouterOS\Response Object ( [unrecognizedWords:protected] => Array ( ) [_type:PEAR2\Net\RouterOS\Response:private] => !done [attributes:protected] => Array ( ) [_tag:PEAR2\Net\RouterOS\Message:private] => ) ) `

If we skip that first dummy rule, for example:

$util->disable(1);

no error happens and the rule is correctly disabled.

gaztelugatxe avatar Apr 21 '18 09:04 gaztelugatxe

As you can see, this is an error message originating from the router. It is normal, and is the case even on the command line (try f.e. /ip firewall filter disable [find] and see the same error message appear).

If you want to disable all of "your" rules, you should instead target all rules that are not dynamic. Dynamic rules are removed when the thing that created them is disabled or removed. In the case of the dummy fasttrack rules, there's no such option, but at least the rule is always dynamic.

So f.e.

$util->setMenu('/ip firewall filter');
$util->disable(RouterOS\Query::where('dynamic', 'false'));

and the equivalent in CLI being /ip firewall filter disable [find where dynamic=no].

boenrobot avatar Apr 21 '18 17:04 boenrobot

Thanks for the fast answer.

Yes, I understand is not a bug, but the

$util->disable(RouterOS\Query::where('dynamic', 'false'));

still throws an error, so I'll keep on trying things.

gaztelugatxe avatar Apr 21 '18 19:04 gaztelugatxe

Oh... crap... testing this now, I'm seeing the query failing is actually the effect of bug #34... Already fixed, but the new version is not released yet.

If you're using Composer, you can get it now by using "dev-develop" as your version vector. Or if you're using an extracted archive (as your error message seems to indicate), you can get an unpackaged zip (i.e. one that does NOT include dependencies) from here, and merge the new files with the old ones, replacing the original ones.

There are some more things I'd like to get around to before I make a new tagged and packaged release.

boenrobot avatar Apr 21 '18 19:04 boenrobot