diff options
Diffstat (limited to 'web/attachments/293580-check_ircd.pl.patch')
-rw-r--r-- | web/attachments/293580-check_ircd.pl.patch | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/web/attachments/293580-check_ircd.pl.patch b/web/attachments/293580-check_ircd.pl.patch new file mode 100644 index 0000000..511b719 --- /dev/null +++ b/web/attachments/293580-check_ircd.pl.patch | |||
@@ -0,0 +1,121 @@ | |||
1 | --- check_ircd.pl.orig 2008-09-16 12:41:20.000000000 +0200 | ||
2 | +++ check_ircd.pl 2008-09-16 12:43:23.000000000 +0200 | ||
3 | @@ -1,4 +1,4 @@ | ||
4 | -#!/usr/bin/perl -wT | ||
5 | +#! /usr/bin/perl -wT | ||
6 | |||
7 | # ----------------------------------------------------------------------------- | ||
8 | # File Name: check_ircd.pl | ||
9 | @@ -50,7 +50,7 @@ | ||
10 | use Socket; | ||
11 | use strict; | ||
12 | use Getopt::Long; | ||
13 | -use vars qw($opt_V $opt_h $opt_t $opt_p $opt_H $opt_w $opt_c $verbose); | ||
14 | +use vars qw($opt_V $opt_h $opt_t $opt_p $opt_H $opt_w $opt_c $verbose $opt_6); | ||
15 | use vars qw($PROGNAME); | ||
16 | use lib utils.pm; | ||
17 | use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); | ||
18 | @@ -60,7 +60,7 @@ | ||
19 | sub print_help (); | ||
20 | sub print_usage (); | ||
21 | sub connection ($$$$); | ||
22 | -sub bindRemote ($$$); | ||
23 | +sub connectRemote ($$); | ||
24 | |||
25 | # -------------------------------------------------------------[ Enviroment ]-- | ||
26 | |||
27 | @@ -140,30 +140,36 @@ | ||
28 | "; | ||
29 | } | ||
30 | |||
31 | -# -------------------------------------------------------------[ bindRemote ]-- | ||
32 | +# ----------------------------------------------------------[ connectRemote ]-- | ||
33 | |||
34 | -sub bindRemote ($$$) | ||
35 | +sub connectRemote ($$) | ||
36 | { | ||
37 | - my ($in_remotehost, $in_remoteport, $in_hostname) = @_; | ||
38 | + my ($in_remotehost, $in_remoteport) = @_; | ||
39 | my $proto = getprotobyname('tcp'); | ||
40 | my $sockaddr; | ||
41 | - my $this; | ||
42 | - my $thisaddr = gethostbyname($in_hostname); | ||
43 | my $that; | ||
44 | - my ($name, $aliases,$type,$len,$thataddr) = gethostbyname($in_remotehost); | ||
45 | -# ($name,$aliases,$type,$len,$thisaddr) = gethostbyname($in_hostname); | ||
46 | + my $pf; | ||
47 | + if ($opt_6) { | ||
48 | + require Socket6; | ||
49 | + $pf = PF_INET6; | ||
50 | + unless ($that = (Socket6::getaddrinfo($in_remotehost, $in_remoteport, AF_INET6, SOCK_STREAM, $proto))[3]) { | ||
51 | + print "IRCD UNKNOWN: Could not resolve $in_remotehost\n"; | ||
52 | + exit $ERRORS{"UNKNOWN"}; | ||
53 | + } | ||
54 | + } else { | ||
55 | + $pf = PF_INET; | ||
56 | + unless ($that = gethostbyname($in_remotehost)) { | ||
57 | + print "IRCD UNKNOWN: Could not resolve $in_remotehost\n"; | ||
58 | + exit $ERRORS{"UNKNOWN"}; | ||
59 | + } | ||
60 | + $sockaddr = 'S n a4 x8'; | ||
61 | + $that = pack($sockaddr, AF_INET, $in_remoteport, $that); | ||
62 | + } | ||
63 | |||
64 | - if (!socket(ClientSocket,AF_INET, SOCK_STREAM, $proto)) { | ||
65 | + if (!socket(ClientSocket, $pf, SOCK_STREAM, $proto)) { | ||
66 | print "IRCD UNKNOWN: Could not start socket ($!)\n"; | ||
67 | exit $ERRORS{"UNKNOWN"}; | ||
68 | } | ||
69 | - $sockaddr = 'S n a4 x8'; | ||
70 | - $this = pack($sockaddr, AF_INET, 0, $thisaddr); | ||
71 | - $that = pack($sockaddr, AF_INET, $in_remoteport, $thataddr); | ||
72 | - if (!bind(ClientSocket, $this)) { | ||
73 | - print "IRCD UNKNOWN: Could not bind socket ($!)\n"; | ||
74 | - exit $ERRORS{"UNKNOWN"}; | ||
75 | - } | ||
76 | if (!connect(ClientSocket, $that)) { | ||
77 | print "IRCD UNKNOWN: Could not connect socket ($!)\n"; | ||
78 | exit $ERRORS{"UNKNOWN"}; | ||
79 | @@ -183,6 +189,7 @@ | ||
80 | ("V" => \$opt_V, "version" => \$opt_V, | ||
81 | "h" => \$opt_h, "help" => \$opt_h, | ||
82 | "v" => \$verbose,"verbose" => \$verbose, | ||
83 | + "6" => \$opt_6, | ||
84 | "t=i" => \$opt_t, "timeout=i" => \$opt_t, | ||
85 | "w=i" => \$opt_w, "warning=i" => \$opt_w, | ||
86 | "c=i" => \$opt_c, "critical=i" => \$opt_c, | ||
87 | @@ -190,15 +197,16 @@ | ||
88 | "H=s" => \$opt_H, "hostname=s" => \$opt_H); | ||
89 | |||
90 | if ($opt_V) { | ||
91 | - print_revision($PROGNAME,'$Revision$ '); | ||
92 | + print_revision($PROGNAME,'$Revision: 1.3 $ '); | ||
93 | exit $ERRORS{'OK'}; | ||
94 | } | ||
95 | |||
96 | if ($opt_h) {print_help(); exit $ERRORS{'OK'};} | ||
97 | |||
98 | ($opt_H) || ($opt_H = shift) || usage("Host name/address not specified\n"); | ||
99 | - my $remotehost = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/); | ||
100 | + my $remotehost = $1 if ($opt_H =~ /^([-.:A-Za-z0-9]+)$/); | ||
101 | ($remotehost) || usage("Invalid host: $opt_H\n"); | ||
102 | + $opt_6 ++ if $remotehost =~ /:/; | ||
103 | |||
104 | ($opt_w) || ($opt_w = shift) || ($opt_w = 50); | ||
105 | my $warn = $1 if ($opt_w =~ /^([0-9]+)$/); | ||
106 | @@ -222,13 +230,8 @@ | ||
107 | |||
108 | alarm($TIMEOUT); | ||
109 | |||
110 | - chomp($hostname = `/bin/hostname`); | ||
111 | - $hostname = $1 if ($hostname =~ /([-.a-zA-Z0-9]+)/); | ||
112 | - my ($name, $alias, $proto) = getprotobyname('tcp'); | ||
113 | - print "MAIN(debug): hostname = $hostname\n" if $verbose; | ||
114 | - | ||
115 | - print "MAIN(debug): binding to remote host: $remotehost -> $remoteport -> $hostname\n" if $verbose; | ||
116 | - my $ClientSocket = &bindRemote($remotehost,$remoteport,$hostname); | ||
117 | + print "MAIN(debug): connecting to $remotehost:$remoteport\n" if $verbose; | ||
118 | + my $ClientSocket = &connectRemote($remotehost,$remoteport); | ||
119 | |||
120 | print ClientSocket "NICK $NICK\nUSER $USER_INFO\n"; | ||
121 | |||