comparison src/mail/ngx_mail_proxy_module.c @ 410:cd9cb7a3ff9e

Merge with nginx 0.7.8.
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 11 Aug 2008 22:07:06 +0400
parents 52b28d322d76 984bb0b1399b
children 375518f786db
comparison
equal deleted inserted replaced
409:52b28d322d76 410:cd9cb7a3ff9e
170 if (s->proxy->buffer == NULL) { 170 if (s->proxy->buffer == NULL) {
171 ngx_mail_proxy_internal_server_error(s); 171 ngx_mail_proxy_internal_server_error(s);
172 return; 172 return;
173 } 173 }
174 174
175 s->out.len = 0;
176
175 switch (s->protocol) { 177 switch (s->protocol) {
176 178
177 case NGX_MAIL_POP3_PROTOCOL: 179 case NGX_MAIL_POP3_PROTOCOL:
178 p->upstream.connection->read->handler = ngx_mail_proxy_pop3_handler; 180 p->upstream.connection->read->handler = ngx_mail_proxy_pop3_handler;
179 s->mail_state = ngx_pop3_start; 181 s->mail_state = ngx_pop3_start;
250 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, rev->log, 0, "mail proxy send user"); 252 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, rev->log, 0, "mail proxy send user");
251 253
252 s->connection->log->action = "sending user name to upstream"; 254 s->connection->log->action = "sending user name to upstream";
253 255
254 line.len = sizeof("USER ") - 1 + s->login.len + 2; 256 line.len = sizeof("USER ") - 1 + s->login.len + 2;
255 line.data = ngx_palloc(c->pool, line.len); 257 line.data = ngx_pnalloc(c->pool, line.len);
256 if (line.data == NULL) { 258 if (line.data == NULL) {
257 ngx_mail_proxy_internal_server_error(s); 259 ngx_mail_proxy_internal_server_error(s);
258 return; 260 return;
259 } 261 }
260 262
269 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, rev->log, 0, "mail proxy send pass"); 271 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, rev->log, 0, "mail proxy send pass");
270 272
271 s->connection->log->action = "sending password to upstream"; 273 s->connection->log->action = "sending password to upstream";
272 274
273 line.len = sizeof("PASS ") - 1 + s->passwd.len + 2; 275 line.len = sizeof("PASS ") - 1 + s->passwd.len + 2;
274 line.data = ngx_palloc(c->pool, line.len); 276 line.data = ngx_pnalloc(c->pool, line.len);
275 if (line.data == NULL) { 277 if (line.data == NULL) {
276 ngx_mail_proxy_internal_server_error(s); 278 ngx_mail_proxy_internal_server_error(s);
277 return; 279 return;
278 } 280 }
279 281
366 368
367 s->connection->log->action = "sending LOGIN command to upstream"; 369 s->connection->log->action = "sending LOGIN command to upstream";
368 370
369 line.len = s->tag.len + sizeof("LOGIN ") - 1 371 line.len = s->tag.len + sizeof("LOGIN ") - 1
370 + 1 + NGX_SIZE_T_LEN + 1 + 2; 372 + 1 + NGX_SIZE_T_LEN + 1 + 2;
371 line.data = ngx_palloc(c->pool, line.len); 373 line.data = ngx_pnalloc(c->pool, line.len);
372 if (line.data == NULL) { 374 if (line.data == NULL) {
373 ngx_mail_proxy_internal_server_error(s); 375 ngx_mail_proxy_internal_server_error(s);
374 return; 376 return;
375 } 377 }
376 378
385 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, rev->log, 0, "mail proxy send user"); 387 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, rev->log, 0, "mail proxy send user");
386 388
387 s->connection->log->action = "sending user name to upstream"; 389 s->connection->log->action = "sending user name to upstream";
388 390
389 line.len = s->login.len + 1 + 1 + NGX_SIZE_T_LEN + 1 + 2; 391 line.len = s->login.len + 1 + 1 + NGX_SIZE_T_LEN + 1 + 2;
390 line.data = ngx_palloc(c->pool, line.len); 392 line.data = ngx_pnalloc(c->pool, line.len);
391 if (line.data == NULL) { 393 if (line.data == NULL) {
392 ngx_mail_proxy_internal_server_error(s); 394 ngx_mail_proxy_internal_server_error(s);
393 return; 395 return;
394 } 396 }
395 397
405 "mail proxy send passwd"); 407 "mail proxy send passwd");
406 408
407 s->connection->log->action = "sending password to upstream"; 409 s->connection->log->action = "sending password to upstream";
408 410
409 line.len = s->passwd.len + 2; 411 line.len = s->passwd.len + 2;
410 line.data = ngx_palloc(c->pool, line.len); 412 line.data = ngx_pnalloc(c->pool, line.len);
411 if (line.data == NULL) { 413 if (line.data == NULL) {
412 ngx_mail_proxy_internal_server_error(s); 414 ngx_mail_proxy_internal_server_error(s);
413 return; 415 return;
414 } 416 }
415 417
502 s->connection->log->action = "sending HELO/EHLO to upstream"; 504 s->connection->log->action = "sending HELO/EHLO to upstream";
503 505
504 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module); 506 cscf = ngx_mail_get_module_srv_conf(s, ngx_mail_core_module);
505 507
506 line.len = sizeof("HELO ") - 1 + cscf->server_name.len + 2; 508 line.len = sizeof("HELO ") - 1 + cscf->server_name.len + 2;
507 line.data = ngx_palloc(c->pool, line.len); 509 line.data = ngx_pnalloc(c->pool, line.len);
508 if (line.data == NULL) { 510 if (line.data == NULL) {
509 ngx_mail_proxy_internal_server_error(s); 511 ngx_mail_proxy_internal_server_error(s);
510 return; 512 return;
511 } 513 }
512 514
529 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, rev->log, 0, 531 ngx_log_debug0(NGX_LOG_DEBUG_MAIL, rev->log, 0,
530 "mail proxy send xclient"); 532 "mail proxy send xclient");
531 533
532 s->connection->log->action = "sending XCLIENT to upstream"; 534 s->connection->log->action = "sending XCLIENT to upstream";
533 535
534 line.len = sizeof("XCLIENT PROTO=SMTP HELO= ADDR= LOGIN= " 536 line.len = sizeof("XCLIENT PROTO=SMTP HELO= ADDR= LOGIN= NAME="
535 "NAME=[UNAVAILABLE]" CRLF) - 1 537 CRLF) - 1
536 + s->esmtp + s->smtp_helo.len 538 + s->esmtp + s->smtp_helo.len
537 + s->connection->addr_text.len + s->login.len; 539 + s->connection->addr_text.len + s->login.len + s->host.len;
538 540
539 line.data = ngx_palloc(c->pool, line.len); 541 line.data = ngx_pnalloc(c->pool, line.len);
540 if (line.data == NULL) { 542 if (line.data == NULL) {
541 ngx_mail_proxy_internal_server_error(s); 543 ngx_mail_proxy_internal_server_error(s);
542 return; 544 return;
543 } 545 }
544 546
545 line.len = ngx_sprintf(line.data, 547 line.len = ngx_sprintf(line.data,
546 "XCLIENT PROTO=%sSMTP%s%V ADDR=%V%s%V " 548 "XCLIENT PROTO=%sSMTP%s%V ADDR=%V%s%V "
547 "NAME=[UNAVAILABLE]" CRLF, 549 "NAME=%V" CRLF,
548 (s->esmtp ? "E" : ""), 550 (s->esmtp ? "E" : ""),
549 (s->smtp_helo.len ? " HELO=" : ""), &s->smtp_helo, 551 (s->smtp_helo.len ? " HELO=" : ""), &s->smtp_helo,
550 &s->connection->addr_text, 552 &s->connection->addr_text,
551 (s->login.len ? " LOGIN=" : ""), &s->login) 553 (s->login.len ? " LOGIN=" : ""), &s->login, &s->host)
552 - line.data; 554 - line.data;
553 555
554 s->mail_state = s->auth_method == NGX_MAIL_AUTH_NONE ? 556 s->mail_state = s->auth_method == NGX_MAIL_AUTH_NONE ?
555 ngx_smtp_xclient_from : ngx_smtp_xclient; 557 ngx_smtp_xclient_from : ngx_smtp_xclient;
556 558
562 "mail proxy send mail from"); 564 "mail proxy send mail from");
563 565
564 s->connection->log->action = "sending MAIL FROM to upstream"; 566 s->connection->log->action = "sending MAIL FROM to upstream";
565 567
566 line.len = s->smtp_from.len + sizeof(CRLF) - 1; 568 line.len = s->smtp_from.len + sizeof(CRLF) - 1;
567 line.data = ngx_palloc(c->pool, line.len); 569 line.data = ngx_pnalloc(c->pool, line.len);
568 if (line.data == NULL) { 570 if (line.data == NULL) {
569 ngx_mail_proxy_internal_server_error(s); 571 ngx_mail_proxy_internal_server_error(s);
570 return; 572 return;
571 } 573 }
572 574
582 "mail proxy send rcpt to"); 584 "mail proxy send rcpt to");
583 585
584 s->connection->log->action = "sending RCPT TO to upstream"; 586 s->connection->log->action = "sending RCPT TO to upstream";
585 587
586 line.len = s->smtp_to.len + sizeof(CRLF) - 1; 588 line.len = s->smtp_to.len + sizeof(CRLF) - 1;
587 line.data = ngx_palloc(c->pool, line.len); 589 line.data = ngx_pnalloc(c->pool, line.len);
588 if (line.data == NULL) { 590 if (line.data == NULL) {
589 ngx_mail_proxy_internal_server_error(s); 591 ngx_mail_proxy_internal_server_error(s);
590 return; 592 return;
591 } 593 }
592 594