mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
github ci
This commit is contained in:
parent
58f6df3807
commit
80a4edf0ef
9 changed files with 144 additions and 6 deletions
50
src/ProtocolLevel.php
Normal file
50
src/ProtocolLevel.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* @copyright Copyright (c) 2021 Robin Appelman <robin@icewind.nl>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace Icewind\SMB;
|
||||
|
||||
|
||||
class ProtocolLevel {
|
||||
/** @var string */
|
||||
private $level;
|
||||
|
||||
private function __construct(string $level) {
|
||||
$this->level = $level;
|
||||
}
|
||||
|
||||
public function getLevel(): string {
|
||||
return $this->level;
|
||||
}
|
||||
|
||||
public static function NT1(): self {
|
||||
return new ProtocolLevel("NT1");
|
||||
}
|
||||
|
||||
public static function SMB2(): self {
|
||||
return new ProtocolLevel("SMB2");
|
||||
}
|
||||
|
||||
public static function SMB3(): self {
|
||||
return new ProtocolLevel("SMB3");
|
||||
}
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ class Connection extends RawConnection {
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
$output[] .= $line;
|
||||
$output[] = $line;
|
||||
}
|
||||
$line = $this->readLine();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ namespace Icewind\SMB\Wrapped;
|
|||
|
||||
use Icewind\SMB\Exception\ConnectException;
|
||||
use Icewind\SMB\Exception\ConnectionException;
|
||||
use Icewind\SMB\Exception\ConnectionResetException;
|
||||
|
||||
class RawConnection {
|
||||
/**
|
||||
|
|
@ -100,7 +101,13 @@ class RawConnection {
|
|||
* @param string $input
|
||||
*/
|
||||
public function write($input) {
|
||||
fwrite($this->getInputStream(), $input);
|
||||
if (@fwrite($this->getInputStream(), $input) === false) {
|
||||
$error = error_get_last();
|
||||
if ($error && strpos($error['message'], "errno=32")) {
|
||||
error_clear_last();
|
||||
throw new ConnectionResetException();
|
||||
}
|
||||
}
|
||||
fflush($this->getInputStream());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ use Icewind\SMB\AbstractServer;
|
|||
use Icewind\SMB\Exception\AuthenticationException;
|
||||
use Icewind\SMB\Exception\ConnectException;
|
||||
use Icewind\SMB\Exception\ConnectionException;
|
||||
use Icewind\SMB\Exception\ConnectionRefusedException;
|
||||
use Icewind\SMB\Exception\InvalidHostException;
|
||||
use Icewind\SMB\IShare;
|
||||
use Icewind\SMB\ISystem;
|
||||
|
|
@ -62,6 +63,9 @@ class Server extends AbstractServer {
|
|||
if (isset($output[0])) {
|
||||
$parser->checkConnectionError($output[0]);
|
||||
}
|
||||
// if (count($output) === 0) {
|
||||
// throw new ConnectionRefusedException();
|
||||
// }
|
||||
|
||||
// sometimes we get an empty line first
|
||||
if (count($output) < 2) {
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ class Share extends AbstractShare {
|
|||
|
||||
// use a close callback to ensure the upload is finished before continuing
|
||||
// this also serves as a way to keep the connection in scope
|
||||
return CallbackWrapper::wrap($fh, null, null, function () use ($connection, $target) {
|
||||
return CallbackWrapper::wrap($fh, null, null, function () use ($connection) {
|
||||
$connection->close(false); // dont terminate, give the upload some time
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue