comparison src/mail/ngx_mail_auth_http_module.c @ 7794:12ea1de7d87c

Mail: parsing of the PROXY protocol from clients. Activated with the "proxy_protocol" parameter of the "listen" directive. Obtained information is passed to the auth_http script in Proxy-Protocol-Addr, Proxy-Protocol-Port, Proxy-Protocol-Server-Addr, and Proxy-Protocol-Server-Port headers.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 05 Mar 2021 17:16:24 +0300
parents 44ebeeceb70e
children 777373b5a169
comparison
equal deleted inserted replaced
7793:44ebeeceb70e 7794:12ea1de7d87c
1225 + sizeof(CRLF) - 1 1225 + sizeof(CRLF) - 1
1226 + sizeof("Client-Host: ") - 1 + s->host.len + sizeof(CRLF) - 1 1226 + sizeof("Client-Host: ") - 1 + s->host.len + sizeof(CRLF) - 1
1227 + ahcf->header.len 1227 + ahcf->header.len
1228 + sizeof(CRLF) - 1; 1228 + sizeof(CRLF) - 1;
1229 1229
1230 if (c->proxy_protocol) {
1231 len += sizeof("Proxy-Protocol-Addr: ") - 1
1232 + c->proxy_protocol->src_addr.len + sizeof(CRLF) - 1
1233 + sizeof("Proxy-Protocol-Port: ") - 1
1234 + sizeof("65535") - 1 + sizeof(CRLF) - 1
1235 + sizeof("Proxy-Protocol-Server-Addr: ") - 1
1236 + c->proxy_protocol->dst_addr.len + sizeof(CRLF) - 1
1237 + sizeof("Proxy-Protocol-Server-Port: ") - 1
1238 + sizeof("65535") - 1 + sizeof(CRLF) - 1;
1239 }
1240
1230 if (s->auth_method == NGX_MAIL_AUTH_NONE) { 1241 if (s->auth_method == NGX_MAIL_AUTH_NONE) {
1231 len += sizeof("Auth-SMTP-Helo: ") - 1 + s->smtp_helo.len 1242 len += sizeof("Auth-SMTP-Helo: ") - 1 + s->smtp_helo.len
1232 + sizeof(CRLF) - 1 1243 + sizeof(CRLF) - 1
1233 + sizeof("Auth-SMTP-From: ") - 1 + s->smtp_from.len 1244 + sizeof("Auth-SMTP-From: ") - 1 + s->smtp_from.len
1234 + sizeof(CRLF) - 1 1245 + sizeof(CRLF) - 1
1312 sizeof("Client-Host: ") - 1); 1323 sizeof("Client-Host: ") - 1);
1313 b->last = ngx_copy(b->last, s->host.data, s->host.len); 1324 b->last = ngx_copy(b->last, s->host.data, s->host.len);
1314 *b->last++ = CR; *b->last++ = LF; 1325 *b->last++ = CR; *b->last++ = LF;
1315 } 1326 }
1316 1327
1328 if (c->proxy_protocol) {
1329 b->last = ngx_cpymem(b->last, "Proxy-Protocol-Addr: ",
1330 sizeof("Proxy-Protocol-Addr: ") - 1);
1331 b->last = ngx_copy(b->last, c->proxy_protocol->src_addr.data,
1332 c->proxy_protocol->src_addr.len);
1333 *b->last++ = CR; *b->last++ = LF;
1334
1335 b->last = ngx_sprintf(b->last, "Proxy-Protocol-Port: %d" CRLF,
1336 c->proxy_protocol->src_port);
1337
1338 b->last = ngx_cpymem(b->last, "Proxy-Protocol-Server-Addr: ",
1339 sizeof("Proxy-Protocol-Server-Addr: ") - 1);
1340 b->last = ngx_copy(b->last, c->proxy_protocol->dst_addr.data,
1341 c->proxy_protocol->dst_addr.len);
1342 *b->last++ = CR; *b->last++ = LF;
1343
1344 b->last = ngx_sprintf(b->last, "Proxy-Protocol-Server-Port: %d" CRLF,
1345 c->proxy_protocol->dst_port);
1346 }
1347
1317 if (s->auth_method == NGX_MAIL_AUTH_NONE) { 1348 if (s->auth_method == NGX_MAIL_AUTH_NONE) {
1318 1349
1319 /* HELO, MAIL FROM, and RCPT TO can't contain CRLF, no need to escape */ 1350 /* HELO, MAIL FROM, and RCPT TO can't contain CRLF, no need to escape */
1320 1351
1321 b->last = ngx_cpymem(b->last, "Auth-SMTP-Helo: ", 1352 b->last = ngx_cpymem(b->last, "Auth-SMTP-Helo: ",