diff options
author | Nicholas Clark <nick@ccl4.org> | 2006-01-10 16:36:03 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2006-01-10 16:36:03 +0000 |
commit | 807d24c827c4cbd2046888817a0509dd8c4b593a (patch) | |
tree | 5643b550bcdbc3ee6f10092ff7ed837909382955 /ext | |
parent | 798b24a857f60d00d6854643c75b8e2ad37b25ce (diff) | |
download | perl-807d24c827c4cbd2046888817a0509dd8c4b593a.tar.gz |
Gisle is correct - $host needs to stay in case the user sets it
themselves. But if the user doesn't, default to INADDR_LOOPBACK.
p4raw-id: //depot/perl@26772
Diffstat (limited to 'ext')
-rw-r--r-- | ext/Sys/Syslog/Syslog.pm | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/ext/Sys/Syslog/Syslog.pm b/ext/Sys/Syslog/Syslog.pm index bdc1e0e335..c9accd3159 100644 --- a/ext/Sys/Syslog/Syslog.pm +++ b/ext/Sys/Syslog/Syslog.pm @@ -42,7 +42,7 @@ my $transmit_ok = 0; my $current_proto = undef; my $failed = undef; my $fail_time = undef; -our ($connected, @fallbackMethods, $syslog_send); +our ($connected, @fallbackMethods, $syslog_send, $host); use Socket ':all'; use POSIX qw(strftime setlocale LC_TIME); @@ -821,7 +821,18 @@ sub connect_tcp { } my $this = sockaddr_in($syslog, INADDR_ANY); - my $that = sockaddr_in($syslog, INADDR_LOOPBACK); + my $that; + if (defined $host) { + $that = inet_aton($host); + if (!$that) { + push(@{$errs}, "can't lookup $host"); + return 0; + } + } else { + $that = INADDR_LOOPBACK; + } + $that = sockaddr_in($syslog, $that); + if (!socket(SYSLOG,AF_INET,SOCK_STREAM,$tcp)) { push(@{$errs}, "tcp socket: $!"); return 0; @@ -849,7 +860,18 @@ sub connect_udp { return 0; } my $this = sockaddr_in($syslog, INADDR_ANY); - my $that = sockaddr_in($syslog, INADDR_LOOPBACK); + my $that; + if (defined $host) { + $that = inet_aton($host); + if (!$that) { + push(@{$errs}, "can't lookup $host"); + return 0; + } + } else { + $that = INADDR_LOOPBACK; + } + $that = sockaddr_in($syslog, $that); + if (!socket(SYSLOG,AF_INET,SOCK_DGRAM,$udp)) { push(@{$errs}, "udp socket: $!"); return 0; |