diff options
Diffstat (limited to 'web/attachments/295596-check_ircd.pl.diff')
-rw-r--r-- | web/attachments/295596-check_ircd.pl.diff | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/web/attachments/295596-check_ircd.pl.diff b/web/attachments/295596-check_ircd.pl.diff new file mode 100644 index 0000000..b3792c4 --- /dev/null +++ b/web/attachments/295596-check_ircd.pl.diff | |||
@@ -0,0 +1,119 @@ | |||
1 | --- check_ircd.pl.orig 2002-05-06 22:35:49.000000000 -0700 | ||
2 | +++ check_ircd.pl 2008-10-01 01:22:43.496305819 -0700 | ||
3 | @@ -43,15 +43,17 @@ | ||
4 | |||
5 | # ----------------------------------------------------------------[ Require ]-- | ||
6 | |||
7 | -require 5.004; | ||
8 | +require 5.6.0; | ||
9 | |||
10 | # -------------------------------------------------------------------[ Uses ]-- | ||
11 | |||
12 | -use Socket; | ||
13 | use strict; | ||
14 | +use IO::Socket; | ||
15 | +use Sys::Hostname; | ||
16 | use Getopt::Long; | ||
17 | use vars qw($opt_V $opt_h $opt_t $opt_p $opt_H $opt_w $opt_c $verbose); | ||
18 | use vars qw($PROGNAME); | ||
19 | +use vars qw($ClientSocket); | ||
20 | use lib utils.pm; | ||
21 | use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); | ||
22 | |||
23 | @@ -60,7 +62,6 @@ | ||
24 | sub print_help (); | ||
25 | sub print_usage (); | ||
26 | sub connection ($$$$); | ||
27 | -sub bindRemote ($$$); | ||
28 | |||
29 | # -------------------------------------------------------------[ Enviroment ]-- | ||
30 | |||
31 | @@ -104,7 +105,7 @@ | ||
32 | $answer = "Server $in_remotehost has less than 0 users! Something is Really WRONG!\n"; | ||
33 | } | ||
34 | |||
35 | - print ClientSocket "quit\n"; | ||
36 | + print $ClientSocket "quit\n"; | ||
37 | print $answer; | ||
38 | exit $ERRORS{$state}; | ||
39 | } | ||
40 | @@ -140,38 +141,6 @@ | ||
41 | "; | ||
42 | } | ||
43 | |||
44 | -# -------------------------------------------------------------[ bindRemote ]-- | ||
45 | - | ||
46 | -sub bindRemote ($$$) | ||
47 | -{ | ||
48 | - my ($in_remotehost, $in_remoteport, $in_hostname) = @_; | ||
49 | - my $proto = getprotobyname('tcp'); | ||
50 | - my $sockaddr; | ||
51 | - my $this; | ||
52 | - my $thisaddr = gethostbyname($in_hostname); | ||
53 | - my $that; | ||
54 | - my ($name, $aliases,$type,$len,$thataddr) = gethostbyname($in_remotehost); | ||
55 | -# ($name,$aliases,$type,$len,$thisaddr) = gethostbyname($in_hostname); | ||
56 | - | ||
57 | - if (!socket(ClientSocket,AF_INET, SOCK_STREAM, $proto)) { | ||
58 | - print "IRCD UNKNOWN: Could not start socket ($!)\n"; | ||
59 | - exit $ERRORS{"UNKNOWN"}; | ||
60 | - } | ||
61 | - $sockaddr = 'S n a4 x8'; | ||
62 | - $this = pack($sockaddr, AF_INET, 0, $thisaddr); | ||
63 | - $that = pack($sockaddr, AF_INET, $in_remoteport, $thataddr); | ||
64 | - if (!bind(ClientSocket, $this)) { | ||
65 | - print "IRCD UNKNOWN: Could not bind socket ($!)\n"; | ||
66 | - exit $ERRORS{"UNKNOWN"}; | ||
67 | - } | ||
68 | - if (!connect(ClientSocket, $that)) { | ||
69 | - print "IRCD UNKNOWN: Could not connect socket ($!)\n"; | ||
70 | - exit $ERRORS{"UNKNOWN"}; | ||
71 | - } | ||
72 | - select(ClientSocket); $| = 1; select(STDOUT); | ||
73 | - return \*ClientSocket; | ||
74 | -} | ||
75 | - | ||
76 | # ===================================================================[ MAIN ]== | ||
77 | |||
78 | MAIN: | ||
79 | @@ -222,24 +191,34 @@ | ||
80 | |||
81 | alarm($TIMEOUT); | ||
82 | |||
83 | - chomp($hostname = `/bin/hostname`); | ||
84 | + $hostname = hostname; | ||
85 | $hostname = $1 if ($hostname =~ /([-.a-zA-Z0-9]+)/); | ||
86 | - my ($name, $alias, $proto) = getprotobyname('tcp'); | ||
87 | print "MAIN(debug): hostname = $hostname\n" if $verbose; | ||
88 | |||
89 | print "MAIN(debug): binding to remote host: $remotehost -> $remoteport -> $hostname\n" if $verbose; | ||
90 | - my $ClientSocket = &bindRemote($remotehost,$remoteport,$hostname); | ||
91 | + | ||
92 | + $ClientSocket = IO::Socket::INET->new( | ||
93 | + PeerAddr => $remotehost, | ||
94 | + PeerPort => $remoteport, | ||
95 | + LocalAddr => $hostname, | ||
96 | + Proto => "tcp" | ||
97 | + ); | ||
98 | + | ||
99 | + if (! $ClientSocket) { | ||
100 | + print "IRCD UNKNOWN: Could not connect socket ($!)\n"; | ||
101 | + exit $ERRORS{"UNKNOWN"}; | ||
102 | + } | ||
103 | |||
104 | - print ClientSocket "NICK $NICK\nUSER $USER_INFO\n"; | ||
105 | + print $ClientSocket "NICK $NICK\nUSER $USER_INFO\n"; | ||
106 | |||
107 | - while (<ClientSocket>) { | ||
108 | + while (<$ClientSocket>) { | ||
109 | print "MAIN(debug): default var = $_\n" if $verbose; | ||
110 | |||
111 | # DALnet,LagNet,UnderNet etc. Require this! | ||
112 | # Replies with a PONG when presented with a PING query. | ||
113 | # If a server doesn't require it, it will be ignored. | ||
114 | |||
115 | - if (m/^PING (.*)/) {print ClientSocket "PONG $1\n";} | ||
116 | + if (m/^PING (.*)/) {print $ClientSocket "PONG $1\n";} | ||
117 | |||
118 | alarm(0); | ||
119 | |||