Browse Source

Change back to the original names for the announce address

Only allow ip's through that match the currenrly selected network interface and address
adaptive-webui-19844
Sjoerd van der Berg 9 years ago
parent
commit
c7c71d3c88
  1. 20
      src/base/bittorrent/session.cpp
  2. 14
      src/base/preferences.cpp
  3. 8
      src/base/preferences.h
  4. 30
      src/gui/advancedsettings.cpp
  5. 3
      src/gui/advancedsettings.h

20
src/base/bittorrent/session.cpp

@ -633,7 +633,7 @@ void Session::setSessionSettings() @@ -633,7 +633,7 @@ void Session::setSessionSettings()
// Include overhead in transfer limits
sessionSettings.rate_limit_ip_overhead = pref->includeOverheadInLimits();
// IP address to announce to trackers
sessionSettings.announce_ip = Utils::String::toStdString(pref->getAnnounceAddress());
sessionSettings.announce_ip = Utils::String::toStdString(pref->getNetworkAddress());
// Super seeding
sessionSettings.strict_super_seeding = pref->isSuperSeedingEnabled();
// * Max Half-open connections
@ -1658,17 +1658,12 @@ const QStringList Session::getListeningIPs() @@ -1658,17 +1658,12 @@ const QStringList Session::getListeningIPs()
Logger* const logger = Logger::instance();
QStringList IPs;
//Take the override addresss
const QString networkAddr = pref->getNetworkAddress();
if ( !networkAddr.isEmpty()) {
IPs.append( networkAddr);
return IPs;
}
const QString ifaceName = pref->getNetworkInterface();
const QString ifaceAddr = pref->getNetworkInterfaceAddress();
const bool listenIPv6 = pref->getListenIPv6();
if (ifaceName.isEmpty()) {
//No interface name or address defined just use an empty list
if (ifaceName.isEmpty() && ifaceAddr.isEmpty()) {
IPs.append(QString());
return IPs;
}
@ -1695,6 +1690,13 @@ const QStringList Session::getListeningIPs() @@ -1695,6 +1690,13 @@ const QStringList Session::getListeningIPs()
if ((!listenIPv6 && (protocol == QAbstractSocket::IPv6Protocol))
|| (listenIPv6 && (protocol == QAbstractSocket::IPv4Protocol)))
continue;
//If an iface address has been defined only allow ip's that match it to go through
if (!ifaceAddr.isEmpty()) {
if (ipString != ifaceAddr) {
continue;
}
}
IPs.append(ipString);
}

14
src/base/preferences.cpp

@ -1349,12 +1349,12 @@ QString Preferences::getNetworkInterfaceName() const @@ -1349,12 +1349,12 @@ QString Preferences::getNetworkInterfaceName() const
return value("Preferences/Connection/InterfaceName").toString();
}
void Preferences::setNetworkAddress(const QString& iface)
void Preferences::setNetworkInterfaceAddress(const QString& addr)
{
setValue("Preferences/Connection/InterfaceAddress", iface);
setValue("Preferences/Connection/InterfaceAddress", addr);
}
QString Preferences::getNetworkAddress() const
QString Preferences::getNetworkInterfaceAddress() const
{
return value("Preferences/Connection/InterfaceAddress").toString();
}
@ -1374,14 +1374,14 @@ void Preferences::setListenIPv6(bool enable) @@ -1374,14 +1374,14 @@ void Preferences::setListenIPv6(bool enable)
setValue("Preferences/Connection/InterfaceListenIPv6", enable);
}
QString Preferences::getAnnounceAddress() const
QString Preferences::getNetworkAddress() const
{
return value("Preferences/Connection/AnnounceAddress").toString();
return value("Preferences/Connection/InetAddress").toString();
}
void Preferences::setAnnounceAddress(const QString& addr)
void Preferences::setNetworkAddress(const QString& addr)
{
setValue("Preferences/Connection/AnnounceAddress", addr);
setValue("Preferences/Connection/InetAddress", addr);
}
bool Preferences::isAnonymousModeEnabled() const

8
src/base/preferences.h

@ -363,14 +363,14 @@ public: @@ -363,14 +363,14 @@ public:
void setMaxHalfOpenConnections(int value);
QString getNetworkInterface() const;
void setNetworkInterface(const QString& iface);
QString getNetworkAddress() const;
void setNetworkAddress(const QString& iface);
QString getNetworkInterfaceAddress() const;
void setNetworkInterfaceAddress(const QString& addr);
QString getNetworkInterfaceName() const;
void setNetworkInterfaceName(const QString& iface);
bool getListenIPv6() const;
void setListenIPv6(bool enable);
QString getAnnounceAddress() const;
void setAnnounceAddress(const QString& addr);
QString getNetworkAddress() const;
void setNetworkAddress(const QString& addr);
bool isAnonymousModeEnabled() const;
void enableAnonymousMode(bool enabled);
bool isSuperSeedingEnabled() const;

30
src/gui/advancedsettings.cpp

@ -45,8 +45,8 @@ enum AdvSettingsRows @@ -45,8 +45,8 @@ enum AdvSettingsRows
QBITTORRENT_HEADER,
// network interface
NETWORK_IFACE,
//Optional bind address
NETWORK_ADDRESS,
//Optional network address
NETWORK_IFACE_ADDRESS,
NETWORK_LISTEN_IPV6,
// behavior
SAVE_RESUME_DATA_INTERVAL,
@ -82,7 +82,7 @@ enum AdvSettingsRows @@ -82,7 +82,7 @@ enum AdvSettingsRows
// tracker
TRACKER_EXCHANGE,
ANNOUNCE_ALL_TRACKERS,
ANNOUNCE_ADDRESS,
NETWORK_ADDRESS,
ROW_COUNT
};
@ -145,18 +145,18 @@ void AdvancedSettings::saveAdvancedSettings() @@ -145,18 +145,18 @@ void AdvancedSettings::saveAdvancedSettings()
}
// Listen on IPv6 address
pref->setListenIPv6(cb_listen_ipv6.isChecked());
// Network address
// Interface address
QHostAddress ifaceAddr(txt_iface_address.text().trimmed());
if (ifaceAddr.isNull())
pref->setNetworkInterfaceAddress("");
else
pref->setNetworkInterfaceAddress(ifaceAddr.toString());
// Network Announce address
QHostAddress networkAddr(txt_network_address.text().trimmed());
if (networkAddr.isNull())
pref->setNetworkAddress("");
else
pref->setNetworkAddress(networkAddr.toString());
// Announce address
QHostAddress announceAddr(txt_announce_address.text().trimmed());
if (announceAddr.isNull())
pref->setAnnounceAddress("");
else
pref->setAnnounceAddress(announceAddr.toString());
// Program notification
pref->useProgramNotification(cb_program_notifications.isChecked());
@ -283,12 +283,12 @@ void AdvancedSettings::loadAdvancedSettings() @@ -283,12 +283,12 @@ void AdvancedSettings::loadAdvancedSettings()
// Listen on IPv6 address
cb_listen_ipv6.setChecked(pref->getListenIPv6());
addRow(NETWORK_LISTEN_IPV6, tr("Listen on IPv6 address (requires restart)"), &cb_listen_ipv6);
// Network address
// Network interface address
txt_iface_address.setText(pref->getNetworkInterfaceAddress());
addRow(NETWORK_IFACE_ADDRESS, tr("Optional IP Address to bind to (requires restart)"), &txt_iface_address);
// Announce address
txt_network_address.setText(pref->getNetworkAddress());
addRow(NETWORK_ADDRESS, tr("IP Address to bind to( requires restart))"), &txt_network_address);
// Network address
txt_announce_address.setText(pref->getAnnounceAddress());
addRow(ANNOUNCE_ADDRESS, tr("IP Address to report to trackers (requires restart)"), &txt_announce_address);
addRow(NETWORK_ADDRESS, tr("IP Address to report to trackers (requires restart)"), &txt_network_address);
// Program notifications
cb_program_notifications.setChecked(pref->useProgramNotification());

3
src/gui/advancedsettings.h

@ -63,8 +63,7 @@ private: @@ -63,8 +63,7 @@ private:
cb_super_seeding, cb_program_notifications, cb_tracker_status,
cb_confirm_torrent_recheck, cb_enable_tracker_ext, cb_listen_ipv6, cb_announce_all_trackers;
QComboBox combo_iface;
QLineEdit txt_announce_address;
QLineEdit txt_network_address;
QLineEdit txt_iface_address, network_address;
// OS dependent settings
#if defined(Q_OS_WIN) || defined(Q_OS_MAC)

Loading…
Cancel
Save