libzypp
10.5.0
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00013 #include <iostream> 00014 #include <fstream> 00015 00016 #include "zypp/base/Logger.h" 00017 #include "zypp/base/String.h" 00018 #include "zypp/Pathname.h" 00019 00020 #include "zypp/media/proxyinfo/ProxyInfoSysconfig.h" 00021 00022 using namespace std; 00023 using namespace zypp::base; 00024 00025 namespace zypp { 00026 namespace media { 00027 00028 ProxyInfoSysconfig::ProxyInfoSysconfig(const Pathname & path) 00029 : ProxyInfo::Impl() 00030 { 00031 map<string,string> data = sysconfig::read( 00032 path.relative() 00033 ? "/etc/sysconfig" + path 00034 : path); 00035 map<string,string>::const_iterator it = data.find("PROXY_ENABLED"); 00036 if (it != data.end()) 00037 _enabled = it->second != "no"; 00038 it = data.find("HTTP_PROXY"); 00039 if (it != data.end()) 00040 _proxies["http"] = it->second; 00041 it = data.find("HTTPS_PROXY"); 00042 if (it != data.end()) 00043 _proxies["https"] = it->second; 00044 it = data.find("FTP_PROXY"); 00045 if (it != data.end()) 00046 _proxies["ftp"] = it->second; 00047 it = data.find("NO_PROXY"); 00048 if (it != data.end()) 00049 str::split(it->second, std::back_inserter(_no_proxy), ", \t"); 00050 } 00051 00052 std::string ProxyInfoSysconfig::proxy(const Url & url_r) const 00053 { 00054 map<string,string>::const_iterator it = _proxies.find(url_r.getScheme()); 00055 if (it != _proxies.end()) 00056 return it->second; 00057 return ""; 00058 } 00059 00060 ProxyInfo::NoProxyIterator ProxyInfoSysconfig::noProxyBegin() const 00061 { return _no_proxy.begin(); } 00062 00063 ProxyInfo::NoProxyIterator ProxyInfoSysconfig::noProxyEnd() const 00064 { return _no_proxy.end(); } 00065 00066 } // namespace media 00067 } // namespace zypp