mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
improve error handling during connect
This commit is contained in:
parent
89f47cfdf2
commit
526f14707e
2 changed files with 8 additions and 0 deletions
|
|
@ -34,10 +34,14 @@ class Connection extends RawConnection {
|
||||||
parent::write($input . PHP_EOL);
|
parent::write($input . PHP_EOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws ConnectException
|
||||||
|
*/
|
||||||
public function clearTillPrompt() {
|
public function clearTillPrompt() {
|
||||||
$this->write('');
|
$this->write('');
|
||||||
do {
|
do {
|
||||||
$promptLine = $this->readLine();
|
$promptLine = $this->readLine();
|
||||||
|
$this->parser->checkConnectionError($promptLine);
|
||||||
} while (!$this->isPrompt($promptLine));
|
} while (!$this->isPrompt($promptLine));
|
||||||
$this->write('');
|
$this->write('');
|
||||||
$this->readLine();
|
$this->readLine();
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,7 @@ class Parser {
|
||||||
* @throws AuthenticationException
|
* @throws AuthenticationException
|
||||||
* @throws InvalidHostException
|
* @throws InvalidHostException
|
||||||
* @throws NoLoginServerException
|
* @throws NoLoginServerException
|
||||||
|
* @throws AccessDeniedException
|
||||||
*/
|
*/
|
||||||
public function checkConnectionError($line) {
|
public function checkConnectionError($line) {
|
||||||
$line = rtrim($line, ')');
|
$line = rtrim($line, ')');
|
||||||
|
|
@ -101,6 +102,9 @@ class Parser {
|
||||||
if (substr($line, -26) === ErrorCodes::NoLogonServers) {
|
if (substr($line, -26) === ErrorCodes::NoLogonServers) {
|
||||||
throw new NoLoginServerException('No login server');
|
throw new NoLoginServerException('No login server');
|
||||||
}
|
}
|
||||||
|
if (substr($line, -23) === ErrorCodes::AccessDenied) {
|
||||||
|
throw new AccessDeniedException('Access denied');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function parseMode($mode) {
|
public function parseMode($mode) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue