From 417659b757afc85fc437f3da462c09a4b86c1282 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Fri, 6 Mar 2020 14:38:59 +0200 Subject: Version 0.5 * NEWS: Update. * configure.ac: Raise version number. * examples/lib/LWP/Ping903.pm: Remove. * examples/README: Mention Mangemanche. Remove references to lib/LWP/Ping903.pm * examples/dbload: Revert to LWP::UserAgent * examples/inspect: Likewise. * examples/ipadd: Likewise. * examples/ipdel: Likewise. --- examples/README | 15 +++----------- examples/dbload | 4 ++-- examples/inspect | 4 ++-- examples/ipadd | 4 ++-- examples/ipdel | 4 ++-- examples/lib/LWP/Ping903.pm | 49 --------------------------------------------- 6 files changed, 11 insertions(+), 69 deletions(-) delete mode 100644 examples/lib/LWP/Ping903.pm (limited to 'examples') diff --git a/examples/README b/examples/README index f5a1c50..df17f0c 100644 --- a/examples/README +++ b/examples/README @@ -5,6 +5,9 @@ facilities via REST API. You can use them as templates for writing your own configuration system, or just run them as they are, if you prefer. +For a mature, advanced ping903 remote management system, please see +. + * Programs - inspect @@ -20,18 +23,6 @@ prefer. - dbload Populates the list of monitored addresses from a SQL database. -All these programs use the LWP::Ping903 module, which provides support -for parsing the ".ping903.cred" file. The source file for the module is -lib/LWP/Ping903.pm. To run the programs from the examples directory, -define the following environment variable: - - export PERL5LIB=lib - -If you don't plan to use basic authorization, you can get rid of this -dependency using the following command: - - sed -i 's/LWP::Ping903/LWP::UserAgent/' inspect ipadd ipdel dbload - * Documentation Each example is self-documented. To access the description, run the diff --git a/examples/dbload b/examples/dbload index 245ace2..4502d55 100755 --- a/examples/dbload +++ b/examples/dbload @@ -179,7 +179,7 @@ L. use strict; use warnings; use JSON; -use LWP::Ping903; +use LWP::UserAgent; use DBI; use Getopt::Long qw(:config gnu_getopt no_ignore_case); use File::Spec; @@ -253,7 +253,7 @@ my $json_text = JSON->new->encode({ 'ip-list' => [ map { $_->[0] } @$res ] }); -my $ua = new LWP::Ping903; +my $ua = new LWP::UserAgent; my $response = $ua->post("$baseurl/config/ip-list", 'Content-Type' => 'application/json', diff --git a/examples/inspect b/examples/inspect index af3d3de..0aa2fb5 100755 --- a/examples/inspect +++ b/examples/inspect @@ -73,7 +73,7 @@ L. use strict; use warnings; -use LWP::Ping903; +use LWP::UserAgent; use HTTP::Status qw(:constants); use JSON; use Getopt::Long qw(:config gnu_getopt no_ignore_case); @@ -99,7 +99,7 @@ GetOptions( ) or exit(1); die "too many arguments; try `$0 --help' for more info\n" if @ARGV; -my $ua = new LWP::Ping903; +my $ua = new LWP::UserAgent; my $response = $ua->get("$baseurl/config"); unless ($response->is_success) { diff --git a/examples/ipadd b/examples/ipadd index d6195da..f001950 100755 --- a/examples/ipadd +++ b/examples/ipadd @@ -57,7 +57,7 @@ L. use strict; use warnings; -use LWP::Ping903; +use LWP::UserAgent; use JSON; use Getopt::Long qw(:config gnu_getopt no_ignore_case); use Pod::Usage; @@ -82,7 +82,7 @@ GetOptions( my $ip = shift @ARGV or die "not enough arguments"; die "too many arguments; try `$0 --help' for more info\n" if @ARGV; -my $ua = new LWP::Ping903; +my $ua = new LWP::UserAgent; my $response = $ua->put("$baseurl/config/ip-list/$ip"); unless ($response->is_success) { print $response->status_line,"\n"; diff --git a/examples/ipdel b/examples/ipdel index 8eed7eb..fa4cb8f 100755 --- a/examples/ipdel +++ b/examples/ipdel @@ -57,7 +57,7 @@ L. use strict; use warnings; -use LWP::Ping903; +use LWP::UserAgent; use JSON; use Getopt::Long qw(:config gnu_getopt no_ignore_case); use Pod::Usage; @@ -83,7 +83,7 @@ my $ip = shift @ARGV or die "not enough arguments"; die "too many arguments; try `$0 --help' for more info\n" if @ARGV; -my $ua = new LWP::Ping903; +my $ua = new LWP::UserAgent; my $response = $ua->delete("$baseurl/config/ip-list/$ip"); unless ($response->is_success) { print $response->status_line,"\n"; diff --git a/examples/lib/LWP/Ping903.pm b/examples/lib/LWP/Ping903.pm deleted file mode 100644 index 8fc398e..0000000 --- a/examples/lib/LWP/Ping903.pm +++ /dev/null @@ -1,49 +0,0 @@ -package LWP::Ping903; -use parent 'LWP::UserAgent'; -use File::Spec; -use HTTP::Status qw(:constants); -use strict; -use warnings; -use Carp; - -my $VERSION = '0.3'; - -sub new { - my $class = shift; - my $self = bless $class->SUPER::new(@_), $class; - $self->agent("$class/$VERSION"); - return $self; -} - -sub get_basic_credentials { - my ($self, $realm, $uri, $isproxy) = @_; - my $cf = File::Spec->catfile($ENV{HOME}, ".ping903.cred"); - if (open(my $fh, '<', $cf)) { - while (<$fh>) { - chomp; - s/^\s+//; - s/\s+$//; - next if /^(#.*)?$/; - my @words; - while ($_) { - no warnings 'uninitialized'; - if (s/^"(.*?)(?host) - && (!$p || $p eq '*' || $p eq $uri->port) - && ($words[1] eq $realm || $words[1] eq '*')) { - return @words[2..3]; - } - } - } - } - return (); -} -- cgit v1.2.1