Browse Source

Add option to bind directly to an IP instead of using a network Interface

adaptive-webui-19844
Sjoerd van der Berg 9 years ago
parent
commit
e2f43b3383
  1. 9
      src/base/bittorrent/session.cpp
  2. 18
      src/base/preferences.cpp
  3. 6
      src/base/preferences.h
  4. 23
      src/gui/advancedsettings.cpp
  5. 1
      src/gui/advancedsettings.h

9
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->getNetworkAddress());
sessionSettings.announce_ip = Utils::String::toStdString(pref->getAnnounceAddress());
// Super seeding
sessionSettings.strict_super_seeding = pref->isSuperSeedingEnabled();
// * Max Half-open connections
@ -1658,6 +1658,13 @@ const QStringList Session::getListeningIPs() @@ -1658,6 +1658,13 @@ 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 bool listenIPv6 = pref->getListenIPv6();

18
src/base/preferences.cpp

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

6
src/base/preferences.h

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

23
src/gui/advancedsettings.cpp

@ -45,6 +45,8 @@ enum AdvSettingsRows @@ -45,6 +45,8 @@ enum AdvSettingsRows
QBITTORRENT_HEADER,
// network interface
NETWORK_IFACE,
//Optional bind address
NETWORK_ADDRESS,
NETWORK_LISTEN_IPV6,
// behavior
SAVE_RESUME_DATA_INTERVAL,
@ -80,7 +82,7 @@ enum AdvSettingsRows @@ -80,7 +82,7 @@ enum AdvSettingsRows
// tracker
TRACKER_EXCHANGE,
ANNOUNCE_ALL_TRACKERS,
NETWORK_ADDRESS,
ANNOUNCE_ADDRESS,
ROW_COUNT
};
@ -144,11 +146,18 @@ void AdvancedSettings::saveAdvancedSettings() @@ -144,11 +146,18 @@ void AdvancedSettings::saveAdvancedSettings()
// Listen on IPv6 address
pref->setListenIPv6(cb_listen_ipv6.isChecked());
// Network address
QHostAddress addr(txt_network_address.text().trimmed());
if (addr.isNull())
QHostAddress networkAddr(txt_network_address.text().trimmed());
if (networkAddr.isNull())
pref->setNetworkAddress("");
else
pref->setNetworkAddress(addr.toString());
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());
// Tracker
@ -276,7 +285,11 @@ void AdvancedSettings::loadAdvancedSettings() @@ -276,7 +285,11 @@ void AdvancedSettings::loadAdvancedSettings()
addRow(NETWORK_LISTEN_IPV6, tr("Listen on IPv6 address (requires restart)"), &cb_listen_ipv6);
// Network address
txt_network_address.setText(pref->getNetworkAddress());
addRow(NETWORK_ADDRESS, tr("IP Address to report to trackers (requires restart)"), &txt_network_address);
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);
// Program notifications
cb_program_notifications.setChecked(pref->useProgramNotification());
addRow(PROGRAM_NOTIFICATIONS, tr("Display program on-screen notifications"), &cb_program_notifications);

1
src/gui/advancedsettings.h

@ -63,6 +63,7 @@ private: @@ -63,6 +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;
// OS dependent settings

Loading…
Cancel
Save