Hi, thanks for the patch! Some comments: On Sat, Sep 18, 2010 at 05:21:39PM +0800, Zhang Qiang wrote:
Repositories may be in different locations (inside/outside the company network), the outside repo needs proxy, but the internal repo should disable proxy. with out this patch libzypp can't work if inside repo and outside repo exist at the same time.
This patch give user the option to disable proxy in repository file. Usage as follows: [home_xiaoqiang] name=local type=rpm-md baseurl=http://172.16.119.175 proxy=_none_ #Disable proxy #proxy=http://host:port #enable proxy enabled=1
It also gives the user the option to specify a proxy in the repository file (like with yum).
/** diff --git a/zypp/media/MediaAccess.cc b/zypp/media/MediaAccess.cc index f0a769d..2f139bc 100644 --- a/zypp/media/MediaAccess.cc +++ b/zypp/media/MediaAccess.cc @@ -132,6 +132,7 @@ MediaAccess::open (const Url& url, const Pathname & preferred_attach_point) bool use_multicurl = true; const char *ariaenv = getenv( "ZYPP_ARIA2C" ); const char *multicurlenv = getenv( "ZYPP_MULTICURL" ); + bool disable_proxy = false; // if user disabled it manually if ( use_multicurl && multicurlenv && ( strcmp(multicurlenv, "0" ) == 0 ) ) { @@ -162,12 +163,18 @@ MediaAccess::open (const Url& url, const Pathname & preferred_attach_point) use_aria = false; }
+ Url curlUrl( url ); + if ( curlUrl.getQueryParam("noproxy") == "yes" ){ + curlUrl.removeQueryParam("noproxy"); + disable_proxy = true; + }
Hmm, why handle "noproxy" different from "proxy"? I.e. why is there an extra disable_proxy argument, but all other settings (like "proxy" are detected later on in fillSettingsFromUrl()? [...]
{ _curlError[0] = '\0'; @@ -1298,6 +1299,8 @@ void MediaCurl::doGetFileCopyFile( const Pathname & filename , const Pathname & string urlBuffer( curlUrl.asString()); CURLcode ret = curl_easy_setopt( _curl, CURLOPT_URL, urlBuffer.c_str() ); + if (_noproxy == true) + curl_easy_setopt(_curl, CURLOPT_NOPROXY, url.getHost().c_str());
Shouldn't that simply be: curl_easy_setopt(_curl, CURLOPT_NOPROXY, "*");
[...] + if (it->second != "_none_" ) + { + int pos = it->second.find(":", 0); + url.setQueryParam("proxy", it->second.substr(0, pos)); + url.setQueryParam("proxyport", it->second.substr(pos + 1));
What if there is no ':' in the proxy string? find will return "npos" in that case. Cheers, Michael. -- Michael Schroeder mls@suse.de SUSE LINUX Products GmbH, GF Markus Rex, HRB 16746 AG Nuernberg main(_){while(_=~getchar())putchar(~_-1/(~(_|32)/13*2-11)*13);} -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org