added support to bind outgoing connections to specific ports (might be useful to do traffic shaping)

This commit is contained in:
Arvid Norberg
2008-02-28 07:34:07 +00:00
parent e48e52770b
commit 9d3b60edb7
9 changed files with 102 additions and 7 deletions

View File

@@ -375,6 +375,8 @@ namespace libtorrent
void stop_natpmp();
void stop_upnp();
int next_port();
// handles delayed alerts
alert_manager m_alerts;
@@ -551,6 +553,10 @@ namespace libtorrent
void second_tick(asio::error_code const& e);
ptime m_last_tick;
// when outgoing_ports is configured, this is the
// port we'll bind the next outgoing socket to
int m_next_port;
#ifndef TORRENT_DISABLE_DHT
boost::intrusive_ptr<dht::dht_tracker> m_dht;
dht_settings m_dht_settings;

View File

@@ -126,6 +126,7 @@ namespace libtorrent
, auto_upload_slots(true)
, cache_size(512)
, cache_expiry(60)
, outgoing_ports(0,0)
{}
// this is the user agent that will be sent to the tracker
@@ -332,6 +333,12 @@ namespace libtorrent
// idle in the cache before it's forcefully flushed
// to disk. Default is 60 seconds.
int cache_expiry;
// if != (0, 0), this is the range of ports that
// outgoing connections will be bound to. This
// is useful for users that have routers that
// allow QoS settings based on local port.
std::pair<int, int> outgoing_ports;
};
#ifndef TORRENT_DISABLE_DHT