Update Server.php

Adicionado método para definir o protocolo de SMB máximo.
This commit is contained in:
mdoliveira 2017-05-19 10:54:52 -03:00 committed by GitHub
commit 499148909e

View file

@ -1,4 +1,5 @@
<?php
/**
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Licensed under the MIT license:
@ -11,6 +12,7 @@ use Icewind\SMB\Exception\AuthenticationException;
use Icewind\SMB\Exception\InvalidHostException;
class Server {
const LOCALE = 'en_US.UTF-8';
/**
@ -43,6 +45,12 @@ class Server {
*/
private $timezoneProvider;
/**
*
* @var string $maxProtocol
*/
private $maxProtocol;
/**
* Check if the smbclient php extension is available
*
@ -126,11 +134,8 @@ class Server {
*/
public function listShares() {
$workgroupArgument = ($this->workgroup) ? ' -W ' . escapeshellarg($this->workgroup) : '';
$command = sprintf('%s %s --authentication-file=%s -gL %s',
$this->system->getSmbclientPath(),
$workgroupArgument,
System::getFD(3),
escapeshellarg($this->getHost())
$maxProtocolArgument = ($this->maxProtocol) ? ' -m ' . escapeshellarg($this->maxProtocol) : '';
$command = sprintf('%s %s %s --authentication-file=%s -gL %s', $this->system->getSmbclientPath(), $workgroupArgument, $maxProtocolArgument,System::getFD(3), escapeshellarg($this->getHost())
);
$connection = new RawConnection($command);
$connection->writeAuthentication($this->getUser(), $this->getPassword());
@ -162,4 +167,22 @@ class Server {
public function getTimeZone() {
return $this->timezoneProvider->get();
}
/**
* @return integer
*/
public function getMaxProtocol() {
return $this->maxProtocol;
}
/**
* @param integer $maxProtocol
*/
public function setMaxProtocol($maxProtocol) {
if((ctype_digit(strval($maxProtocol)))){
$this->maxProtocol = 'SMB' . $maxProtocol;
} else {
throw new Exception\InvalidTypeException("Parameter is invalid, integer type only is accepted");
}
}
}