fix(release): handle explicit FTPS on port 21 via ftp:// + --ssl-reqd (auto-detect or FTPS_MODE=explicit)
This commit is contained in:
parent
59b48fba3f
commit
38946e711c
2 changed files with 26 additions and 2 deletions
|
|
@ -113,11 +113,30 @@ if (!host || !user || !pass || !remoteDir) {
|
|||
if (!remoteDir.startsWith('/')) remoteDir = '/' + remoteDir;
|
||||
if (remoteDir.endsWith('/')) remoteDir = remoteDir.slice(0, -1);
|
||||
|
||||
// Determine explicit vs implicit FTPS handling
|
||||
function asBool(v) {
|
||||
const s = String(v || '').toLowerCase();
|
||||
return s === 'true' || s === '1' || s === 'yes' || s === 'on';
|
||||
}
|
||||
const ftpsMode = (process.env.FTPS_MODE || '').toLowerCase(); // 'explicit' | 'implicit' | ''
|
||||
let useExplicitFtps = false;
|
||||
if (protocol === 'ftps') {
|
||||
if (ftpsMode === 'explicit') useExplicitFtps = true;
|
||||
else if (ftpsMode === 'implicit') useExplicitFtps = false;
|
||||
else if (String(port || '') === '' || String(port) === '21') useExplicitFtps = true; // default to explicit on port 21
|
||||
}
|
||||
|
||||
// Construct base URL for FTP/SFTP upload target
|
||||
const baseUrl = `${protocol}://${host}${port ? `:${port}` : ''}${remoteDir}`;
|
||||
const scheme = (protocol === 'ftps' && useExplicitFtps) ? 'ftp' : protocol;
|
||||
const baseUrl = `${scheme}://${host}${port ? `:${port}` : ''}${remoteDir}`;
|
||||
|
||||
// Prepare common curl flags
|
||||
const curlBase = ['curl', '--fail', '--ftp-create-dirs'];
|
||||
if (protocol === 'ftps' && useExplicitFtps) {
|
||||
// Explicit FTPS (FTPES): connect plain on port 21 and then upgrade to TLS
|
||||
// Modern curl prefers --ssl-reqd; keep compatibility with older --ftp-ssl-reqd if available
|
||||
curlBase.push('--ssl-reqd');
|
||||
}
|
||||
// Detect curl option support dynamically to stay compatible with older curl versions
|
||||
function curlSupports(opt) {
|
||||
try {
|
||||
|
|
@ -211,7 +230,7 @@ function ensureUpdatesJson() {
|
|||
|
||||
ensureUpdatesJson();
|
||||
|
||||
console.log(`Uploading ${files.length} file(s) from ${artifactsDir} to ${protocol}://${host}${port ? `:${port}` : ''}${remoteDir}/`);
|
||||
console.log(`Uploading ${files.length} file(s) from ${artifactsDir} to ${scheme}://${host}${port ? `:${port}` : ''}${remoteDir}/`);
|
||||
|
||||
for (const file of files) {
|
||||
const localPath = path.join(artifactsDir, file);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue