| Age | Commit message (Collapse) | Author |
|
Using port makes the IP address of DoT and DoH listen on the same
address with UDP.
If we set ListenAddress to 0.0.0.0 and TLS termination is handled
by proxy, this cause DoT and DoH will also listen on all
addresses.
|
|
With help of spdxconv tool [1], we able to bulk update all files license
and copyright format to comply with SPDX formats.
[1] https://kilabit.info/project/spdxconv/
|
|
When we want to test a function or methods that does not interact
with DNS server, there is no need to run dummy DNS server.
|
|
Previously, if we parse, create, or remove the SOA record from zone, we
assume the SOA records are valid and not touch their values.
In this changes, we set the SOA fields to default values if its not set,
to make the SOA record consistent and valid, in perspective of client.
This changes also export the default OS values for documentation and add
new method NewRDataSOA to simplify creating new SOA record.
|
|
This is to prevent the test failed due to the same port number (8053)
has already been used (another DNS server already running).
|
|
Previously all caches operation are tied to the Server type.
In order to separate the responsibilities between server and caches,
we move all caches operations to Cache type.
|
|
Using ":=" simplify the code but we lose the type. For example,
v := F()
The only way we know what the type of v is by inspecting the function
F.
Another disadvantages of using ":=" may cause extra variables
allocation where two or more variables with same type is declared
inside body of function where it could be only one.
While at it, we split the struct for test case into separate type.
|
|
Previously, we use uint16 to represent type for ResourceRecord Type or
Question type.
To make the code more strict, where parameter or return value, must be
expected as record type, we add new type to represent the RR type:
RecordType.
This changes also rename any variable name of QType or qtype to RType
or rtype because QType is misleading. The type defined the
ResourceRecord to be queried not only question.
|
|
Previously, the test.Assert and test.AssertBench functions has the
boolean parameter to print the stack trace of test in case its not equal.
Since this parameter is not mandatory and its usually always set to
"true", we remove them from function signature to simplify the call
to Assert and AssertBench.
|
|
This is for consistency for type and variable names.
|
|
The second parameter uniquely identify the source of caches.
|
|
|
|
While at it add field Records that contains unpacked ResourceRecord as
mapping between domain and ResourceRecord.
This is useful for client that need to edit the RR in MasterFile.
This changes also unexport the Messages field, to access it use the method
Messages().
|
|
|
|
Instead of as methods in Server, we detach the LoadHostDir and
LostMasterDir into functions that return list of filename and their
content.
|
|
|
|
|
|
Previously, the certificate is initialized by caller. This commit changes
the certification initialization by using path to the files.
|
|
There is nothing special with this implementation. Basically, its TCP
connection on top of TLS.
|
|
The fields in ServerOptions is refactored to have generic name.
* The IPAddress field is renamed to ListenAddress, its value is both IP
address and port.
* The Port field is removed, merged to ListenAddress.
* The DoHPort field renamed to HTTPPort.
* The DoHCertificate field is renamed to TLSCertificate.
* The DoHAllowInsecure field is renamed to TLSAllowInsecure.
All the fields now have ini tag so it can be filled by using
ini.Unmarshal().
|
|
|
|
The valid syntax to suppress linter warnings is "//nolint:<name>" with
no space between comment and "nolint" and between ":". Also, we move the
placement of nolint directive to the top of statements for multiple
nolint in the same scope.
While at it, fix and supress some linter warnings.
|
|
|
|
This commit change the ServerOptions to use single port field for UDP
and TCP.
|
|
The forwarding routines will be running only if there is at least one
valid NameServers on ServerOptions.
The request will be forwarded only if IsRD (is recursion desired) flag is
set.
|
|
Previously, we use a handler for server, like server in HTTP library, to
serve query from client based on request. The idea was to make server
more generic which allow custom cache or request handling.
This is make sense if DNS response is dynamic, but in real world it is
not. DNS record actually static, either loaded from file (hosts or zone
file) or from response by recursive server.
This commit remove the server Handler and make all request to be
handled automatically based on whether the query exist on cache or not.
|
|
There are possibility that certificate and private key file may not
exist in file system, for example in memory or fetched from other server.
This commit replace CertFile and PrivateKeyFile on ServerOptions with
direct instance of tls.Certificate.
|
|
There are two type of answer: local and non-local.
Local answer is a DNS record that is loaded from hosts file or master
zone file.
Non-local answer is a DNS record that is received from parent name
servers.
Server caches the DNS answers in two storages: map and list.
The map caches store local and non local answers, using domain name as a
key and list of answers as value,
domain-name -> [{A,IN,...},{AAAA,IN,...}]
The list caches store non-local answers, ordered by last accessed time,
it is used to prune least frequently accessed answers.
Local caches will never get pruned.
|
|
The function that generate test responses will save the response in
global variables _testResponses. This is required when we refactor
unit test later to minimize global variable.
|
|
|
|
First, server have the following method exported: ListenAndServe,
ListenAndServeDoH, ListenAndServeTCP, and ListenAndServeUDP. The last
three methods are actually called by ListenAndServe automatically, so
there is no need to export them.
Second, instance of ServerOptions is only used for bootstraping listener.
After all listener have been setting up, its not used anymore. This
commit minimize the memory usage by release the ServerOptions after
server has been started.
Third, using ListenAndServe method block the caller, unless its running
with goroutine. This change make the Start() method to be non-blocking.
Server can wait for all listeners to shutting down or error using Wait().
|
|
Most of the warnings caused by update to linter which cause global
variables declared with grouping "( ... )" and that has been suppressed,
are become false-positive again.
|
|
Using request pooling just make the implementation a little bit complex.
Implementator must know that request need to be release by using
FreeRequest to minimize memory allocation.
|
|
The previous port number, 5353, is used by another program, which make
the test run failed.
The new port number is 5300.
|
|
|
|
|
|
The kind value indicate from which connection the request is coming from.
If Kind is UDP, Sender and UDPAddr must be non nil.
If Kind is TCP, Sender must be non nil
If Kind is DoH, both Sender and UDPAddr must be nil and ResponseWriter
and ChanResponded must be non nil and initialized.
|
|
Previously, we have request pooling but it does not work well (causing
data race) when handling DoH request.
This commit reimplement them back by adding http ResponseWriter and a
channel to notify response has been written, to request fields.
|
|
|
|
Since implementation of DNS over HTTP, the request contains channel for
waiting response from DNS server. The channel message cause data race
due to request can be closed on the other side (handler of DNS request).
For temporary fix, we disable request pooling until we found the simple
way to manage DoH response.
|
|
This is to prevent flaky test on DoH where server is not ready but the
test already run in parallel.
|
|
Since we have three mode for server now (UDP, TCP, DoH), more
parameters were added to ListenAndServe. To simplify this we use server
options with struct that can be passed directly to ListenAndServer.
|
|
The implementation is based on latest draft [1].
[1] https://tools.ietf.org/html/draft-ietf-doh-dns-over-https-14
|
|
|
|
|
|
Let the client handle how to manage response.
|
|
We try to follow Go encoding package conventions, but the
BinaryUnmarshaler interface notation does not make sense in our case,
where packet is already existed in message itself.
|
|
|
|
|
|
|