diff options
author | npmccallum <npmccallum@c587cffe-e639-0410-9787-d7902ae8ed56> | 2010-01-19 15:06:04 +0000 |
---|---|---|
committer | npmccallum <npmccallum@c587cffe-e639-0410-9787-d7902ae8ed56> | 2010-01-19 15:06:04 +0000 |
commit | 2c37a9fed231fd6c6172903095e29d4a56c3d27b (patch) | |
tree | 4b6e04814c4011a11c8d02bfb0f633166479ab58 /libproxy/modules | |
parent | 8d45436044fffccc15dc1e21de22532fb2a88cd2 (diff) | |
download | libproxy-2c37a9fed231fd6c6172903095e29d4a56c3d27b.tar.gz |
macosx: disable RTSP/Gopher for now, fix memory leak, add support for ExcludeSimpleHostnames
git-svn-id: http://libproxy.googlecode.com/svn/trunk@480 c587cffe-e639-0410-9787-d7902ae8ed56
Diffstat (limited to 'libproxy/modules')
-rw-r--r-- | libproxy/modules/config_macosx.cpp | 30 | ||||
-rw-r--r-- | libproxy/modules/ignore_hostname.cpp | 36 |
2 files changed, 59 insertions, 7 deletions
diff --git a/libproxy/modules/config_macosx.cpp b/libproxy/modules/config_macosx.cpp index 50fbdc9..8ec82b9 100644 --- a/libproxy/modules/config_macosx.cpp +++ b/libproxy/modules/config_macosx.cpp @@ -87,9 +87,9 @@ static bool protocol_url(CFDictionaryRef settings, string protocol, string& conf if (protocol == "HTTP" || protocol == "HTTPS" || protocol == "FTP") ss << "http://"; else if (protocol == "Gopher") - ss << "gopher://"; // Is this correct? + return false; //ss << "gopher://"; // Is this correct? else if (protocol == "RTSP") - ss << "rtsp://"; // Is this correct? + return false; //ss << "rtsp://"; // Is this correct? else if (protocol == "SOCKS") ss << "socks://"; else @@ -125,29 +125,45 @@ public: if (!proxies) throw runtime_error("Unable to fetch proxy configuration"); // wpad:// - if (getbool(proxies, "ProxyAutoDiscoveryEnable")) + if (getbool(proxies, "ProxyAutoDiscoveryEnable")) { + CFRelease(proxies); return com::googlecode::libproxy::url(string("wpad://")); + } // pac+http://... if (getbool(proxies, "ProxyAutoConfigEnable") && (tmp = str(getobj<CFStringRef>(proxies, "ProxyAutoConfigURLString"))) != "" && - url::is_valid(tmp)) + url::is_valid(tmp)) { + CFRelease(proxies); return com::googlecode::libproxy::url(string("pac+") + tmp); + } // http:// or socks:// (TODO: gopher:// and rtsp:// ???) if ((protocol_url(proxies, toupper(url.get_scheme()), tmp) && url::is_valid(tmp)) || (protocol_url(proxies, capitalize(url.get_scheme()), tmp) && url::is_valid(tmp)) || (protocol_url(proxies, toupper("http"), tmp) && url::is_valid(tmp)) || - (protocol_url(proxies, toupper("socks"), tmp) && url::is_valid(tmp))) + (protocol_url(proxies, toupper("socks"), tmp) && url::is_valid(tmp))) { + CFRelease(proxies); return com::googlecode::libproxy::url(tmp); + } // direct:// + CFRelease(proxies); return com::googlecode::libproxy::url(string("direct://")); } string get_ignore(url) { - // TODO: "Exclude simple hostnames" - return str(getobj<CFArrayRef>(SCDynamicStoreCopyProxies(NULL), "ExceptionsList")); + // Get config dict + CFDictionaryRef proxies = SCDynamicStoreCopyProxies(NULL); + if (!proxies) return ""; + + // Get ignores + string tmp = str(getobj<CFArrayRef>(proxies, "ExceptionsList")); + if (getbool(proxies, "ExcludeSimpleHostnames")) + tmp += (tmp == "" ? string("") : string(",")) + "__simple_hostnames__"; + + CFRelease(proxies); + return tmp; } }; diff --git a/libproxy/modules/ignore_hostname.cpp b/libproxy/modules/ignore_hostname.cpp new file mode 100644 index 0000000..2297a93 --- /dev/null +++ b/libproxy/modules/ignore_hostname.cpp @@ -0,0 +1,36 @@ +/******************************************************************************* + * libproxy - A library for proxy configuration + * Copyright (C) 2009 Nathaniel McCallum <nathaniel@natemccallum.com> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + ******************************************************************************/ + +#include <cstdio> + +#include "../module_types.hpp" +using namespace com::googlecode::libproxy; + +class hostname_ignore_module : public ignore_module { +public: + PX_MODULE_ID(NULL); + + virtual bool ignore(url& url, string ignorestr) { + if (ignorestr == "__simple_hostnames__" && url.get_host().find('.') == string::npos) + return true; + return false; + } +}; + +PX_MODULE_LOAD(ignore, hostname, true); |