From 38946e711c0b537654512e67a6e21fc560fafc21 Mon Sep 17 00:00:00 2001 From: wagesj45 Date: Sun, 24 Aug 2025 04:11:18 -0500 Subject: [PATCH] fix(release): handle explicit FTPS on port 21 via ftp:// + --ssl-reqd (auto-detect or FTPS_MODE=explicit) --- .env.example | 5 +++++ scripts/release-push.js | 23 +++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 69ada3b..378d72f 100644 --- a/.env.example +++ b/.env.example @@ -15,6 +15,11 @@ FTP_PASS=your-ftp-password # Remote directory to upload signed artifacts (e.g., /addons/archive-org-link-grabber/) FTP_REMOTE_DIR=/path/on/server +# FTPS mode (optional): +# explicit (FTPES on port 21) or implicit (default on port 990) +# If unset, the script auto-detects explicit when FTP_PROTOCOL=ftps and FTP_PORT=21. +# FTPS_MODE=explicit + # SFTP host verification (SFTP only; choose one) # SFTP_KNOWN_HOSTS=/home/you/.ssh/known_hosts # SFTP_HOST_PUBKEY_SHA256=base64sha256fingerprint diff --git a/scripts/release-push.js b/scripts/release-push.js index b6de052..388d81e 100644 --- a/scripts/release-push.js +++ b/scripts/release-push.js @@ -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);