diff lib/Test/Nginx/SMTP.pm @ 1660:068c30e9d2c6

Tests: smtp tests with proxy protocol to backend.
author Sergey Kandaurov <pluknet@nginx.com>
date Fri, 05 Mar 2021 19:18:52 +0300
parents 4e0644119341
children d0025a0dead7
line wrap: on
line diff
--- a/lib/Test/Nginx/SMTP.pm
+++ b/lib/Test/Nginx/SMTP.pm
@@ -100,6 +100,7 @@ sub can_read {
 
 sub smtp_test_daemon {
 	my ($port) = @_;
+	my $proxy_protocol;
 
 	my $server = IO::Socket::INET->new(
 		Proto => 'tcp',
@@ -113,6 +114,8 @@ sub smtp_test_daemon {
 		$client->autoflush(1);
 		print $client "220 fake esmtp server ready" . CRLF;
 
+		$proxy_protocol = '';
+
 		while (<$client>) {
 			Test::Nginx::log_core('||', $_);
 
@@ -134,6 +137,10 @@ sub smtp_test_daemon {
 				print $client '250 rcpt to ok' . CRLF;
 			} elsif (/^xclient/i) {
 				print $client '220 xclient ok' . CRLF;
+			} elsif (/^proxy/i) {
+				$proxy_protocol = $_;
+			} elsif (/^xproxy/i) {
+				print $client '211 ' . $proxy_protocol . CRLF;
 			} else {
 				print $client "500 unknown command" . CRLF;
 			}