The DNSMASQ source under the Spit trough

Source: Internet
Author: User
The DNSMASQ source under the Spit trough

First of all, thank you, the author provides a simple design, rich functions, fully reduce the work of our ordinary programmers, but to understand it is not so desirable, there are mainly a few points. 1. Irrelevant design, code indentation problem.

Everywhere no longer space, occasionally a few lines of tab, really bad look ah, reading up very troublesome
2. The overall design of the feeling
The main architecture of the program is select to listen for the state of the socket to operate-"decided that it can only be used in a small network architecture" using the

struct DNSMASQ global structure, which contains a lot of linked lists to store the data packets and the response to bind, think very cleverly, however, Personally feel that such a structure is too bloated, look really uncomfortable, only slowly familiar with the code logic, understanding the design.
3. Modify its DNS processing logic
The main processing logic in Check_dns_listener, I only looked at the request of UDP, TCP request did not pay attention to understand, seemingly is fork process, separate processing. The maximum number of connections is limited. The

main functions are Receive_query, forward_query, reply_query, etc.

receive_query-mainly parsing datagrams to see if there is a cache, there are no timeouts, use the cache Answer_ Request processing encapsulates the corresponding, does not call Forward_query
Forward_query-The main thing is to send the data message to all DNS servers, from/tmp/resolve.conf.auto
reply _query-Accept the DNS server response, after receiving the lookup is which request, not found is discarded, found, based on SOA, etc.

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.