From bf30a269c9bc4506f5214fa0d9262fd44247c28a Mon Sep 17 00:00:00 2001 From: luzluna park Date: Tue, 3 Jun 2014 16:45:10 +0900 Subject: [PATCH] Revert "stunnel proxy protocol remote ip,port setting feature added for smtps." This reverts commit eaebf766bca9e07d1aee8d9db18ad867de4f9643. --- lib/Qpsmtpd/PollServer.pm | 1 - lib/Qpsmtpd/SMTP.pm | 48 +-------------------------------------- 2 files changed, 1 insertion(+), 48 deletions(-) diff --git a/lib/Qpsmtpd/PollServer.pm b/lib/Qpsmtpd/PollServer.pm index 39313af..a9e6ba0 100644 --- a/lib/Qpsmtpd/PollServer.pm +++ b/lib/Qpsmtpd/PollServer.pm @@ -85,7 +85,6 @@ sub reset_for_next_message { $self->SUPER::reset_for_next_message(@_); $self->{_commands} = { - proxy => 1, ehlo => 1, helo => 1, rset => 1, diff --git a/lib/Qpsmtpd/SMTP.pm b/lib/Qpsmtpd/SMTP.pm index 2eeb156..fe8e63e 100644 --- a/lib/Qpsmtpd/SMTP.pm +++ b/lib/Qpsmtpd/SMTP.pm @@ -34,7 +34,7 @@ sub new { my $self = bless({args => \%args}, $class); - my (@commands) = qw(proxy ehlo helo rset mail rcpt data help vrfy noop quit); + my (@commands) = qw(ehlo helo rset mail rcpt data help vrfy noop quit); my (%commands); @commands{@commands} = ('') x @commands; @@ -150,52 +150,6 @@ sub connection { || ($self->{_connection} = Qpsmtpd::Connection->new()); } -# proxy command process for stunnel (protocol = proxy) config to support smtps -sub proxy { - my ($self, $line) = @_; - # if not stunnel bypass - return if ( $self->connection->remote_ip() ne '127.0.0.1' ); - # input format : PROXY TCP4 192.168.41.227 10.27.11.106 50060 465 - if ( $line =~ m/^(.*?) (.*?) (.*?) (.*?) (.*?)$/ ) { - my $protocol = $1; - my $remote_ip = $2; - my $local_ip = $3; - my $remote_port = $4; - my $local_port = $5; - $self->connection->remote_ip( $remote_ip ); - $self->connection->remote_port( $remote_port ); - $self->connection->remote_info( "[$remote_ip]"); - - if ( $self->isa('Qpsmtpd::PollServer') ) { - use ParaDNS; - ParaDNS->new( - finished => sub { $self->continue_read() }, - callback => sub { $self->connection->remote_host($_[0]) }, - host => $remote_ip, - ); - } - else { - my $res = Net::DNS::Resolver->new( dnsrch => 0 ); - $res->tcp_timeout(3); - $res->udp_timeout(3); - my $query = $res->query( $remote_ip, 'PTR' ); - if ($query) { - foreach my $rr ($query->answer) { - next if $rr->type ne 'PTR'; - $self->connection->remote_host( $rr->ptrdname ); - } - } - } - - $self->connection->notes('proxy', 'YES'); - $self->connection->notes('protocol', $protocol); - $self->connection->notes('remote_ip', $remote_ip); - $self->connection->notes('remote_port', $remote_port); - $self->connection->notes('local_ip', $local_ip); - $self->connection->notes('local_port', $local_port); - } -} - sub helo { my ($self, $line) = @_; my ($rc, @msg) = $self->run_hooks('helo_parse');