19 |
|
|
20 |
my $debug=0; |
my $debug=0; |
21 |
|
|
22 |
|
my $reuse_conn=0; # if you set this to 1, it will try to do all expn |
23 |
|
# over single tcp connection. It nice to smtp server, |
24 |
|
# but sendmail slows down after 10 expns or so... |
25 |
|
|
26 |
my ($remote,$port, $iaddr, $paddr, $proto, $line); |
my ($remote,$port, $iaddr, $paddr, $proto, $line); |
27 |
|
|
28 |
$remote = shift || 'intranet.pliva.hr'; |
$remote = shift || 'localhost'; |
29 |
$port = shift || 25; |
$port = shift || 25; |
30 |
|
|
31 |
print "# using remote $remote port $port\n" if ($debug); |
print "# using remote $remote port $port\n" if ($debug); |
32 |
|
|
33 |
if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') } |
sub open_conn { |
34 |
die "No port" unless $port; |
if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') } |
35 |
$iaddr = inet_aton($remote) || die "no host: $remote"; |
die "No port" unless $port; |
36 |
$paddr = sockaddr_in($port, $iaddr); |
$iaddr = inet_aton($remote) || die "no host: $remote"; |
37 |
|
$paddr = sockaddr_in($port, $iaddr); |
38 |
$proto = getprotobyname('tcp'); |
|
39 |
socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die "socket: $!"; |
$proto = getprotobyname('tcp'); |
40 |
connect(SOCK, $paddr) || die "connect: $!"; |
socket(SOCK, PF_INET, SOCK_STREAM, $proto) || die "socket: $!"; |
41 |
select(SOCK); $|=1; |
connect(SOCK, $paddr) || die "connect: $!"; |
42 |
select(STDOUT); $|=1; |
select(SOCK); $|=1; |
43 |
|
select(STDOUT); $|=1; |
44 |
|
|
45 |
|
my $hello=<SOCK>; # hello |
46 |
|
|
47 |
|
} |
48 |
|
|
49 |
my $hello=<SOCK>; # hello |
sub close_conn { |
50 |
|
close (SOCK) || die "close: $!"; |
51 |
|
} |
52 |
|
|
53 |
my %tested; |
my %tested; |
54 |
|
|
79 |
} |
} |
80 |
} |
} |
81 |
|
|
82 |
|
open_conn if ($reuse_conn); |
83 |
|
|
84 |
while(<STDIN>) { |
while(<STDIN>) { |
85 |
chomp; |
chomp; |
86 |
next if (/^#/ || /^$/); |
next if (/^#/ || /^$/); |
87 |
|
open_conn if (! $reuse_conn); |
88 |
try_expn($_); |
try_expn($_); |
89 |
|
close_conn if (! $reuse_conn); |
90 |
} |
} |
91 |
|
|
92 |
close (SOCK) || die "close: $!"; |
close_conn if ($reuse_conn); |
93 |
exit; |
exit; |