Skip to content

Commit

Permalink
Add support for FTPS sync targets
Browse files Browse the repository at this point in the history
Added new property `\phpbu\App\Backup\Sync\Ftp::$secure`
to support FTPS sync targets.
  • Loading branch information
hype09 committed Jan 18, 2024
1 parent 1a00ecf commit 2280478
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
},
"require-dev": {
"sebastianfeldmann/git": "^3.2",
"sebastianfeldmann/ftp": "^0.9",
"sebastianfeldmann/ftp": "^0.9.2",
"guzzlehttp/guzzle": "^5.3.4|^6.5.8|^7.5.0",
"aws/aws-sdk-php": "^3.10",
"kunalvarma05/dropbox-php-sdk": "^0.4",
Expand All @@ -68,7 +68,7 @@
"phpmailer/phpmailer": "^6.0"
},
"suggest": {
"sebastianfeldmann/ftp": "Require ^0.9 to sync to an FTP server",
"sebastianfeldmann/ftp": "Require ^0.9.2 to sync to an FTP server",
"guzzlehttp/guzzle": "Require ^5.3.3|^6.2.1 to write logs to Telegram",
"aws/aws-sdk-php": "Require '^3.10' to sync to Amazon S3",
"kunalvarma05/dropbox-php-sdk": "Require '^0.2' to sync to Dropbox",
Expand Down
3 changes: 2 additions & 1 deletion doc/config/sync/ftp.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"user": "user.name",
"password": "mySecret",
"path": "someDir/someSubDir",
"passive": "false"
"passive": "false",
"secure": "false"
}
}

3 changes: 3 additions & 0 deletions doc/config/sync/ftp.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@

<!-- optional, default=false -->
<option name="passive" value="true" />

<!-- optional, default=false -->
<option name="secure" value="true" />
</sync>
10 changes: 9 additions & 1 deletion src/Backup/Sync/Ftp.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ class Ftp extends Xtp
*/
protected $passive;

/**
* If set to `true` connection is made via FTPS (explicit SSL).
*
* @var bool
*/
protected $secure;

/**
* Setup the Ftp sync
*
Expand All @@ -56,6 +63,7 @@ public function setup(array $config)
parent::setup($config);

$this->passive = Util\Str::toBoolean(Util\Arr::getValue($config, 'passive', ''), false);
$this->secure = Util\Str::toBoolean(Util\Arr::getValue($config, 'secure', ''), false);
$this->setUpCleanable($config);
}

Expand Down Expand Up @@ -113,7 +121,7 @@ protected function createClient()
{
if (!$this->ftpClient) {
$login = $this->user . ($this->password ? ':' . $this->password : '');
$this->ftpClient = new Client('ftp://' . $login . '@' . $this->host, $this->passive);
$this->ftpClient = new Client('ftp://' . $login . '@' . $this->host, $this->passive, $this->secure);
}
return $this->ftpClient;
}
Expand Down

0 comments on commit 2280478

Please sign in to comment.