Community discussions

 
oooscar
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 84
Joined: Sun Jan 05, 2014 12:56 pm
Location: Spain
Contact:

Login API pear2/Net_RouterOS 6.45.x

Mon Oct 07, 2019 8:32 pm

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,
 
oooscar
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 84
Joined: Sun Jan 05, 2014 12:56 pm
Location: Spain
Contact:

Re: Login API pear2/Net_RouterOS 6.45.x

Tue Oct 08, 2019 9:05 pm

Hi,


No one ? There is no fix ?
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 5934
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Login API pear2/Net_RouterOS 6.45.x

Wed Oct 09, 2019 12:22 pm

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
 
oooscar
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 84
Joined: Sun Jan 05, 2014 12:56 pm
Location: Spain
Contact:

Re: Login API pear2/Net_RouterOS 6.45.x

Wed Oct 09, 2019 2:48 pm

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,
 
oooscar
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 84
Joined: Sun Jan 05, 2014 12:56 pm
Location: Spain
Contact:

Re: Login API pear2/Net_RouterOS 6.45.x

Fri Oct 11, 2019 5:39 pm

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,

Who is online

Users browsing this forum: No registered users and 1 guest