This commit is contained in:
garnier-quentin 2015-08-12 11:54:21 +02:00
parent ef7b09e8e1
commit dc877d1da4
5 changed files with 49 additions and 7 deletions

View File

@ -46,6 +46,7 @@ sub new {
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"proxyurl:s" => { name => 'proxyurl' },
"proxypac:s" => { name => 'proxypac' },
"expected-string:s" => { name => 'expected_string' },
"timeout:s" => { name => 'timeout' },
"no-follow" => { name => 'no_follow', },
@ -173,7 +174,11 @@ Port used by Webserver
=item B<--proxyurl>
Proxy URL if any
Proxy URL
=item B<--proxypac>
Proxy pac file (can be an url or local file)
=item B<--method>

View File

@ -50,6 +50,7 @@ sub new {
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"proxyurl:s" => { name => 'proxyurl' },
"proxypac:s" => { name => 'proxypac' },
"header:s@" => { name => 'header' },
"get-param:s@" => { name => 'get_param' },
"timeout:s" => { name => 'timeout', default => 10 },
@ -368,7 +369,11 @@ Port used by Webserver
=item B<--proxyurl>
Proxy URL if any
Proxy URL
=item B<--proxypac>
Proxy pac file (can be an url or local file)
=item B<--proto>

View File

@ -46,6 +46,7 @@ sub new {
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"proxyurl:s" => { name => 'proxyurl' },
"proxypac:s" => { name => 'proxypac' },
"timeout:s" => { name => 'timeout' },
"no-follow" => { name => 'no_follow', },
"ssl:s" => { name => 'ssl' },
@ -187,7 +188,11 @@ Specify password for basic authentification (Mandatory if --credentials is speci
=item B<--proxyurl>
Proxy URL if any
Proxy URL
=item B<--proxypac>
Proxy pac file (can be an url or local file)
=item B<--timeout>

View File

@ -50,6 +50,7 @@ sub new {
"username:s" => { name => 'username' },
"password:s" => { name => 'password' },
"proxyurl:s" => { name => 'proxyurl' },
"proxypac:s" => { name => 'proxypac' },
"header:s@" => { name => 'header' },
"timeout:s" => { name => 'timeout', default => 10 },
"ssl:s" => { name => 'ssl', },
@ -381,7 +382,11 @@ Port used by Webserver
=item B<--proxyurl>
Proxy URL if any
Proxy URL
=item B<--proxypac>
Proxy pac file (can be an url or local file)
=item B<--proto>

View File

@ -147,6 +147,30 @@ sub get_port_request {
return $port;
}
sub set_proxy {
my ($self, %options) = @_;
if (defined($options{request}->{proxypac}) && $options{request}->{proxypac} ne '') {
centreon::plugins::misc::mymodule_load(output => $self->{output}, module => 'HTTP::ProxyPAC',
error_msg => "Cannot load module 'HTTP::ProxyPAC'.");
my $pac;
eval {
$pac = HTTP::ProxyPAC->new($options{request}->{proxypac});
};
if ($@) {
$self->{output}->add_option_msg(short_msg => 'issue to load proxypac: ' . $@);
$self->{output}->option_exit();
}
my $res = $pac->find_proxy($options{url});
if (defined($res->direct) && $res->direct != 1) {
$self->{ua}->proxy(['http', 'https'], $res->proxy);
}
}
if (defined($options{request}->{proxyurl}) && $options{request}->{proxyurl} ne '') {
$self->{ua}->proxy(['http', 'https'], $options{request_options}->{proxyurl});
}
}
sub request {
my ($self, %options) = @_;
@ -215,9 +239,7 @@ sub request {
$req->authorization_basic($request_options->{username}, $request_options->{password});
}
if (defined($request_options->{proxyurl})) {
$self->{ua}->proxy(['http', 'https'], $request_options->{proxyurl});
}
$self->set_proxy(request => $request_options, url => $url);
if (defined($request_options->{cert_pkcs12}) && $request_options->{cert_file} ne '' && $request_options->{cert_pwd} ne '') {
eval "use Net::SSL"; die $@ if $@;