danikf/tik4net

[Request] ExecuteListWithDuration return on !done and ExecuteListUntilDone

Opened this issue · 9 comments

Attempting to make a simple synchronous traceroute, but none of the execute commands work, except for ExecuteListWithDuration.

I believe that calling the command /tool/traceroute address=8.8.8.8 count=1 would cause RouterOS to return a !done by itself without the need for a /cancel.

Do you think it would be possible to make ExecuteListWithDuration return when it it receive a !done?
And maybe a ExecuteListUntilDone would be interesting to have.

  • Change ExecuteListWithDuration to return when it receive !done
  • Add ExecuteListUntilDone, with optional timeout

Some testing shows that maybe ExecuteListWithDuration(1000) does return when it receive a !done.
The summary comment does not mention this though. Might want to add that.

So I might be able to use ExecuteListWithDuration anyway, but I would still prefer a timeout exception, rather than a cancel.

Hi,
I believe synchronous call is easy, isn't it? Just use synchronous Execute method with count limit.

const string IP = "127.0.0.1";

var cmd = Connection.CreateCommandAndParameters("/tool/traceroute", TikCommandParameterFormat.NameValue,
      "address", IP,
      "count", "1");
var result = cmd.ExecuteList();

Which returns list of two !re rows.

> /tool/traceroute
> =address=127.0.0.1
> =count=1
< !re
< =address=
< =loss=0
< =sent=1
< =last=0
< =status=
< 
< !re
< =address=127.0.0.1
< =loss=0
< =sent=1
< =last=32
< =avg=32
< =best=32
< =worst=32
< =std-dev=0
< =status=
< 
< !done

Is this behavior similar to your expectations?

D

BTW - about ExecuteWithDuration behavior see #41 (I have also updated comments on these methods as you recommended)

D

Hi - version with expected fix seams to be still in development ... I will publish v3.4 soon.
D

Added ToolTraceroute object with static Execute method.

Testing the changes.

ExecuteListWithDuration works, but kinda opposite from what I would want to have in my specific case. Which is why a ExecuteListUntilDone might be interesting.
Maybe I should try to implement it.

I would suggest that ExecuteListWithDuration(int, out bool, out string) return something else than "canceled" when it received a premature !done. Why not make the abortReason be "Prematurely done" or something?
Monitoring the ExecuteAsync's onDoneCallback for a premature !done shouldn't be too hard.

I will confess that I haven't used any of these duration execute methods at all out side of my testing back then. So not sure if anything needs to be changed here anymore.
The logic behind some of these just seem backwards to me.