Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Socks5 support username and password #408

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/settings-mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ void SettingsManager::SeafileProxy::toQtNetworkProxy(QNetworkProxy *proxy) const
: QNetworkProxy::Socks5Proxy);
proxy->setHostName(host);
proxy->setPort(port);
if (type == HttpProxy && !username.isEmpty() && !password.isEmpty()) {
if ((type == HttpProxy || type == SocksProxy) && !username.isEmpty() && !password.isEmpty()) {
proxy->setUser(username);
proxy->setPassword(password);
}
Expand All @@ -340,6 +340,8 @@ SettingsManager::SeafileProxy SettingsManager::SeafileProxy::fromQtNetworkProxy(
sproxy.password = proxy.password();
} else if (proxy.type() == QNetworkProxy::Socks5Proxy) {
sproxy.type = SocksProxy;
sproxy.username = proxy.user();
sproxy.password = proxy.password();
}

return sproxy;
Expand All @@ -357,7 +359,8 @@ bool SettingsManager::SeafileProxy::operator==(const SeafileProxy &rhs) const
username == rhs.username && password == rhs.password;
} else {
// socks proxy
return host == rhs.host && port == rhs.port;
return host == rhs.host && port == rhs.port &&
username == rhs.username && password == rhs.password;
}
}

Expand Down Expand Up @@ -440,7 +443,7 @@ void SettingsManager::writeProxyDetailsToDaemon(const SeafileProxy& proxy)
rpc->seafileSetConfig(kProxyType, type);
rpc->seafileSetConfig(kProxyAddr, proxy.host.toUtf8().data());
rpc->seafileSetConfigInt(kProxyPort, proxy.port);
if (type == "http") {
if (type == "http" || type == "socks") {
rpc->seafileSetConfig(kProxyUsername, proxy.username.toUtf8().data());
rpc->seafileSetConfig(kProxyPassword, proxy.password.toUtf8().data());
}
Expand Down
15 changes: 10 additions & 5 deletions src/ui/settings-dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,11 @@ void SettingsDialog::showHideControlsBasedOnCurrentProxyType(int state)
mProxyHostLabel->setVisible(true);
mProxyPort->setVisible(true);
mProxyPortLabel->setVisible(true);
mProxyRequirePassword->setVisible(false);
mProxyUsername->setVisible(false);
mProxyUsernameLabel->setVisible(false);
mProxyPassword->setVisible(false);
mProxyPasswordLabel->setVisible(false);
mProxyRequirePassword->setVisible(true);
mProxyUsername->setVisible(true);
mProxyUsernameLabel->setVisible(true);
mProxyPassword->setVisible(true);
mProxyPasswordLabel->setVisible(true);
break;
case SettingsManager::NoProxy:
case SettingsManager::SystemProxy:
Expand Down Expand Up @@ -369,6 +369,11 @@ bool SettingsDialog::updateProxySettings()
case SettingsManager::SocksProxy:
new_proxy.host = proxy_host;
new_proxy.port = proxy_port;
if (mProxyRequirePassword->checkState() == Qt::Checked) {
new_proxy.username = proxy_username;
new_proxy.password = proxy_password;
break;
}
break;
case SettingsManager::NoProxy:
case SettingsManager::SystemProxy:
Expand Down