@@ -43,14 +43,14 @@ |
||
| 43 | 43 | if (($value & $mask) || $buffer !== '') { |
| 44 | 44 | // Get the current byte by shifting it to least significant position and add it to the string |
| 45 | 45 | // 0xFF12345678 => 0xFF |
| 46 | - $byte = $value >> (8 * $i); |
|
| 46 | + $byte = $value >> (8 * $i); |
|
| 47 | 47 | $buffer .= chr($byte); |
| 48 | 48 | |
| 49 | 49 | // Set the most significant byte to 0 so we can restart the process being shure |
| 50 | 50 | // that the value is left padded with 0 |
| 51 | 51 | // 0xFF12345678 => 0x12345678 |
| 52 | 52 | // -1 = 0xFFFFF.... (number of F depend of PHP_INT_SIZE ) |
| 53 | - $mask = -1 >> ((PHP_INT_SIZE - $i) * 8); |
|
| 53 | + $mask = -1 >> ((PHP_INT_SIZE - $i) * 8); |
|
| 54 | 54 | $value &= $mask; |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -46,9 +46,9 @@ |
||
| 46 | 46 | * List of available operators for "->where()" method |
| 47 | 47 | */ |
| 48 | 48 | public const AVAILABLE_OPERATORS = [ |
| 49 | - '-', // Does not have |
|
| 50 | - '=', // Equal |
|
| 51 | - '>', // More than |
|
| 49 | + '-', // Does not have |
|
| 50 | + '=', // Equal |
|
| 51 | + '>', // More than |
|
| 52 | 52 | '<' // Less than |
| 53 | 53 | ]; |
| 54 | 54 | |
@@ -51,7 +51,7 @@ |
||
| 51 | 51 | $result = fread($this->stream, $length); |
| 52 | 52 | |
| 53 | 53 | // Stream in blocking mode timed out |
| 54 | - if(socket_get_status($this->stream)['timed_out']){ |
|
| 54 | + if (socket_get_status($this->stream)['timed_out']) { |
|
| 55 | 55 | throw new StreamException('Stream timed out'); |
| 56 | 56 | } |
| 57 | 57 | |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // Set blocking mode on a stream |
| 62 | - if ($this->config('socket_blocking') === true){ |
|
| 62 | + if ($this->config('socket_blocking') === true) { |
|
| 63 | 63 | stream_set_blocking($socketClient, true); |
| 64 | 64 | } |
| 65 | 65 | |
@@ -126,22 +126,22 @@ |
||
| 126 | 126 | * List of allowed parameters of config |
| 127 | 127 | */ |
| 128 | 128 | public const ALLOWED = [ |
| 129 | - 'host' => 'string', // Address of Mikrotik RouterOS |
|
| 130 | - 'user' => 'string', // Username |
|
| 131 | - 'pass' => 'string', // Password |
|
| 129 | + 'host' => 'string', // Address of Mikrotik RouterOS |
|
| 130 | + 'user' => 'string', // Username |
|
| 131 | + 'pass' => 'string', // Password |
|
| 132 | 132 | 'port' => 'integer', // RouterOS API port number for access (if not set use default or default with SSL if SSL enabled) |
| 133 | 133 | 'ssl' => 'boolean', // Enable ssl support (if port is not set this parameter must change default port to ssl port) |
| 134 | - 'ssl_options' => 'array', // List of SSL options, eg. |
|
| 134 | + 'ssl_options' => 'array', // List of SSL options, eg. |
|
| 135 | 135 | 'legacy' => 'boolean', // Support of legacy login scheme (true - pre 6.43, false - post 6.43) |
| 136 | 136 | 'timeout' => 'integer', // Max timeout for instantiating connection with RouterOS |
| 137 | 137 | 'socket_timeout' => 'integer', // Max timeout for read from RouterOS |
| 138 | 138 | 'socket_blocking' => 'boolean', // Set blocking mode on a socket stream |
| 139 | - 'socket_options' => 'array', // List of socket context options |
|
| 139 | + 'socket_options' => 'array', // List of socket context options |
|
| 140 | 140 | 'attempts' => 'integer', // Count of attempts to establish TCP session |
| 141 | 141 | 'delay' => 'integer', // Delay between attempts in seconds |
| 142 | 142 | 'ssh_port' => 'integer', // Number of SSH port |
| 143 | 143 | 'ssh_timeout' => 'integer', // Max timeout for read from RouterOS via SSH proto (for "/export" command) |
| 144 | - 'ssh_private_key' => 'string', // Max timeout for read from RouterOS via SSH proto (for "/export" command) |
|
| 144 | + 'ssh_private_key' => 'string', // Max timeout for read from RouterOS via SSH proto (for "/export" command) |
|
| 145 | 145 | ]; |
| 146 | 146 | |
| 147 | 147 | /** |
@@ -15,9 +15,9 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | |
| 17 | 17 | 'host' => env('ROUTEROS_HOST', '192.168.88.1'), // Address of Mikrotik RouterOS |
| 18 | - 'user' => env('ROUTEROS_USER', 'admin'), // Username |
|
| 19 | - 'pass' => env('ROUTEROS_PASS'), // Password |
|
| 20 | - 'port' => (int) env('ROUTEROS_PORT', 8728), // RouterOS API port number for access (if not set use default or default with SSL if SSL enabled) |
|
| 18 | + 'user' => env('ROUTEROS_USER', 'admin'), // Username |
|
| 19 | + 'pass' => env('ROUTEROS_PASS'), // Password |
|
| 20 | + 'port' => (int) env('ROUTEROS_PORT', 8728), // RouterOS API port number for access (if not set use default or default with SSL if SSL enabled) |
|
| 21 | 21 | |
| 22 | 22 | /* |
| 23 | 23 | |-------------------------------------------------------------------------- |
@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | | |
| 31 | 31 | */ |
| 32 | 32 | |
| 33 | - 'attempts' => (int) env('ROUTEROS_ATTEMPTS', 10), // Count of attempts to establish TCP session |
|
| 34 | - 'delay' => (int) env('ROUTEROS_DELAY', 1), // Delay between attempts in seconds |
|
| 35 | - 'timeout' => (int) env('ROUTEROS_TIMEOUT', 10), // Max timeout for instantiating connection with RouterOS |
|
| 36 | - 'socket_timeout' => (int) env('ROUTEROS_SOCKET_TIMEOUT', env('ROUTEROS_TIMEOUT', 30)), // Max timeout for read from RouterOS |
|
| 37 | - 'socket_blocking' => (bool) env('ROUTEROS_SOCKET_BLOCKING', true), // Set blocking mode on a socket stream |
|
| 33 | + 'attempts' => (int) env('ROUTEROS_ATTEMPTS', 10), // Count of attempts to establish TCP session |
|
| 34 | + 'delay' => (int) env('ROUTEROS_DELAY', 1), // Delay between attempts in seconds |
|
| 35 | + 'timeout' => (int) env('ROUTEROS_TIMEOUT', 10), // Max timeout for instantiating connection with RouterOS |
|
| 36 | + 'socket_timeout' => (int) env('ROUTEROS_SOCKET_TIMEOUT', env('ROUTEROS_TIMEOUT', 30)), // Max timeout for read from RouterOS |
|
| 37 | + 'socket_blocking' => (bool) env('ROUTEROS_SOCKET_BLOCKING', true), // Set blocking mode on a socket stream |
|
| 38 | 38 | |
| 39 | 39 | // @see https://www.php.net/manual/en/context.socket.php |
| 40 | 40 | 'socket_options' => [ |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | // @see https://www.php.net/manual/en/context.ssl.php |
| 67 | 67 | 'ssl_options' => [ |
| 68 | - 'ciphers' => env('ROUTEROS_SSL_CIPHERS', 'ADH:ALL'), // ADH:ALL, ADH:ALL@SECLEVEL=0, ADH:ALL@SECLEVEL=1 ... ADH:ALL@SECLEVEL=5 |
|
| 69 | - 'verify_peer' => (bool) env('ROUTEROS_SSL_VERIFY_PEER', false), // Require verification of SSL certificate used. |
|
| 70 | - 'verify_peer_name' => (bool) env('ROUTEROS_SSL_VERIFY_PEER_NAME', false), // Require verification of peer name. |
|
| 68 | + 'ciphers' => env('ROUTEROS_SSL_CIPHERS', 'ADH:ALL'), // ADH:ALL, ADH:ALL@SECLEVEL=0, ADH:ALL@SECLEVEL=1 ... ADH:ALL@SECLEVEL=5 |
|
| 69 | + 'verify_peer' => (bool) env('ROUTEROS_SSL_VERIFY_PEER', false), // Require verification of SSL certificate used. |
|
| 70 | + 'verify_peer_name' => (bool) env('ROUTEROS_SSL_VERIFY_PEER_NAME', false), // Require verification of peer name. |
|
| 71 | 71 | 'allow_self_signed' => (bool) env('ROUTEROS_SSL_ALLOW_SELF_SIGNED', false), // Allow self-signed certificates. Requires verify_peer=true. |
| 72 | 72 | ], |
| 73 | 73 | |
@@ -81,9 +81,9 @@ discard block |
||
| 81 | 81 | | |
| 82 | 82 | */ |
| 83 | 83 | |
| 84 | - 'ssh_port' => (int) env('ROUTEROS_SSH_PORT', 22), // Number of SSH port |
|
| 84 | + 'ssh_port' => (int) env('ROUTEROS_SSH_PORT', 22), // Number of SSH port |
|
| 85 | 85 | 'ssh_timeout' => (int) env('ROUTEROS_SSH_TIMEOUT', env('ROUTEROS_TIMEOUT', 30)), // Max timeout for read from RouterOS via SSH proto (for "/export" command) |
| 86 | - 'ssh_private_key' => env('ROUTEROS_SSH_PRIVKEY', '~/.ssh/id_rsa.pub'), // Full path to required private key |
|
| 86 | + 'ssh_private_key' => env('ROUTEROS_SSH_PRIVKEY', '~/.ssh/id_rsa.pub'), // Full path to required private key |
|
| 87 | 87 | |
| 88 | 88 | /* |
| 89 | 89 | |-------------------------------------------------------------------------- |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | // Read answer from socket in loop, or until timeout reached |
| 255 | - $startTime = time(); |
|
| 255 | + $startTime = time(); |
|
| 256 | 256 | while (true) { |
| 257 | 257 | // Exit from loop if timeout reached |
| 258 | 258 | if (time() > $startTime + $this->config('socket_timeout')) { |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | // Save as result |
| 377 | - if(null != $this->parseResponse($item)) $result[] = $this->parseResponse($item)[0]; |
|
| 377 | + if (null != $this->parseResponse($item)) $result[] = $this->parseResponse($item)[0]; |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | } else { |
@@ -374,7 +374,9 @@ |
||
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | // Save as result |
| 377 | - if(null != $this->parseResponse($item)) $result[] = $this->parseResponse($item)[0]; |
|
| 377 | + if(null != $this->parseResponse($item)) { |
|
| 378 | + $result[] = $this->parseResponse($item)[0]; |
|
| 379 | + } |
|
| 378 | 380 | } |
| 379 | 381 | |
| 380 | 382 | } else { |