use PVE::Exception;
use PVE::RESTHandler;
use PVE::RPCEnvironment;
+use PVE::API2Tools;
use JSON;
use PVE::JSONSchema qw(get_standard_option);
$ua->max_size(1024*1024);
$ua->ssl_opts(verify_hostname => 0); # don't care for changelogs
+ # HACK: LWP does not use proxy 'CONNECT' for https
+ local $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = "Net::SSL";
+ local ($ENV{HTTPS_PROXY}, $ENV{HTTPS_PROXY_USERNAME}, $ENV{HTTPS_PROXY_PASSWORD});
+
if ($proxy) {
- $ua->proxy(['http', 'https'], $proxy);
+ ($ENV{HTTPS_PROXY}, $ENV{HTTPS_PROXY_USERNAME}, $ENV{HTTPS_PROXY_PASSWORD}) =
+ PVE::API2Tools::parse_http_proxy($proxy);
+ $ua->proxy(['http'], $proxy);
} else {
$ua->env_proxy;
}
$req->content($content);
my $ua = LWP::UserAgent->new(protocols_allowed => ['https'], timeout => 30);
+ $ua->ssl_opts(verify_hostname => 0); # don't care
+
+ # HACK: LWP does not use proxy 'CONNECT' for https
+ local $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = "Net::SSL";
+ local ($ENV{HTTPS_PROXY}, $ENV{HTTPS_PROXY_USERNAME}, $ENV{HTTPS_PROXY_PASSWORD});
if ($proxy) {
- $ua->proxy(['http', 'https'], $proxy);
+ ($ENV{HTTPS_PROXY}, $ENV{HTTPS_PROXY_USERNAME}, $ENV{HTTPS_PROXY_PASSWORD}) =
+ PVE::API2Tools::parse_http_proxy($proxy);
+ $ua->proxy(['http'], $proxy);
} else {
$ua->env_proxy;
}
use warnings;
use PVE::Tools;
use Digest::MD5 qw(md5_hex);
+use URI;
+use URI::Escape;
my $hwaddress;
return $entry;
};
+sub parse_http_proxy {
+ my ($proxyenv) = @_;
+
+ my $uri = URI->new($proxyenv);
+
+ my $scheme = $uri->scheme;
+ my $host = $uri->host;
+ my $port = $uri->port || 3128;
+
+ my ($username, $password);
+
+ if (defined(my $p_auth = $uri->userinfo())) {
+ ($username, $password) = map URI::Escape::uri_unescape($_), split(":", $p_auth, 2);
+ }
+
+ return ("$host:$port", $username, $password);
+}
+
1;