Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c73109b8ca | ||
|
|
2c2282e05a |
@@ -69,6 +69,9 @@ async function buildMergedPdf(subs) {
|
|||||||
async function ftpUpload(dateien) {
|
async function ftpUpload(dateien) {
|
||||||
const { host, port, user, password, secure, rejectUnauthorized } = config.ftp;
|
const { host, port, user, password, secure, rejectUnauthorized } = config.ftp;
|
||||||
if (!host || !user) throw new Error('FTP nicht konfiguriert (SKRIFT_FTP_HOST/USER fehlen).');
|
if (!host || !user) throw new Error('FTP nicht konfiguriert (SKRIFT_FTP_HOST/USER fehlen).');
|
||||||
|
// Diagnose ohne Passwort-Leak: bei „530 Login incorrect" trotz korrekter Daten
|
||||||
|
// ist meist die Passwort-Laenge im .env falsch (Quotes/CRLF/Leerzeichen).
|
||||||
|
console.log(`[batch] FTP-Login: host=${host}:${port} user="${user}" pw_len=${(password || '').length} secure=${secure}`);
|
||||||
const client = new ftp.Client(30000);
|
const client = new ftp.Client(30000);
|
||||||
// client.ftp.verbose = true;
|
// client.ftp.verbose = true;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -64,11 +64,16 @@ module.exports = {
|
|||||||
// Login incorrect" führen, obwohl die Daten korrekt sind.
|
// Login incorrect" führen, obwohl die Daten korrekt sind.
|
||||||
ftp: (() => {
|
ftp: (() => {
|
||||||
const envClean = (v) => String(v || '').replace(/[\r\n]+/g, '').replace(/^(['"])([\s\S]*)\1$/, '$2');
|
const envClean = (v) => String(v || '').replace(/[\r\n]+/g, '').replace(/^(['"])([\s\S]*)\1$/, '$2');
|
||||||
|
// Passwoerter mit Sonderzeichen ($ # @ …) werden in .env-Dateien oft
|
||||||
|
// verstuemmelt ($ = Variable, # = Kommentar). Deshalb bevorzugt base64:
|
||||||
|
// SKRIFT_FTP_PASSWORD_B64 wird dekodiert und ist damit env-sicher.
|
||||||
|
const pwB64 = envClean(process.env.SKRIFT_FTP_PASSWORD_B64);
|
||||||
|
const password = pwB64 ? Buffer.from(pwB64, 'base64').toString('utf8') : envClean(process.env.SKRIFT_FTP_PASSWORD);
|
||||||
return {
|
return {
|
||||||
host: envClean(process.env.SKRIFT_FTP_HOST),
|
host: envClean(process.env.SKRIFT_FTP_HOST),
|
||||||
port: parseInt(process.env.SKRIFT_FTP_PORT, 10) || 21,
|
port: parseInt(process.env.SKRIFT_FTP_PORT, 10) || 21,
|
||||||
user: envClean(process.env.SKRIFT_FTP_USER),
|
user: envClean(process.env.SKRIFT_FTP_USER),
|
||||||
password: envClean(process.env.SKRIFT_FTP_PASSWORD),
|
password,
|
||||||
// explizites FTP über TLS (wie im FTP-Client eingestellt). 'false' schaltet ab.
|
// explizites FTP über TLS (wie im FTP-Client eingestellt). 'false' schaltet ab.
|
||||||
secure: String(process.env.SKRIFT_FTP_SECURE || 'true').toLowerCase() !== 'false',
|
secure: String(process.env.SKRIFT_FTP_SECURE || 'true').toLowerCase() !== 'false',
|
||||||
// Selbstsigniertes Zertifikat zulassen (viele FTP-Server) – auf 'false' setzen für strikte Prüfung.
|
// Selbstsigniertes Zertifikat zulassen (viele FTP-Server) – auf 'false' setzen für strikte Prüfung.
|
||||||
|
|||||||
Reference in New Issue
Block a user