summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKostyantyn Ovechko <fastinetserver@gmail.com>2010-06-23 15:39:47 +0300
committerKostyantyn Ovechko <fastinetserver@gmail.com>2010-06-23 15:39:47 +0300
commit04e475df1d87f7d6bcf1c296f1f4c927a8bf4a84 (patch)
tree4d35204104076a11dadfba6d73f4ea58c1170bd7
parentAdd [mirrors].benchmark_oblivion option to segget.conf (diff)
downloadidfetch-04e475df1d87f7d6bcf1c296f1f4c927a8bf4a84.tar.gz
idfetch-04e475df1d87f7d6bcf1c296f1f4c927a8bf4a84.tar.bz2
idfetch-04e475df1d87f7d6bcf1c296f1f4c927a8bf4a84.zip
Add [proxy] section settings to segget.conf
PROXY_IP_OR_NAME Specify a proxy to use (address and port). Set HTTP proxy to use. The parameter should be a string holding the proxy host name or dotted IP address. To specify port number in this string, append :[port] to the end of the host name. The proxy string may be prefixed with [protocol]:// since any such prefix will be ignored. The proxy's port number may optionally be specified with the separate option. If not specified, by default port 1080 will be used for proxies. When you tell segget to use an HTTP proxy, segget will transparently convert operations to HTTP even if you specify an FTP URL etc. Segget respects the environment variables http_proxy, ftp_proxy, all_proxy etc, if any of those are set. The PROXY option does however override any possibly set environment variables. Default: proxy_ip_or_name=none PROXY_PORT Set the proxy port to connect to unless it is specified in the PROXY option. Default: proxy_port=1080 PROXY_USER Set user name to use for the transfer while connecting to Proxy. The PROXY_USER option should be used in same way as the PROXY_PASSWORD is used. In order to specify the password to be used in conjunction with the user name use the PROXY_PASSWORD option. Default: proxy_user=none PROXY_PASSWORD Set password to use for the transfer while connecting to Proxy. The PROXY_PASSWORD option should be used in conjunction with the PROXY_USER option. Default: proxy_password=none SYNOPSIS: proxy_off=0 | 1 Setting the proxy_off=1 will explicitly disable the use of a proxy, even if there is an environment variable set for it. Default: proxy_off=1
-rw-r--r--segget/config.cpp3
-rw-r--r--segget/segget.conf83
-rw-r--r--segget/segment.cpp17
-rw-r--r--segget/settings.cpp20
4 files changed, 106 insertions, 17 deletions
diff --git a/segget/config.cpp b/segget/config.cpp
index c94b2bf..6d4130d 100644
--- a/segget/config.cpp
+++ b/segget/config.cpp
@@ -73,6 +73,7 @@ int ConfigFile::set(string &dst, string const& section, string const& entry) con
}
else{
dst=ci->second;
+ log("Settings: ["+section+"]."+entry+"="+dst);
return 0;
}
}
@@ -86,6 +87,7 @@ int ConfigFile::set(uint &dst, string const& section, string const& entry) const
}
else{
dst=atoi(ci->second.c_str());
+ log("Settings: ["+section+"]."+entry+"="+toString(dst));
return 0;
}
}
@@ -99,6 +101,7 @@ int ConfigFile::set(bool &dst, string const& section, string const& entry) const
}
else{
dst=atoi(ci->second.c_str());
+ log("Settings: ["+section+"]."+entry+"="+toString(dst));
return 0;
}
} \ No newline at end of file
diff --git a/segget/segget.conf b/segget/segget.conf
index 19e1f89..3d1dc47 100644
--- a/segget/segget.conf
+++ b/segget/segget.conf
@@ -1,8 +1,11 @@
[folders]
+# DISTFILES_DIR
# Define a dir to store distfiles
# Default:
# distfiles_dir=./distfiles
distfiles_dir=./distfiles
+
+# SEGMENTS_DIR
# Define a dir to store distfiles' segments
# Default:
# segments_dir=./tmp
@@ -13,6 +16,7 @@ segments_dir=./tmp
# NOT IMPLEMENTED YET: fetch_only=0
[distfiles]
+# MAX_CONNECTION_NUM_PER_DISTFILE
# Each distfile can have up to max_connection_num_per_distfile simultaneous
# connections.
# default:
@@ -20,6 +24,7 @@ segments_dir=./tmp
max_connection_num_per_distfile=3
[segments]
+# MAX_SEGMENT_SIZE
# Define maximum segment size in bytes.
# Default:
# max_segment_size=500000
@@ -37,6 +42,7 @@ max_segment_size=500000
# resume_on=1
resume_on=1
+# MAX_TRIES
# If segment download was unsuccessful, new attempts are made. When attempts
# number reaches max_tries, segment gets FAILED status and error logged to error_log
# Default:
@@ -44,9 +50,11 @@ resume_on=1
max_tries=30
[connections]
+# MAX_CONNECTIONS
# Define maximum number of connections
max_connections=10
+# CONNECTION_TIMEOUT
# Set the number of seconds to wait while trying to connect. Use 0 to wait
# indefinitely. Pass a long. It should contain the maximum time in seconds that
# you allow the connection to the server to take. This only limits the connection
@@ -57,6 +65,7 @@ max_connections=10
# connection_timeout=15
connection_timeout=15
+# FTP_RESPONSE_TIMEOUT
# Set a timeout period (in seconds) on the amount of time that the server is
# allowed to take in order to generate a response message for a command before the
# session is considered hung. While awaiting for a response, this value overrides
@@ -66,6 +75,7 @@ connection_timeout=15
# ftp_response_timeout=5000
ftp_response_timeout=5000
+# TIMEOUT
# maximum amount of time to download segment in seconds
# Set the maximum number of seconds for a connection to execute.
# Pass a long as parameter containing the maximum time in seconds that you allow
@@ -124,6 +134,7 @@ bind_interface=none
# low might cause unnecessary connection setup failures.
[mirrors]
+# MAX_CONNECTIONS_NUM_PER_MIRROR
# Define how many simultaneous downloads from one mirror segget is allowed to
# have. While choosing a mirror segget will skip mirrors with
# max_connections_num_per_mirror active downloads.
@@ -144,6 +155,7 @@ collect_benchmark_stats_on=1
# use_benchmark_results=1 (Note: at the moment can NOT be changed)
use_benchmark_stats=1
+# BENCHMARK_OBLIVION
# benchmark_oblivion option allows to adjust how fast segget "forgets"
# benchmarking statistics on mirrors performance.
# Default:
@@ -167,38 +179,77 @@ benchmark_oblivion=5
[user-data]
-user_agent=segget
-Specify the user and password for authentication on a ftp servers.
-ftp-user=anonymous
-ftp-password=me@mail.ru
+# NOT IMPLEMENTED YET: user_agent=segget
+# Specify the user and password for authentication on a ftp servers.
+# NOT IMPLEMENTED YET: ftp-user=anonymous
+# NOT IMPLEMENTED YET: ftp-password=me@mail.ru
[proxy]
+# PROXY_IP_OR_NAME
# Specify a proxy to use (address and port).
-proxy-ip=none
-proxy-port=none
-Specify the user and password for authentication on a proxy server.
-proxy-user=user
-proxy-password=password
-# Set to forbid using proxies.
-no-proxy=1
+# Set HTTP proxy to use. The parameter should be a string holding the proxy host
+# name or dotted IP address. To specify port number in this string,
+# append :[port] to the end of the host name. The proxy string may be prefixed
+# with [protocol]:// since any such prefix will be ignored. The proxy's port
+# number may optionally be specified with the separate option. If not specified,
+# by default port 1080 will be used for proxies.
+# When you tell segget to use an HTTP proxy, segget will transparently convert
+# operations to HTTP even if you specify an FTP URL etc.
+# Segget respects the environment variables http_proxy, ftp_proxy, all_proxy etc,
+# if any of those are set. The PROXY option does however override any possibly
+# set environment variables.
+# Default:
+# proxy_ip_or_name=none
+proxy_ip_or_name=none
+
+# PROXY_PORT
+# Set the proxy port to connect to unless it is specified in the PROXY option.
+# Default:
+# proxy_port=1080
+proxy_port=1080
+
+# PROXY_USER
+# Set user name to use for the transfer while connecting to Proxy.
+# The PROXY_USER option should be used in same way as the PROXY_PASSWORD is used.
+# In order to specify the password to be used in conjunction with the user name
+# use the PROXY_PASSWORD option.
+# Default:
+# proxy_user=none
+proxy_user=none
+
+# PROXY_PASSWORD
+# Set password to use for the transfer while connecting to Proxy.
+# The PROXY_PASSWORD option should be used in conjunction with the PROXY_USER
+# option.
+# Default:
+# proxy_password=none
+proxy_password=none
+
+# SYNOPSIS: proxy_off=0 | 1
+# Setting the proxy_off=1 will explicitly disable the use of a proxy, even if
+# there is an environment variable set for it.
+# Default:
+# proxy_off=1
+proxy_off=1
[proxy-fetcher]
# Specify proxy-fetcher address and port
-proxy-fetcher-ip=none
-proxy-fetcher-port=none
+# NOT IMPLEMENTED YET: proxy-fetcher-ip=none
+# NOT IMPLEMENTED YET: proxy-fetcher-port=none
# Specify the user and password for authentication on a proxy-fetcher-server.
# proxy-fetcher-user=user
# proxy-fetcher-password=password
# Set to forbid direct connections to Internet servers if it's possible to use
# proxy-fetcher.
-use-proxy-fetcher-demon-if-possible=1
+# NOT IMPLEMENTED YET: use-proxy-fetcher-demon-if-possible=1
# Set to forbid direct connections to Internet servers.
-use-proxy-fetcher-demon-only=0
+# NOT IMPLEMENTED YET: use-proxy-fetcher-demon-only=0
# Set to forbid using proxy-fetcher.
-no-proxy-fetcher
+# NOT IMPLEMENTED YET: no-proxy-fetcher
[mirroring]
+# MIRROR_DIR
# Define a dir to store distfiles for mirroring.
# Default:
# mirror_dir=./mirror
diff --git a/segget/segment.cpp b/segget/segment.cpp
index 87067b9..e055b23 100644
--- a/segget/segment.cpp
+++ b/segget/segment.cpp
@@ -127,6 +127,23 @@ 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.proxy_off)
+ curl_easy_setopt(easyhandle, CURLOPT_NOPROXY, "*");
+ else{
+ if ((settings.proxy_ip_or_name!="none") and (settings.proxy_port!=0)){
+ curl_easy_setopt(easyhandle, CURLOPT_PROXY, settings.proxy_ip_or_name.c_str());
+ curl_easy_setopt(easyhandle, CURLOPT_PROXYPORT, settings.proxy_port);
+ debug("Using proxy:"+settings.proxy_ip_or_name+":"+toString(settings.proxy_port));
+ }
+ if (settings.proxy_user!="none"){
+ curl_easy_setopt(easyhandle, CURLOPT_PROXYUSERNAME, settings.proxy_user.c_str());
+ if (settings.proxy_password!="none")
+ curl_easy_setopt(easyhandle, CURLOPT_PROXYPASSWORD, settings.proxy_password.c_str());
+ }
+ }
+
if ((settings.bind_interface!="none")
and (settings.bind_interface!="")
and (settings.bind_interface!="NONE"))
diff --git a/segget/settings.cpp b/segget/settings.cpp
index 2cfcb74..6b78774 100644
--- a/segget/settings.cpp
+++ b/segget/settings.cpp
@@ -31,6 +31,12 @@ class Tsettings{
//mirrors
uint max_connections_num_per_mirror;
uint benchmark_oblivion;
+ //proxy
+ string proxy_ip_or_name;
+ uint proxy_port;
+ uint proxy_off;
+ string proxy_user;
+ string proxy_password;
Tsettings():
//folders
distfiles_dir("./distfiles"),
@@ -52,7 +58,13 @@ class Tsettings{
bind_interface("none"),
//mirrors
max_connections_num_per_mirror(2),
- benchmark_oblivion(5)
+ benchmark_oblivion(5),
+ //proxy
+ proxy_ip_or_name("none"),
+ proxy_port(0),
+ proxy_off(1),
+ proxy_user("none"),
+ proxy_password("none")
//logs
{};
void set_resume(bool resume_setting){resume_on=resume_setting;};
@@ -83,6 +95,12 @@ void Tsettings::load_from_conf_file(){
conf.set(max_connections_num_per_mirror, "mirrors", "max_connections_num_per_mirror");
conf.set(benchmark_oblivion, "mirrors", "benchmark_oblivion");
+
+ conf.set(proxy_ip_or_name, "proxy", "proxy_ip_or_name");
+ conf.set(proxy_port, "proxy", "proxy_port");
+ conf.set(proxy_off, "proxy", "proxy_off");
+ conf.set(proxy_user, "proxy", "proxy_user");
+ conf.set(proxy_password, "proxy", "proxy_password");
}
Tsettings settings;