Permalink
Browse files

add INET6 Client.pm support from dkimproxy

  • Loading branch information...
1 parent 83bc7a8 commit 37992d3f0ceb8ab9fa907903cd7b7fe36ec1d670 @jnorell committed Dec 11, 2012
Showing with 74 additions and 3 deletions.
  1. +1 −0 .gitignore
  2. +21 −3 MSDW/SMTP/Client.pm
  3. +1 −0 debian/changelog
  4. +50 −0 debian/patches/add-dkim-inet6-client.patch
  5. +1 −0 debian/patches/series
View
@@ -14,3 +14,4 @@ META.yml
MYMETA.yml
nytprof.out
pm_to_blib
+.pc
View
@@ -10,6 +10,17 @@
#
# Written by Bennett Todd <bet@rahul.net>
+#enable support for IPv6, if available
+eval "require IO::Socket::INET6";
+if ($@ && $@ =~ /^Can't locate/)
+{
+ # a dummy INET6 module that falls back on IO::Socket::INET
+ eval q|
+ package IO::Socket::INET6;
+ use base "IO::Socket::INET";
+ |;
+}
+
package MSDW::SMTP::Client;
use IO::Socket;
@@ -95,7 +106,7 @@ sub new {
my ($this, @opts) = @_;
my $class = ref($this) || $this;
my $self = bless { timeout => 300, @opts }, $class;
- $self->{sock} = IO::Socket::INET->new(
+ $self->{sock} = IO::Socket::INET6->new(
PeerAddr => $self->{interface},
PeerPort => $self->{port},
Timeout => $self->{timeout},
@@ -130,10 +141,17 @@ sub yammer {
local (*_);
local ($/) = "\r\n";
while (<$fh>) {
- s/^\./../;
- $self->{sock}->print($_) or die "$0: write error: $!\n";
+ $self->write_data_line($_);
}
$self->{sock}->print(".\r\n") or die "$0: write error: $!\n";
}
+sub write_data_line
+{
+ my ($self, $line) = @_;
+ $line =~ s/^\./../;
+ $self->{sock}->print($line)
+ or die "$0: write error: $!\n";
+}
+
1;
View
@@ -1,5 +1,6 @@
smtpprox (1.2-1) UNRELEASED; urgency=low
* Initial release
+ * Add INET6 support from dkimproxy's Client.pm.
-- Jesse Norell <jesse@kci.net> Mon, 26 Nov 2012 16:06:47 -0700
@@ -0,0 +1,50 @@
+Add dkimproxy's INET6 support to Client.pm.
+--- a/MSDW/SMTP/Client.pm
++++ b/MSDW/SMTP/Client.pm
+@@ -10,6 +10,17 @@
+ #
+ # Written by Bennett Todd <bet@rahul.net>
+
++#enable support for IPv6, if available
++eval "require IO::Socket::INET6";
++if ($@ && $@ =~ /^Can't locate/)
++{
++ # a dummy INET6 module that falls back on IO::Socket::INET
++ eval q|
++ package IO::Socket::INET6;
++ use base "IO::Socket::INET";
++ |;
++}
++
+ package MSDW::SMTP::Client;
+ use IO::Socket;
+
+@@ -95,7 +106,7 @@
+ my ($this, @opts) = @_;
+ my $class = ref($this) || $this;
+ my $self = bless { timeout => 300, @opts }, $class;
+- $self->{sock} = IO::Socket::INET->new(
++ $self->{sock} = IO::Socket::INET6->new(
+ PeerAddr => $self->{interface},
+ PeerPort => $self->{port},
+ Timeout => $self->{timeout},
+@@ -130,10 +141,17 @@
+ local (*_);
+ local ($/) = "\r\n";
+ while (<$fh>) {
+- s/^\./../;
+- $self->{sock}->print($_) or die "$0: write error: $!\n";
++ $self->write_data_line($_);
+ }
+ $self->{sock}->print(".\r\n") or die "$0: write error: $!\n";
+ }
+
++sub write_data_line
++{
++ my ($self, $line) = @_;
++ $line =~ s/^\./../;
++ $self->{sock}->print($line)
++ or die "$0: write error: $!\n";
++}
++
+ 1;
View
@@ -0,0 +1 @@
+add-dkim-inet6-client.patch

0 comments on commit 37992d3

Please sign in to comment.