Skip to content

Commit 5ef49c7

Browse files
committed
Validate hostname before connect
1 parent b558444 commit 5ef49c7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Connection/Connection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ abstract class Connection implements ConnectionInterface
6060
*/
6161
public function __construct($host, $username, $password, $port = 21, $timeout = 90)
6262
{
63+
if (!filter_var(gethostbyname($host), FILTER_VALIDATE_IP)) {
64+
throw new ConnectionException("[$host] is not a valid host name/IP.");
65+
}
66+
6367
$this->host = $host;
6468
$this->username = $username;
6569
$this->password = $password;

0 commit comments

Comments
 (0)