Page 1 of 1

Login API pear2/Net_RouterOS 6.45.x

Posted: Mon Oct 07, 2019 8:32 pm
by oooscar
Hi,

I did read about new login API from 6.45.x version. https://wiki.mikrotik.com/wiki/Manual:API#Initial_login

Now I have several routers where I connect throw pear2/Net_RouterOS with versions older that 6.45 (arround 1000 routers). And now there start to come some with new RouterOS version.

I did found a new version on pear2/Net_RouterOS 1.0.0b6 (i'm using 1.0.0.b5) but on the change log I didn't found login differences.

So how I have to do to keep working the api call with both verions ?

I'm doing at the moment:
$this->util = new RouterOS\Util($this->client = new RouterOS\Client($ip,$userRouter,$passRouter,null,null,$tiempoEspera));


Thanks,

Re: Login API pear2/Net_RouterOS 6.45.x

Posted: Tue Oct 08, 2019 9:05 pm
by oooscar
Hi,


No one ? There is no fix ?

Re: Login API pear2/Net_RouterOS 6.45.x

Posted: Wed Oct 09, 2019 12:22 pm
by mrz
I do not see a problem you just try new login method and fall back if you receive ret, as shown in the python example:
https://wiki.mikrotik.com/wiki/Manual:A ... ple_client

See "login" function

Re: Login API pear2/Net_RouterOS 6.45.x

Posted: Wed Oct 09, 2019 2:48 pm
by oooscar
Thanks mrz,

but I'm using pers2/Net_RouterOS PHP class, I wonder if there is any update to don't change the code directly.


it should be here:

private static function _login(
Communicator $com,
$username,
$password = '',
$timeout = null
) {
$request = new Request('/login');
$request->send($com);
$response = new Response($com, false, $timeout);
$request->setArgument('name', $username);
$request->setArgument(
'response',
'00' . md5(
chr(0) . $password
. pack('H*', $response->getProperty('ret'))
)
);
$request->send($com);
$response = new Response($com, false, $timeout);
return $response->getType() === Response::TYPE_FINAL
&& null === $response->getProperty('ret');
}

If no ones have donne i will try but just if someone has done it would be grate to be shared.

Thanks,

Re: Login API pear2/Net_RouterOS 6.45.x

Posted: Fri Oct 11, 2019 5:39 pm
by oooscar
Hi,

the code in this link is working for me until new realse or the API comes over.

https://github.com/pear2/Net_RouterOS/issues/37

Thanks,