diff options
author | Kostyantyn Ovechko <fastinetserver@gmail.com> | 2010-06-22 04:09:58 +0300 |
---|---|---|
committer | Kostyantyn Ovechko <fastinetserver@gmail.com> | 2010-06-22 04:09:58 +0300 |
commit | 1657adc4707a5d331264022cc8b1ace7abfb9ded (patch) | |
tree | f7377997db343c6512947acd65c1b221f1b0892c | |
parent | Add [connections].low_connection_speed_limit, [connections].low_connection_sp... (diff) | |
download | idfetch-1657adc4707a5d331264022cc8b1ace7abfb9ded.tar.gz idfetch-1657adc4707a5d331264022cc8b1ace7abfb9ded.tar.bz2 idfetch-1657adc4707a5d331264022cc8b1ace7abfb9ded.zip |
Add option [connections].bind_interface
BIND INTERFACE / IP
Pass a string as parameter. This sets the interface name to use as outgoing
network interface. The name can be an interface name, an IP address, or a host
name. No binding is set by default.
default:
bind_interface=none
-rw-r--r-- | segget/segget.conf | 24 | ||||
-rw-r--r-- | segget/segment.cpp | 5 | ||||
-rw-r--r-- | segget/settings.cpp | 5 |
3 files changed, 31 insertions, 3 deletions
diff --git a/segget/segget.conf b/segget/segget.conf index 240630c..fb08e33 100644 --- a/segget/segget.conf +++ b/segget/segget.conf @@ -82,6 +82,28 @@ max_connection_speed=0 #max_total_speed=50000 +# BIND INTERFACE / IP +# Pass a string as parameter. This sets the interface name to use as outgoing +# network interface. The name can be an interface name, an IP address, or a host +# name. No binding is set by default. +# default: +# bind_interface=none +bind_interface=none + +# BIND LOCALPORT +# Pass a long. This sets the local port number of the socket used for connection. +# This can be used in combination with BIND_INTERFACE and you are recommended to +# use BIND_LOCALPORTRANGE as well when this is set. +# Valid port numbers are 1 - 65535. + +# BIND_LOCALPORTRANGE +# Pass a long. This is the number of attempts segget should make to find a +# working local port number. It starts with the given BIND_LOCALPORT and adds +# one to the number for each retry. Setting this to 1 or below will make segget +# do only one try for the exact port number. Port numbers by nature are scarce +# resources that will be busy at times so setting this value to something too +# low might cause unnecessary connection setup failures. + [mirrors] max_connections_num_per_mirror=2 benchmarking_on=1 @@ -95,8 +117,6 @@ allow_ftp=1 [schedule] -[interfaces] -# bind_if=192.168.56.2 [user-data] user_agent=segget diff --git a/segget/segment.cpp b/segget/segment.cpp index 34ee3c2..bc4d960 100644 --- a/segget/segment.cpp +++ b/segget/segment.cpp @@ -126,6 +126,11 @@ int Tsegment::add_easy_handle_to_multi(CURLM *cm){ curl_easy_setopt(easyhandle, CURLOPT_LOW_SPEED_LIMIT, settings.low_connection_speed_limit); curl_easy_setopt(easyhandle, CURLOPT_LOW_SPEED_TIME, settings.low_connection_speed_time); curl_easy_setopt(easyhandle, CURLOPT_MAX_RECV_SPEED_LARGE, settings.max_connection_speed); + if ((settings.bind_interface!="none") + and (settings.bind_interface!="") + and (settings.bind_interface!="NONE")) + curl_easy_setopt(easyhandle, CURLOPT_INTERFACE, settings.bind_interface.c_str()); + //set connection timeout curl_easy_setopt(easyhandle, CURLOPT_CONNECTTIMEOUT, settings.connection_timeout); curl_easy_setopt(easyhandle, CURLOPT_WRITEFUNCTION, write_data); diff --git a/segget/settings.cpp b/segget/settings.cpp index 451168d..cbb62e6 100644 --- a/segget/settings.cpp +++ b/segget/settings.cpp @@ -27,6 +27,7 @@ class Tsettings{ uint low_connection_speed_limit; uint low_connection_speed_time; uint max_connection_speed; + string bind_interface; Tsettings(): //folders distfiles_dir("./distfiles"), @@ -44,7 +45,8 @@ class Tsettings{ time_out(6000), low_connection_speed_limit(1000), low_connection_speed_time(10), - max_connection_speed(0) + max_connection_speed(0), + bind_interface("none") {}; void set_resume(bool resume_setting){resume_on=resume_setting;}; bool get_resume(){return resume_on;}; @@ -70,6 +72,7 @@ void Tsettings::load_from_conf_file(){ conf.set(low_connection_speed_limit, "connections", "low_connection_speed_limit"); conf.set(low_connection_speed_time, "connections", "low_connection_speed_time"); conf.set(max_connection_speed, "connections", "max_connection_speed"); + conf.set(bind_interface, "connections", "bind_interface"); } Tsettings settings; |