Set env ip to that of sender.
This commit is contained in:
parent
72f1e99bb8
commit
176becbfce
1 changed files with 19 additions and 8 deletions
|
|
@ -25,17 +25,23 @@ my $webguiRoot = '/data/WebGUI';
|
||||||
#---------------------------------------------------------------
|
#---------------------------------------------------------------
|
||||||
# Startup
|
# Startup
|
||||||
{
|
{
|
||||||
my ( $configFile, $command, $id ) = getCredentials();
|
my ( $configFile, $command, $id, $sender, $senderIp ) = getCredentials();
|
||||||
|
|
||||||
if ( WebGUI::MailCommand::isValidCommand( $command ) ) {
|
if ( WebGUI::MailCommand::isValidCommand( $command ) ) {
|
||||||
my $session = openSession( $webguiRoot, $configFile );
|
my $session = openSession( $webguiRoot, $configFile );
|
||||||
|
no warnings 'once';
|
||||||
WebGUI::MailCommand::processCommand( $session, $command, $id );
|
*{ WebGUI::Session::Env::getIp } = sub {
|
||||||
|
return $senderIp;
|
||||||
|
};
|
||||||
|
|
||||||
|
$session->log->warn( "IP is : [$senderIp][" .$session->env->getIp ."]");
|
||||||
|
|
||||||
|
WebGUI::MailCommand::processCommand( $session, $command, $id, $sender );
|
||||||
|
|
||||||
closeSession( $session );
|
closeSession( $session );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
# TODO: log something
|
die "Not a valid command [$command].";
|
||||||
}
|
}
|
||||||
|
|
||||||
exit(0);
|
exit(0);
|
||||||
|
|
@ -43,14 +49,18 @@ my $webguiRoot = '/data/WebGUI';
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
sub getCredentials {
|
sub getCredentials {
|
||||||
my ( $domain, $user );
|
my ( $domain, $user, $sender, $senderIp );
|
||||||
|
|
||||||
GetOptions(
|
GetOptions(
|
||||||
'domain=s' => \$domain,
|
'domain=s' => \$domain,
|
||||||
'user=s' => \$user,
|
'user=s' => \$user,
|
||||||
|
'sender=s' => \$sender,
|
||||||
|
'senderIp=s'=> \$senderIp,
|
||||||
);
|
);
|
||||||
die "--domain parameter is required" unless $domain;
|
die "--domain parameter is required" unless $domain;
|
||||||
die "--user paramere is required" unless $user;
|
die "--user parameter is required" unless $user;
|
||||||
|
die "--sender parameter is required" unless $sender;
|
||||||
|
die "--senderIp parameter is required" unless $senderIp;
|
||||||
|
|
||||||
my $dispatch = WebGUI::Config->new( $webguiRoot, 'mailing_dispatch.config' )
|
my $dispatch = WebGUI::Config->new( $webguiRoot, 'mailing_dispatch.config' )
|
||||||
|| die "Cannot open $webguiRoot/etc/mailing_dispatch.config";
|
|| die "Cannot open $webguiRoot/etc/mailing_dispatch.config";
|
||||||
|
|
@ -64,7 +74,8 @@ sub getCredentials {
|
||||||
die "Received mail addressed to [$user\@$domain] which contains no id" unless $id;
|
die "Received mail addressed to [$user\@$domain] which contains no id" unless $id;
|
||||||
die "Received mail addressed to [$user\@$domain] which contains no command" unless $command;
|
die "Received mail addressed to [$user\@$domain] which contains no command" unless $command;
|
||||||
|
|
||||||
return ( $configFile, $command, $id );
|
|
||||||
|
return ( $configFile, $command, $id, $sender, $senderIp );
|
||||||
}
|
}
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue