libzypp  11.13.5
ProxyInfoSysconfig.cc
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
13 #include <iostream>
14 #include <fstream>
15 
16 #include "zypp/base/Logger.h"
17 #include "zypp/base/String.h"
18 #include "zypp/Pathname.h"
19 
21 
22 using namespace std;
23 using namespace zypp::base;
24 
25 namespace zypp {
26  namespace media {
27 
28  ProxyInfoSysconfig::ProxyInfoSysconfig(const Pathname & path)
29  : ProxyInfo::Impl()
30  {
32  path.relative()
33  ? "/etc/sysconfig" + path
34  : path);
35  map<string,string>::const_iterator it = data.find("PROXY_ENABLED");
36  if (it != data.end())
37  _enabled = it->second != "no";
38  it = data.find("HTTP_PROXY");
39  if (it != data.end())
40  _proxies["http"] = it->second;
41  it = data.find("HTTPS_PROXY");
42  if (it != data.end())
43  _proxies["https"] = it->second;
44  it = data.find("FTP_PROXY");
45  if (it != data.end())
46  _proxies["ftp"] = it->second;
47  it = data.find("NO_PROXY");
48  if (it != data.end())
49  str::split(it->second, std::back_inserter(_no_proxy), ", \t");
50  }
51 
52  std::string ProxyInfoSysconfig::proxy(const Url & url_r) const
53  {
55  if (it != _proxies.end())
56  return it->second;
57  return "";
58  }
59 
61  { return _no_proxy.begin(); }
62 
64  { return _no_proxy.end(); }
65 
66  } // namespace media
67 } // namespace zypp