Subject: | Support for Binding to a specific address |
Hello,
This patch lets the user select the local IP address for the outgoing
connections (in case the machine has several IPs).
Index: MTA.pm
===================================================================
--- MTA.pm.orig
+++ MTA.pm
@@ -29,6 +29,7 @@
@NoBounceRegexList
$MaxActiveKids
$FourErrCacheLifetime
+ $BindAddress
%SMTProutes
/;
@@ -790,6 +791,11 @@
my $paddr = sockaddr_in( 25, $iaddr );
socket( SOCK, PF_INET, SOCK_STREAM, getprotobyname('tcp') )
or die "$$ socket: $!";
+
+ my $laddr = defined $BindAddress ? inet_aton($BindAddress)
+ : INADDR_ANY;
+ my $sockaddr = sockaddr_in(0, $laddr);
+ bind( SOCK, $sockaddr ) or die "$!";
connect( SOCK, $paddr ) || next;
mylog "connected to $Peerout";