diff options
author | 2010-07-28 01:34:47 +0300 | |
---|---|---|
committer | 2010-07-28 01:34:47 +0300 | |
commit | 198ec5587744c549687e720125258214246c8b08 (patch) | |
tree | 5c7b9f5e389f2c4a7f2ce36e2efa48c0db1551cf | |
parent | Add CoralCDN support (diff) | |
download | idfetch-198ec5587744c549687e720125258214246c8b08.tar.gz idfetch-198ec5587744c549687e720125258214246c8b08.tar.bz2 idfetch-198ec5587744c549687e720125258214246c8b08.zip |
Add options FOLLOW_LOCATION and MAX_REDIRS to network#.conf files
SYNOPSIS: FOLLOW_LOCATION= 0 | 1
A parameter set to 1 tells segget to follow any Location: header that the server
sends as part of an HTTP header. This means that the segget will re-send the
same request on the new location and follow new Location: headers all the way
until no more such headers are returned. MAX_REDIRS can be used to limit the
number of redirects segget will follow.
Default:
follow_location=1
MAX_REDIRS
The set number will be the redirection limit. If that many redirections have
been followed, the next redirect will cause an error. This option only makes
sense if the FOLLOW_LOCATION is used at the same time.
Setting the limit to 0 will make segget refuse any redirect.
Minimum value: 0
Maximum value: 100
Default:
max_redirs=5
-rw-r--r-- | segget/network.cpp | 3 | ||||
-rw-r--r-- | segget/network.h | 4 | ||||
-rw-r--r-- | segget/network0.conf | 30 | ||||
-rw-r--r-- | segget/network1.conf | 29 | ||||
-rw-r--r-- | segget/network2.conf | 29 | ||||
-rw-r--r-- | segget/segment.cpp | 4 |
6 files changed, 87 insertions, 12 deletions
diff --git a/segget/network.cpp b/segget/network.cpp index 782c009..7230774 100644 --- a/segget/network.cpp +++ b/segget/network.cpp @@ -75,7 +75,8 @@ void Tnetwork::init(uint priority_value){ conf.set("network_connections","low_connection_speed_limit",low_connection_speed_limit,1,-1); conf.set("network_connections","low_connection_speed_time",low_connection_speed_time,1,600); conf.set("network_connections","max_connection_speed",max_connection_speed,1,-1); - + conf.set("network_connections","follow_location",follow_location); + conf.set("network_connections","max_redirs",max_redirs,0,100); conf.set("network_user_data","user_agent",user_agent); conf.set("network_proxy","proxy_ip_or_name",proxy_ip_or_name); diff --git a/segget/network.h b/segget/network.h index 96950f9..78476f0 100644 --- a/segget/network.h +++ b/segget/network.h @@ -68,6 +68,8 @@ class Tnetwork{ ulong low_connection_speed_time; ulong max_connection_speed; ulong current_speed_time_interval_msecs; + bool follow_location; + ulong max_redirs; //user-data string user_agent; //proxy @@ -101,6 +103,8 @@ class Tnetwork{ low_connection_speed_time(10), max_connection_speed(0), current_speed_time_interval_msecs(1000), + follow_location(1), + max_redirs(5), //user-data user_agent("segget"), //proxy diff --git a/segget/network0.conf b/segget/network0.conf index 6a750e0..e56f3bb 100644 --- a/segget/network0.conf +++ b/segget/network0.conf @@ -1,13 +1,15 @@ [mode] -# SYNOPSIS: NETWORK_MODE= 0 | 1 | 2 +# SYNOPSIS: NETWORK_MODE= 0 | 1 | 2 | 3 # 0 - remote mirrors (default) # 1 - proxy fetcher # 2 - local mirrors # 3 - CoralCDN +# - If set to 0, segget will use ONLY mirror list provided by portage +# system, and will NOT use the list from network0_mirrors.conf file. # - If set to 1 or 2, segget will replace mirror list provided by portage # system with the list from network#_mirrors.conf file -# - If set to 0, segget will use ONLY mirror list provided by portage -# system, and will NOT use the list from network0_mirrors.conf file +# - If set to 3, segget will convert mirrors provided by portage system +# to use CoralCDN caches. # In some cases it's necessary to make segget prefer local mirrors over # the remote ones. For this purpose define settings for 2 networks: # settings for network0 (to provide access to local mirrors), @@ -133,6 +135,28 @@ low_connection_speed_time=10 # max_connection_speed=0 max_connection_speed=3000 + +# SYNOPSIS: FOLLOW_LOCATION= 0 | 1 +# A parameter set to 1 tells segget to follow any Location: header that the server +# sends as part of an HTTP header. This means that the segget will re-send the +# same request on the new location and follow new Location: headers all the way +# until no more such headers are returned. MAX_REDIRS can be used to limit the +# number of redirects segget will follow. +# Default: +# follow_location=1 +follow_location=1 + +# MAX_REDIRS +# The set number will be the redirection limit. If that many redirections have +# been followed, the next redirect will cause an error. This option only makes +# sense if the FOLLOW_LOCATION is used at the same time. +# Setting the limit to 0 will make segget refuse any redirect. +# Minimum value: 0 +# Maximum value: 100 +# Default: +# max_redirs=5 +max_redirs=5 + [network_protocols] # SYNOPSIS: http_on=0 | 1 # Default: diff --git a/segget/network1.conf b/segget/network1.conf index 56bc8e5..2d813b1 100644 --- a/segget/network1.conf +++ b/segget/network1.conf @@ -1,13 +1,15 @@ [mode] -# SYNOPSIS: NETWORK_MODE= 0 | 1 | 2 +# SYNOPSIS: NETWORK_MODE= 0 | 1 | 2 | 3 # 0 - remote mirrors (default) # 1 - proxy fetcher # 2 - local mirrors # 3 - CoralCDN +# - If set to 0, segget will use ONLY mirror list provided by portage +# system, and will NOT use the list from network0_mirrors.conf file. # - If set to 1 or 2, segget will replace mirror list provided by portage # system with the list from network#_mirrors.conf file -# - If set to 0, segget will use ONLY mirror list provided by portage -# system, and will NOT use the list from network0_mirrors.conf file +# - If set to 3, segget will convert mirrors provided by portage system +# to use CoralCDN caches. # In some cases it's necessary to make segget prefer local mirrors over # the remote ones. For this purpose define settings for 2 networks: # settings for network0 (to provide access to local mirrors), @@ -133,6 +135,27 @@ low_connection_speed_time=10 # max_connection_speed=0 max_connection_speed=3000 +# SYNOPSIS: FOLLOW_LOCATION= 0 | 1 +# A parameter set to 1 tells segget to follow any Location: header that the server +# sends as part of an HTTP header. This means that the segget will re-send the +# same request on the new location and follow new Location: headers all the way +# until no more such headers are returned. MAX_REDIRS can be used to limit the +# number of redirects segget will follow. +# Default: +# follow_location=1 +follow_location=1 + +# MAX_REDIRS +# The set number will be the redirection limit. If that many redirections have +# been followed, the next redirect will cause an error. This option only makes +# sense if the FOLLOW_LOCATION is used at the same time. +# Setting the limit to 0 will make segget refuse any redirect. +# Minimum value: 0 +# Maximum value: 100 +# Default: +# max_redirs=5 +max_redirs=5 + [network_protocols] # SYNOPSIS: http_on=0 | 1 # Default: diff --git a/segget/network2.conf b/segget/network2.conf index e163e1b..ae243ef 100644 --- a/segget/network2.conf +++ b/segget/network2.conf @@ -1,13 +1,15 @@ [mode] -# SYNOPSIS: NETWORK_MODE= 0 | 1 | 2 +# SYNOPSIS: NETWORK_MODE= 0 | 1 | 2 | 3 # 0 - remote mirrors (default) # 1 - proxy fetcher # 2 - local mirrors # 3 - CoralCDN +# - If set to 0, segget will use ONLY mirror list provided by portage +# system, and will NOT use the list from network0_mirrors.conf file. # - If set to 1 or 2, segget will replace mirror list provided by portage # system with the list from network#_mirrors.conf file -# - If set to 0, segget will use ONLY mirror list provided by portage -# system, and will NOT use the list from network0_mirrors.conf file +# - If set to 3, segget will convert mirrors provided by portage system +# to use CoralCDN caches. # In some cases it's necessary to make segget prefer local mirrors over # the remote ones. For this purpose define settings for 2 networks: # settings for network0 (to provide access to local mirrors), @@ -133,6 +135,27 @@ low_connection_speed_time=10 # max_connection_speed=0 max_connection_speed=3000 +# SYNOPSIS: FOLLOW_LOCATION= 0 | 1 +# A parameter set to 1 tells segget to follow any Location: header that the server +# sends as part of an HTTP header. This means that the segget will re-send the +# same request on the new location and follow new Location: headers all the way +# until no more such headers are returned. MAX_REDIRS can be used to limit the +# number of redirects segget will follow. +# Default: +# follow_location=1 +follow_location=1 + +# MAX_REDIRS +# The set number will be the redirection limit. If that many redirections have +# been followed, the next redirect will cause an error. This option only makes +# sense if the FOLLOW_LOCATION is used at the same time. +# Setting the limit to 0 will make segget refuse any redirect. +# Minimum value: 0 +# Maximum value: 100 +# Default: +# max_redirs=5 +max_redirs=5 + [network_protocols] # SYNOPSIS: http_on=0 | 1 # Default: diff --git a/segget/segment.cpp b/segget/segment.cpp index 3dcfa7d..5201c54 100644 --- a/segget/segment.cpp +++ b/segget/segment.cpp @@ -136,8 +136,8 @@ int Tsegment::add_easy_handle_to_multi(CURLM *cm, uint network_num){ } curl_easy_setopt(easyhandle, CURLOPT_USERAGENT, network_array[network_num].user_agent.c_str()); - curl_easy_setopt(easyhandle, CURLOPT_FOLLOWLOCATION, 1); - curl_easy_setopt(easyhandle, CURLOPT_MAXREDIRS, 5); + curl_easy_setopt(easyhandle, CURLOPT_FOLLOWLOCATION, network_array[network_num].follow_location); + curl_easy_setopt(easyhandle, CURLOPT_MAXREDIRS, network_array[network_num].max_redirs); if (network_array[network_num].proxy_off) curl_easy_setopt(easyhandle, CURLOPT_NOPROXY, "*"); |