Server-Config UI (aktiv/passiv) und Port-Forwarding Tipps in README
- FTP-Tab: Server Configuration mit Active/Passive Radio-Buttons - Passive Mode: Port-Range konfigurierbar (Default 30000-31000) - Apply-Button startet Pure-FTPd automatisch neu - Helper-Script: serverconfig show/active/passive Kommandos - sudoers: systemctl restart, tee und rm für Pure-FTPd Config - README: Port-Forwarding Anleitung für Windows (netsh) und Linux (socat/iptables) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <QFormLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QHBoxLayout>
|
||||
#include <QInputDialog>
|
||||
#include <QLabel>
|
||||
#include <QMessageBox>
|
||||
@@ -152,6 +153,47 @@ FtpSharePlugin::FtpSharePlugin(QObject *parent, const QVariantList &args)
|
||||
|
||||
connect(pwButton, &QPushButton::clicked, this, &FtpSharePlugin::onChangePassword);
|
||||
|
||||
// Server configuration section
|
||||
auto *serverGroup = new QGroupBox(i18n("Server Configuration"));
|
||||
auto *serverLayout = new QVBoxLayout(serverGroup);
|
||||
|
||||
// Active mode
|
||||
m_activeRadio = new QRadioButton(i18n("Active Mode (Port 20)"));
|
||||
serverLayout->addWidget(m_activeRadio);
|
||||
|
||||
// Passive mode
|
||||
m_passiveRadio = new QRadioButton(i18n("Passive Mode"));
|
||||
serverLayout->addWidget(m_passiveRadio);
|
||||
|
||||
// Passive port range
|
||||
m_passivePortsWidget = new QWidget();
|
||||
auto *passivePortsLayout = new QHBoxLayout(m_passivePortsWidget);
|
||||
passivePortsLayout->setContentsMargins(20, 0, 0, 0);
|
||||
passivePortsLayout->addWidget(new QLabel(i18n("Port-Range:")));
|
||||
m_passiveStartSpin = new QSpinBox();
|
||||
m_passiveStartSpin->setRange(1024, 65535);
|
||||
m_passiveStartSpin->setValue(30000);
|
||||
passivePortsLayout->addWidget(m_passiveStartSpin);
|
||||
passivePortsLayout->addWidget(new QLabel(QStringLiteral("-")));
|
||||
m_passiveEndSpin = new QSpinBox();
|
||||
m_passiveEndSpin->setRange(1024, 65535);
|
||||
m_passiveEndSpin->setValue(31000);
|
||||
passivePortsLayout->addWidget(m_passiveEndSpin);
|
||||
passivePortsLayout->addStretch();
|
||||
serverLayout->addWidget(m_passivePortsWidget);
|
||||
|
||||
// Apply button
|
||||
auto *applyServerBtn = new QPushButton(i18n("Apply Server Config"));
|
||||
serverLayout->addWidget(applyServerBtn);
|
||||
|
||||
mainLayout->addWidget(serverGroup);
|
||||
|
||||
connect(m_activeRadio, &QRadioButton::toggled, this, &FtpSharePlugin::onModeChanged);
|
||||
connect(applyServerBtn, &QPushButton::clicked, this, &FtpSharePlugin::onApplyServerConfig);
|
||||
|
||||
// Load current server config
|
||||
loadServerConfig();
|
||||
|
||||
mainLayout->addStretch();
|
||||
|
||||
// Connect signals
|
||||
@@ -335,6 +377,71 @@ void FtpSharePlugin::applyChanges()
|
||||
}
|
||||
}
|
||||
|
||||
void FtpSharePlugin::loadServerConfig()
|
||||
{
|
||||
QProcess proc;
|
||||
proc.start(QStringLiteral("dolphin-ftp-share"),
|
||||
{QStringLiteral("serverconfig"), QStringLiteral("show")});
|
||||
proc.waitForFinished(5000);
|
||||
|
||||
const QString output = QString::fromLocal8Bit(proc.readAllStandardOutput());
|
||||
bool isPassive = false;
|
||||
int startPort = 30000;
|
||||
int endPort = 31000;
|
||||
|
||||
const QStringList lines = output.split(QLatin1Char('\n'));
|
||||
for (const QString &line : lines) {
|
||||
if (line.startsWith(QLatin1String("mode=passive")))
|
||||
isPassive = true;
|
||||
else if (line.startsWith(QLatin1String("passive_start=")))
|
||||
startPort = line.mid(14).toInt();
|
||||
else if (line.startsWith(QLatin1String("passive_end=")))
|
||||
endPort = line.mid(12).toInt();
|
||||
}
|
||||
|
||||
if (isPassive) {
|
||||
m_passiveRadio->setChecked(true);
|
||||
m_passiveStartSpin->setValue(startPort);
|
||||
m_passiveEndSpin->setValue(endPort);
|
||||
} else {
|
||||
m_activeRadio->setChecked(true);
|
||||
}
|
||||
onModeChanged();
|
||||
}
|
||||
|
||||
void FtpSharePlugin::onModeChanged()
|
||||
{
|
||||
m_passivePortsWidget->setEnabled(m_passiveRadio->isChecked());
|
||||
}
|
||||
|
||||
void FtpSharePlugin::onApplyServerConfig()
|
||||
{
|
||||
QProcess proc;
|
||||
if (m_activeRadio->isChecked()) {
|
||||
proc.start(QStringLiteral("dolphin-ftp-share"),
|
||||
{QStringLiteral("serverconfig"), QStringLiteral("active")});
|
||||
} else {
|
||||
proc.start(QStringLiteral("dolphin-ftp-share"),
|
||||
{QStringLiteral("serverconfig"), QStringLiteral("passive"),
|
||||
QString::number(m_passiveStartSpin->value()),
|
||||
QString::number(m_passiveEndSpin->value())});
|
||||
}
|
||||
proc.waitForFinished(10000);
|
||||
|
||||
if (proc.exitCode() == 0) {
|
||||
QMessageBox::information(m_page,
|
||||
i18n("Server Configuration"),
|
||||
m_activeRadio->isChecked()
|
||||
? i18n("Server set to active mode (Port 20).\nPure-FTPd restarted.")
|
||||
: i18n("Server set to passive mode (Ports %1-%2).\nPure-FTPd restarted.",
|
||||
m_passiveStartSpin->value(), m_passiveEndSpin->value()));
|
||||
} else {
|
||||
QMessageBox::warning(m_page,
|
||||
i18n("Server Configuration"),
|
||||
i18n("Failed to apply server configuration."));
|
||||
}
|
||||
}
|
||||
|
||||
void FtpSharePlugin::onChangePassword()
|
||||
{
|
||||
const QString username = m_pwUserCombo->currentText();
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include <QComboBox>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
#include <QSpinBox>
|
||||
#include <QWidget>
|
||||
|
||||
struct UserPermission {
|
||||
@@ -22,8 +24,11 @@ public:
|
||||
|
||||
private:
|
||||
void loadCurrentShare();
|
||||
void loadServerConfig();
|
||||
void onShareToggled(bool checked);
|
||||
void onChangePassword();
|
||||
void onApplyServerConfig();
|
||||
void onModeChanged();
|
||||
|
||||
QString m_path;
|
||||
QString m_defaultShareName;
|
||||
@@ -34,6 +39,13 @@ private:
|
||||
QWidget *m_usersWidget = nullptr;
|
||||
QComboBox *m_pwUserCombo = nullptr;
|
||||
|
||||
// Server config
|
||||
QRadioButton *m_activeRadio = nullptr;
|
||||
QRadioButton *m_passiveRadio = nullptr;
|
||||
QSpinBox *m_passiveStartSpin = nullptr;
|
||||
QSpinBox *m_passiveEndSpin = nullptr;
|
||||
QWidget *m_passivePortsWidget = nullptr;
|
||||
|
||||
QVector<UserPermission> m_userPerms;
|
||||
|
||||
bool m_isShared = false;
|
||||
|
||||
Reference in New Issue
Block a user