summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--auth/ssh.php8
-rw-r--r--auth/telnet.php6
-rw-r--r--routers/router.php3
3 files changed, 7 insertions, 10 deletions
diff --git a/auth/ssh.php b/auth/ssh.php
index a8a74b9..5fdd489 100644
--- a/auth/ssh.php
+++ b/auth/ssh.php
@@ -71,17 +71,17 @@ final class SSH extends Authentication {
}
public function send_command($command) {
- if (($this->connection == null) || !$this->connection->isConnected()) {
- $this->connect();
- }
+ $this->connect();
$data = $this->connection->exec($command);
+ $this->disconnect();
+
return $data;
}
public function disconnect() {
- if ($this->connection != null) {
+ if (($this->connection != null) && $this->connection->isConnected()) {
$this->connection->disconnect();
$this->connection = null;
}
diff --git a/auth/telnet.php b/auth/telnet.php
index 628e602..40a8822 100644
--- a/auth/telnet.php
+++ b/auth/telnet.php
@@ -47,9 +47,7 @@ final class Telnet extends Authentication {
}
public function send_command($command) {
- if ($this->connection == null) {
- $this->connect();
- }
+ $this->connect();
fputs($this->connection, $command."\r\n");
@@ -58,6 +56,8 @@ final class Telnet extends Authentication {
$data .= fread($this->connection, 4096);
}
+ $this->disconnect();
+
return $data;
}
diff --git a/routers/router.php b/routers/router.php
index b47d2d3..d786f94 100644
--- a/routers/router.php
+++ b/routers/router.php
@@ -49,7 +49,6 @@ abstract class Router {
$auth = Authentication::instance($this->config);
try {
- $auth->connect();
$data = '';
foreach ($commands as $selected) {
@@ -57,8 +56,6 @@ abstract class Router {
log_to_file('[client: '.$this->requester.'] '.$this->config['host'].
'> '.$selected);
}
-
- $auth->disconnect();
} catch (Exception $e) {
throw $e;
}