tags 513549 + patch
thanks

Hi Andreas,

attached you can find a patch which gives swaks a basic IPv6 support.
At least for me it does what I need now.

Regards
  Micha
--- swaks.orig	2009-05-25 13:22:22.000000000 +0200
+++ swaks	2009-05-25 13:55:17.000000000 +0200
@@ -5,6 +5,7 @@
 #	please send an email to updates-sw...@jetmore.net
 
 use strict;
+use IO::Socket::INET6;
 
 my($p_name)   = $0 =~ m|/?([^/]+)$|;
 my $p_version = "20061116.0";
@@ -154,7 +155,8 @@
                                   } (keys %G::auth_map_t)
                              ), "\n";
   print "quit after       = $G::quit_after\n";
-  print "local int        = $G::link{lint}\n";
+  print "local int (IPv4) = $G::link{lint}\n";
+  print "local int (IPv6) = $G::link{lint6}\n";
   print "timeout          = $G::link{timeout}\n";
   print "data             = <<.\n$opts->{data}\n";
   exit(0);
@@ -198,9 +200,16 @@
                             LocalAddr => $G::link{lint});
 
     if ($@) {
-      ptrans(12, "Error connecting $G::link{lint} " .
+      $@ = "";
+      $G::link{sock} = IO::Socket::INET6->new(PeerAddr => $G::link{server},
+                            PeerPort  => $G::link{port}, Proto => 'tcp',
+                            Timeout   => $G::link{timeout},
+                            LocalAddr => $G::link{lint6});
+      if ($@) {
+        ptrans(12, "Error connecting $G::link{lint} " .
                             "to $G::link{server}:$G::link{port}:\n\t$@");
-      exit(2);
+        exit(2);
+      }
     }
     ptrans(11, "Connected to $G::link{server}.");
   } elsif ($G::link{type} eq 'socket-unix') {
@@ -1220,9 +1229,12 @@
   }
 
   # local interface to connect from
-  $G::link{lint}   = $o->{lint} || interact("Interface: ", '^.*$')
+  $G::link{lint}   = $o->{lint}  || interact("Interface IPv4: ", '^.*$')
       if (defined($o->{lint}));
-  $G::link{lint} ||= $fconf->{INTERFACE} || '0.0.0.0';
+  $G::link{lint6}  = $o->{lint6} || interact("Interface IPv6: ", '^.*$')
+      if (defined($o->{lint6}));
+  $G::link{lint}  ||= $fconf->{INTERFACE} || '0.0.0.0';
+  $G::link{lint6} ||= $fconf->{INTERFACE} || '::0';
 
   # SMTP timeout
   $o->{timeout}       = '0s' if ($o->{timeout} eq '0'); # used 'eq' on purpose

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to