| Age | Commit message (Collapse) | Author |
|
Using the [http.DefaultServeMux] will cause panic when the server
restarted automatically.
|
|
This is to minimize lookup on map each time we need the string
representation.
|
|
The 6 seconds timeout will works only on fast, stable connection.
On some environment with bad network connection, it will cause I/O timeout
during recv and this affect the whole internet connections, like
browsing.
Since the browser wait for domain to be resolved but it does
not get the response, it send another query.
The next query also got timeout again.
Increasing to 10-30 seconds also does not help on that environment.
After some tests, 60 seconds is the lower timeout limit that reduce
the I/O timeout.
It is better that we receive the response and store it to caches, so
the next query can be handled quickly, rather than timeout and retrying
with the same error.
|
|
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/
|
|
|
|
HTTP request now implicitly create request with context.
Any false positive related to not closing HTTP response body has been
annotated with "nolint:bodyclose".
In the example code, use consistent "// Output:" comment format, by
prefixing with single space.
Any comment on code now also prefixing with single space.
An error returned without variables now use [errors.New] instead of
[fmt.Errorf].
Any error returned using [fmt.Errorf] now wrapped using "%w" instead of
"%s".
Also, replace error checking using [errors.Is] or [errors.As], instead
of using equal/not-equal operator.
Any statement like "x = x OP y" now replaced with "x OP= y".
Also, swap statement is simplified using "x, y = y, x".
Any switch statement with single case now replaced with if-condition.
Any call to defer on function or program that call [os.Exit], now
replaced by calling the deferred function directly.
Any if-else condition now replaced with switch statement, if possible.
|
|
There are some reports that I disagree with revive, in example, code
should not declare the type after variables.
In my opinion, on some cases, declaring the type make the code more
readable and explicit.
Since I did not want to add new configuration file, we changes it and
follow revive for now.
|
|
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.
|
|
|
|
The value is based on recommendation by https://dnsflagday.net/2020/
to prevent IP fragmentation when supporting EDNS message.
|
|
This changes rename the SectionHeader into MessageHeader.
The pack() method is optimized with the following results,
benchmark old ns/op new ns/op delta
BenchmarkMessageHeader_pack-8 66.2 21.7 -67.31%
benchmark old allocs new allocs delta
BenchmarkMessageHeader_pack-8 3 1 -66.67%
benchmark old bytes new bytes delta
BenchmarkMessageHeader_pack-8 32 16 -50.00%
The unpack() method is simplified by minimizing the if-condition.
This changes also fix the pack and unpack OpCode for value other then 0,
due to wrong shift value, 2 instead of 3.
|
|
Previously, the record class is represented by uint16 using prefix
QueryClassXxx.
This changes make the record class to be an independent type, to make
code more strict (prevent passing invalid value), and readable.
|
|
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, all packet size for reading and sending the message is
fixed to 4096, even on UDP.
This changes set the UDP packet size maximum to 512 bytes and others to
4096 bytes.
While at it, minimize copying packet if its not reusable inside a method.
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
Since the caches and forwarding now is handled internally, and Request
has been unexported, there is no need for exporting the connection type
anymore.
|
|
This mapping can be used to print an error message based on error code
on response.
|
|
This will make the dns.go only contains global variables and constants.
|
|
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.
|
|
This mapping can be used to print connection type for logging.
|
|
Previously, the question type is printed using the decimal value, for
example 1 for question type address (A).
This commit add the mapping between query types and their string
representation and use it for printing query type.
|
|
|
|
|
|
This is to limit implementation to assign value of connection type to
known values only.
|
|
|
|
|
|
|
|
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
|
|
|
|
Master files are text files that contain RRs in text form. Since the
contents of a zone can be expressed in the form of a list of RRs a
master file is most often used to define a zone, though it can be used
to list a cache's contents.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This will allow to detect unknown query type for further development.
|
|
|
|
|
|
|