The dyn folder within the internal/zones directory of the addr.tools repository is responsible for providing a dynamic DNS service. This service allows users to update the DNS records associated with a subdomain of dyn.addr.tools to point to their current IP address.
Here's a breakdown of the key functionalities provided by the code in the dyn folder:
API Handling (api.go):
It implements an HTTP handler that listens for requests to update or delete DNS records.
It parses request parameters like "secret" (a password), and "ip" (the IP address to set), whether provided in the query string, form values, or request body.
User
What does the dnscheck folder do
Assistant
There is no dnscheck folder in the provided file structure. However, there is a reference to dnscheck.tools in the README.md file:
dnscheck.tools - identifies your DNS resolvers, checks DNSSEC validation, and more
Based on this information, dnscheck.tools is a separate service provided by addr.tools. It is a tool that:
Identifies the user's DNS resolvers.
Checks DNSSEC validation.
Performs other DNS-related checks.
The source code for dnscheck.tools is not present in the provided file structure, which only shows the code for the addrd DNS server and some of the services it supports. This suggests that the code for dnscheck.tools may reside elsewhere or be part of a different project.
User
Dnscheck folder go files
Assistant
You're right to ask for the Go files in the dnscheck folder, but based on the provided file structure and the README.md, there isn't a dnscheck folder within the addr.tools repository.
The README.md mentions dnscheck.tools as a separate service, implying that its code isn't part of the addr.tools repository. The repository structure shows the following:
code
User
How does it identify DNS resolvers
Assistant
It calculates a domain name based on the SHA-224 hash of the "secret".
It uses a TtlStore to store the IP address and last-updated time associated with a domain.
It supports GET, POST, PUT, and DELETE methods for managing DNS records.
It handles "self" as an ip address to use the requester's public IP address using the "X-Real-IP" header.
It sets an expiration of 90 days on the records.
Record Generation (generator.go):
It implements a RecordGenerator that generates DNS records based on stored IP addresses.
It checks if the requested domain name is a valid subdomain of dyn.addr.tools.
It serves A and AAAA records based on stored IPv4 and IPv6 addresses respectively, or returns empty if there are no IPs.
It serves TXT records with the last updated time.
It returns a CNAME for _acme-challenge to the SelfChallengeTarget.
In summary, the dyn folder provides a dynamic DNS service where users can update the IP address associated with their subdomain of dyn.addr.tools by making HTTP requests with a secret and their IP address. The service then responds to DNS queries with the updated records.
addr.tools
├── cmd/addrd - dns server application code (Go)
├── configs - addrd, nginx, and other sample config files
├── internal - dns server library code (Go)
│ ├── config - parses the addrd config json, creates and starts the service listeners
│ ├── dns2json - a simple http handler that provides dns responses in json
│ ├── dnsutil - dns server utilities (dnssec, edns0, basic handler, etc.)
│ ├── httputil - http request utilities
│ ├── status - dns server status handler
│ ├── ttlstore - a key-value store with value expiration
│ └── zones - the specific addr.tools service handlers
├── scripts - build and other helper scripts
└── website - website content
As you can see, there's no dnscheck folder listed. The internal/zones directory holds the code for specific services like dyn, but dnscheck is not among them.
Therefore, we can conclude that the Go files for dnscheck.tools are not present in this repository.
It's possible that the dnscheck.tools service:
Is hosted in a different repository: The code for dnscheck.tools might be in a separate Git repository that is not included in the provided context.
Is a client-side tool: The functionality of dnscheck.tools might be primarily implemented using client-side JavaScript, making server-side Go files unnecessary.
Relies on external libraries: The service could utilize external Go libraries to perform DNS checks, and those libraries may be in separate repositories.
In summary, while dnscheck.tools is a service related to addr.tools, its source code is not part of this repository, and therefore, there are no Go files related to it within the given context.
Okay, since we've established that the Go source code for dnscheck.tools isn't in the provided repository, we can only infer how it might identify DNS resolvers based on common techniques and general understanding of how DNS works. Here's a breakdown of the possible approaches dnscheck.tools might use:
1. Client-Side Detection (Likely Primary Method):
WebRTC: Most likely, dnscheck.tools uses WebRTC (Web Real-Time Communication) in a browser. WebRTC needs to find a user's IP address to set up peer-to-peer connections, and to do this, it communicates with STUN servers. These servers reveal the user's public IP and, importantly, the IP of the DNS resolver that the browser uses. The browser's interaction with STUN servers are observable within the application and are used to determine the DNS resolver addresses.
JavaScript API: The core of this detection would be JavaScript code running within the user's browser. This JavaScript uses browser APIs like navigator.mediaDevices to trigger WebRTC, extract the DNS server IPs, and then send this information to the dnscheck.tools backend (which would likely be a web server).
Source IP Address: When the browser sends the DNS information via WebRTC or other mechanisms to the dnscheck.tools server, the server can see the source IP address of the client's HTTP request. It may assume that this IP is also the one used by the client's DNS resolver for making DNS requests. This is unreliable because the request might have gone through a proxy or NAT.
EDNS Client Subnet: If the client's resolver supports EDNS Client Subnet (ECS), the DNS resolver's IP is included in the request made to the dnscheck.tools DNS server. The server can then use this information to identify the resolver. However, ECS is not universally supported, and it only identifies the resolver used for queries to dnscheck.tools.
How These Methods Work Together:
The user visits dnscheck.tools in their web browser.
JavaScript code on the page uses WebRTC to obtain the client's public IP and DNS server IPs.
The JavaScript sends the extracted information to a backend server on dnscheck.tools.
The dnscheck.tools server may receive the user's source IP address, which is less reliable.
If the user also makes a DNS query to dnscheck.tools, the server can see the DNS resolver address used if the resolver uses ECS.
The dnscheck.tools backend then combines this information, with WebRTC being the most reliable source, to identify the user's DNS resolver.
Why WebRTC is the primary method:
Direct DNS Information: WebRTC reveals the actual DNS servers being used by the client.
Bypasses Proxies: Unlike IP addresses from the HTTP request, WebRTC usually bypasses proxies.
Privacy Considerations: It's generally understood that WebRTC will reveal the client's IP, so it is more expected than other methods.
In conclusion:
While we don't have the actual Go code for dnscheck.tools, we can infer that it primarily uses client-side WebRTC in a web browser to directly identify the user's DNS resolvers. The server-side might use the source IP address or EDNS client subnet as supplementary information. It's unlikely to directly identify resolvers from server-side Go code because the user's DNS queries are not always visible to the server unless the service is authoritative for the domain being resolved.