Structure related to ngx_mail in notes of Nginx

Source: Internet
Author: User
: This article mainly introduces the ngx_mail-related structure in notes of "deep understanding of Nginx". if you are interested in the PHP Tutorial, refer to it. Structure of Nginx mail-related modules

Ngx_mail_module_t

This is the abstract interface of the mail module, that is, the unique interface of the mail module pointed to by the ctx member in ngx_module_t. Each mail module implements its own ngx_mail_module_t structure.

Typedefstruct {// The general interface ngx_mail_protocol_t * protocol extracted by POP3 stmp imap; // The void * (* create_main_conf) (ngx_conf_t * cf) used to create the main-level configuration item ); // The callback function char * (* init_main_conf) (ngx_conf_t * cf, void * conf) after the main-level configuration item is parsed ); // The void * (* create_srv_conf) (ngx_conf_t * cf) struct used to create srv-level configuration items ); // process the configuration item char * (* merge_srv_conf) (ngx_conf_t * cf, void * prev, void * conf) with the same name in srv and main according to the specific module;} ngx_mail_module_t;

Ngx_protocol_s

Typedefstruct ngx_mail_protocol_s ngx_mail_protocol_t; // interface method typedefvoid (* signature) (s * s, ngx_connection_t * c) required by four POP3 smtp imap and other application-level Mail modules ); typedefvoid (* signature) (ngx_event_t * rev); typedefvoid (* ngx_mail_auth_state_pt) (ngx_event_t * rev); typedef ngx_int_t (* signature) (ngx_mail_session_t * s ); struct ngx_mail_protocol_s {// mail module name ngx_str_t name; // The four most frequently used ports in_port_t port [4] In the current mail module; // The Mail module type ngx_uint_t type; // initialize init_session after establishing a TCP connection with the client; // method for receiving and parsing client requests ngx_mail_init_protocol_pt init_protocol; // method for parsing client mail protocol ngx_mail_parse_command_pt parse_command; ngx_mail_auth_state_pt auth_state; // if no error is encountered during processing, return the response specified by internal_server_error to the client ngx_str_t internal_server_error; ngx_str_t cert_error; ngx_str_t no_cert ;};

Ngx_mail_session_t

After Nginx establishes a TCP connection with the client, the ngx_mail_init_connection function is called back to initialize the Mail Protocol. At this time, a core struct similar to ngx_http_request_t in the HTTP request will be created: ngx_mail_session_s.

Typedefstruct {uint32_t signature;/* "MAIL" * // The connection between the downstream client and Nginx ngx_connection_t * connection; // you can save the content ngx_str_t out that needs to be sent to the downstream client; // receives the ngx_buf_t * buffer request from the client; // points to a pointer array that stores the context construction body pointer void ** ctx of each mail module in the request; // void ** main_conf, a pointer array composed of the main-level configuration struct; // void ** srv_conf, a pointer array composed of the srv-level configuration struct; // Parse the host domain name ngx_resolver_ctx_t * resolver_ctx; // proxy context, used for Nginx two-way passthrough communication between the client and the mail server ngx_mail_proxy_ctx_t * proxy; // indicates the current state of ngx_uint_t mail_state when interacting with the mail server; // mail protocol type unsigned protocol: 3; // 1: indicates that the current read or write operation needs to be blocked unsigned blocked: 1; // 1: The request needs to end unsigned quit: 1; // when parsing a specific email protocol, the email frame uses unsigned quoted: 1; unsigned backslash: 1; unsigned no_sync_literal: 1; // unsigned starttls: 1; unsigned esmtp: 1; // indicates the record authentication method unsigned auth_method: 3 when interacting with the authentication server; // 1: indicates that the authentication server requests to suspend receiving the response. Nginx will continue to wait for the subsequent response from the authentication server. unsigned auth_wait: 1; // The username ngx_str_t login during verification; // The password ngx_str_t passwd during verification; // ngx_str_t Salt as the Auth-salt verification information; // The three members are only used for IMAP communication ngx_str_t tag; ngx_str_t tagged_line; ngx_str_t text; // Nginx server address ngx_str_t * addr_text; // host address ngx_str_t host; // The following four members are only used for SMTP communication ngx_str_t smtp_helo; ngx_str_t smtp_from; smtp_to; ngx_str_t cmd; // indicates that the message type ngx_uint_t command is parsed from the mail server when the mail server interacts; // stores the ngx_array_t args parameter in the mail protocol from the downstream client; // The number of times the current request attempts to access the server for verification ngx_uint_t login_attempt;/* used to parse POP3/IMAP/SMTP command */ngx_uint_t state; u_char * cmd_start; u_char * arg_start; u_char * arg_end; ngx_uint_t literal_len;} ngx_mail_session_t;

Copyright: Pain is just in your mind.

The above introduces the ngx_mail-related structure in the notes of "understanding Nginx", including some content, and hopes to help friends who are interested in PHP tutorials.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.