mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 18:03:56 -04:00
make direct-hosts use glob characters correctly
This commit is contained in:
parent
2531913df2
commit
c88b65d0f6
@ -82,6 +82,8 @@ config_downloader.GetBool("verify-ssl", true);
|
|||||||
// connections that don't specify otherwise.
|
// connections that don't specify otherwise.
|
||||||
const string http_proxy =
|
const string http_proxy =
|
||||||
config_downloader.GetString("http-proxy", "");
|
config_downloader.GetString("http-proxy", "");
|
||||||
|
const string http_direct_hosts =
|
||||||
|
config_downloader.GetString("http-direct-hosts", "");
|
||||||
const string http_proxy_username =
|
const string http_proxy_username =
|
||||||
config_downloader.GetString("http-proxy-username", "");
|
config_downloader.GetString("http-proxy-username", "");
|
||||||
|
|
||||||
|
@ -43,6 +43,7 @@ extern const int patcher_buffer_size;
|
|||||||
extern const bool early_random_seed;
|
extern const bool early_random_seed;
|
||||||
extern const bool verify_ssl;
|
extern const bool verify_ssl;
|
||||||
extern const string http_proxy;
|
extern const string http_proxy;
|
||||||
|
extern const string http_direct_hosts;
|
||||||
extern const string http_proxy_username;
|
extern const string http_proxy_username;
|
||||||
extern const double connect_timeout;
|
extern const double connect_timeout;
|
||||||
extern const double http_timeout;
|
extern const double http_timeout;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "executionEnvironment.h"
|
#include "executionEnvironment.h"
|
||||||
#include "httpBasicAuthorization.h"
|
#include "httpBasicAuthorization.h"
|
||||||
#include "httpDigestAuthorization.h"
|
#include "httpDigestAuthorization.h"
|
||||||
|
#include "globPattern.h"
|
||||||
|
|
||||||
#ifdef HAVE_SSL
|
#ifdef HAVE_SSL
|
||||||
|
|
||||||
@ -102,6 +103,8 @@ HTTPClient() {
|
|||||||
_ssl_ctx = (SSL_CTX *)NULL;
|
_ssl_ctx = (SSL_CTX *)NULL;
|
||||||
|
|
||||||
set_proxy_spec(http_proxy);
|
set_proxy_spec(http_proxy);
|
||||||
|
set_direct_host_spec(http_direct_hosts);
|
||||||
|
|
||||||
if (!http_proxy_username.empty()) {
|
if (!http_proxy_username.empty()) {
|
||||||
set_username("*proxy", "", http_proxy_username);
|
set_username("*proxy", "", http_proxy_username);
|
||||||
}
|
}
|
||||||
@ -251,11 +254,6 @@ set_proxy_spec(const string &proxy_spec) {
|
|||||||
url = URLSpec(spec.substr(equals + 1), true);
|
url = URLSpec(spec.substr(equals + 1), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!url.has_scheme()) {
|
|
||||||
// The default scheme for talking to proxies is HTTP.
|
|
||||||
url.set_scheme("http");
|
|
||||||
}
|
|
||||||
|
|
||||||
add_proxy(scheme, url);
|
add_proxy(scheme, url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -301,8 +299,8 @@ get_proxy_spec() const {
|
|||||||
// Access: Published
|
// Access: Published
|
||||||
// Description: Specifies the set of hosts that should be connected
|
// Description: Specifies the set of hosts that should be connected
|
||||||
// to directly, without using a proxy. This is a
|
// to directly, without using a proxy. This is a
|
||||||
// semicolon-separated list of hostnames or ip addresses,
|
// semicolon-separated list of hostnames that may
|
||||||
// that may contain wildcard characters ("*").
|
// contain wildcard characters ("*").
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void HTTPClient::
|
void HTTPClient::
|
||||||
set_direct_host_spec(const string &direct_host_spec) {
|
set_direct_host_spec(const string &direct_host_spec) {
|
||||||
@ -325,21 +323,21 @@ set_direct_host_spec(const string &direct_host_spec) {
|
|||||||
// Access: Published
|
// Access: Published
|
||||||
// Description: Returns the set of hosts that should be connected
|
// Description: Returns the set of hosts that should be connected
|
||||||
// to directly, without using a proxy, as a
|
// to directly, without using a proxy, as a
|
||||||
// semicolon-separated list of hostnames or ip addresses,
|
// semicolon-separated list of hostnames that may
|
||||||
// that may contain wildcard characters ("*").
|
// contain wildcard characters ("*").
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
string HTTPClient::
|
string HTTPClient::
|
||||||
get_direct_host_spec() const {
|
get_direct_host_spec() const {
|
||||||
string result;
|
string result;
|
||||||
|
|
||||||
vector_string::const_iterator si;
|
DirectHosts::const_iterator si;
|
||||||
for (si = _direct_hosts.begin(); si != _direct_hosts.end(); ++si) {
|
for (si = _direct_hosts.begin(); si != _direct_hosts.end(); ++si) {
|
||||||
const string &host = (*si);
|
const GlobPattern &host = (*si);
|
||||||
|
|
||||||
if (!result.empty()) {
|
if (!result.empty()) {
|
||||||
result += ";";
|
result += ";";
|
||||||
}
|
}
|
||||||
result += host;
|
result += host.get_pattern();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -367,6 +365,8 @@ clear_proxy() {
|
|||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void HTTPClient::
|
void HTTPClient::
|
||||||
add_proxy(const string &scheme, const URLSpec &proxy) {
|
add_proxy(const string &scheme, const URLSpec &proxy) {
|
||||||
|
URLSpec proxy_url(proxy);
|
||||||
|
|
||||||
// The scheme is always converted to lowercase.
|
// The scheme is always converted to lowercase.
|
||||||
string lc_scheme;
|
string lc_scheme;
|
||||||
lc_scheme.reserve(scheme.length());
|
lc_scheme.reserve(scheme.length());
|
||||||
@ -379,7 +379,18 @@ add_proxy(const string &scheme, const URLSpec &proxy) {
|
|||||||
lc_scheme = lc_scheme.substr(0, lc_scheme.length() - 1);
|
lc_scheme = lc_scheme.substr(0, lc_scheme.length() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
_proxies_by_scheme[lc_scheme].push_back(proxy);
|
if (lc_scheme == "socks") {
|
||||||
|
// Scheme "socks" implies we talk to the proxy via the "socks"
|
||||||
|
// scheme, no matter what scheme the user actually specified.
|
||||||
|
proxy_url.set_scheme("socks");
|
||||||
|
|
||||||
|
} else if (!proxy_url.has_scheme()) {
|
||||||
|
// Otherwise, if the user didn't specify a scheme to talk to the
|
||||||
|
// proxy, the default is "http".
|
||||||
|
proxy_url.set_scheme("http");
|
||||||
|
}
|
||||||
|
|
||||||
|
_proxies_by_scheme[lc_scheme].push_back(proxy_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -414,7 +425,7 @@ add_direct_host(const string &hostname) {
|
|||||||
lc_hostname += tolower(*si);
|
lc_hostname += tolower(*si);
|
||||||
}
|
}
|
||||||
|
|
||||||
_direct_hosts.push_back(lc_hostname);
|
_direct_hosts.push_back(GlobPattern(lc_hostname));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
@ -435,10 +446,9 @@ get_proxies_for_url(const URLSpec &url, pvector<URLSpec> &proxies) const {
|
|||||||
// First, check if the hostname matches any listed in direct_hosts.
|
// First, check if the hostname matches any listed in direct_hosts.
|
||||||
string hostname = url.get_server();
|
string hostname = url.get_server();
|
||||||
|
|
||||||
// TODO: This should be a glob match, not a literal match.
|
DirectHosts::const_iterator si;
|
||||||
vector_string::const_iterator si;
|
|
||||||
for (si = _direct_hosts.begin(); si != _direct_hosts.end(); ++si) {
|
for (si = _direct_hosts.begin(); si != _direct_hosts.end(); ++si) {
|
||||||
if ((*si) == hostname) {
|
if ((*si).matches(hostname)) {
|
||||||
// It matches, so don't use any proxies.
|
// It matches, so don't use any proxies.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,10 @@
|
|||||||
#include "urlSpec.h"
|
#include "urlSpec.h"
|
||||||
#include "httpAuthorization.h"
|
#include "httpAuthorization.h"
|
||||||
#include "httpEnum.h"
|
#include "httpEnum.h"
|
||||||
|
#include "globPattern.h"
|
||||||
#include "pointerTo.h"
|
#include "pointerTo.h"
|
||||||
#include "pvector.h"
|
#include "pvector.h"
|
||||||
#include "pmap.h"
|
#include "pmap.h"
|
||||||
#include "vector_string.h"
|
|
||||||
|
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
|
|
||||||
@ -136,7 +136,8 @@ private:
|
|||||||
typedef pvector<URLSpec> Proxies;
|
typedef pvector<URLSpec> Proxies;
|
||||||
typedef pmap<string, Proxies> ProxiesByScheme;
|
typedef pmap<string, Proxies> ProxiesByScheme;
|
||||||
ProxiesByScheme _proxies_by_scheme;
|
ProxiesByScheme _proxies_by_scheme;
|
||||||
vector_string _direct_hosts;
|
typedef pvector<GlobPattern> DirectHosts;
|
||||||
|
DirectHosts _direct_hosts;
|
||||||
|
|
||||||
HTTPEnum::HTTPVersion _http_version;
|
HTTPEnum::HTTPVersion _http_version;
|
||||||
VerifySSL _verify_ssl;
|
VerifySSL _verify_ssl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user