From 36043b3a369651da7b36821d1fd25929096afb9e Mon Sep 17 00:00:00 2001 From: iBNu Maksum Date: Fri, 23 Aug 2019 14:36:20 +0700 Subject: [PATCH 1/2] add port from IP, use ip:port when adding router --- .gitignore | 3 ++- system/autoload/PEAR2/Net/RouterOS/Client.php | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 85637033..aef7d02e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /system/config.php .DS_Store .vscode/ -ui/compiled/*.php \ No newline at end of file +ui/compiled/*.php +ui/cache/*.php \ No newline at end of file diff --git a/system/autoload/PEAR2/Net/RouterOS/Client.php b/system/autoload/PEAR2/Net/RouterOS/Client.php index 88b13e56..cc1d136f 100644 --- a/system/autoload/PEAR2/Net/RouterOS/Client.php +++ b/system/autoload/PEAR2/Net/RouterOS/Client.php @@ -135,6 +135,11 @@ class Client $crypto = N::CRYPTO_OFF, $context = null ) { + if(strpos($host,":")>-1){ + $part = explode(":",$host); + $host = $part[0]; + $port = $part[1]; + } $this->com = new Communicator( $host, $port, @@ -151,7 +156,7 @@ class Client if ((!$persist || !($old = $this->com->getTransmitter()->lock(S::DIRECTION_ALL))) && $this->com->getTransmitter()->isFresh() - ) { + ) { if (!static::login($this->com, $username, $password, $timeout)) { $this->com->close(); throw new DataFlowException( From fb8a1353d943e0ff5d48e4a1033da9edc182bc73 Mon Sep 17 00:00:00 2001 From: iBNu Maksum Date: Fri, 23 Aug 2019 16:15:02 +0700 Subject: [PATCH 2/2] Update login mikrotik untuk versi baru --- .gitignore | 3 ++- system/autoload/PEAR2/Net/RouterOS/Client.php | 14 ++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index aef7d02e..eb691d3b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ .DS_Store .vscode/ ui/compiled/*.php -ui/cache/*.php \ No newline at end of file +ui/cache/*.php +/test.php \ No newline at end of file diff --git a/system/autoload/PEAR2/Net/RouterOS/Client.php b/system/autoload/PEAR2/Net/RouterOS/Client.php index cc1d136f..1dd59ce9 100644 --- a/system/autoload/PEAR2/Net/RouterOS/Client.php +++ b/system/autoload/PEAR2/Net/RouterOS/Client.php @@ -131,7 +131,7 @@ class Client $password = '', $port = 8728, $persist = false, - $timeout = null, + $timeout = 10, $crypto = N::CRYPTO_OFF, $context = null ) { @@ -274,16 +274,10 @@ class Client $timeout = null ) { $request = new Request('/login'); - $request->send($com); - $response = new Response($com, false, $timeout); + // Update Mikrotik Versi terbaru + // sayangnya ini ngga aman, bagusnya di setup ke port SSL $request->setArgument('name', $username); - $request->setArgument( - 'response', - '00' . md5( - chr(0) . $password - . pack('H*', $response->getProperty('ret')) - ) - ); + $request->setArgument('password', $password); $request->send($com); $response = new Response($com, false, $timeout); return $response->getType() === Response::TYPE_FINAL