aboutsummaryrefslogtreecommitdiff
path: root/lib/dns/example_server_test.go
AgeCommit message (Collapse)Author
2021-11-13lib/dns: use snake case for file namingShulhan
Using snake case make the file naming more readable.
2021-01-20dns: replace master word with zoneShulhan
This is for consistency for type and variable names.
2020-08-25dns: add second parameter to PopulateCachesByXXXShulhan
The second parameter uniquely identify the source of caches.
2020-08-18dns: rename MasterFile to ZoneFileShulhan
2020-08-15dns: refactoring the ResourceRecord values from []byte to stringShulhan
There are two reasons for this changes. First, to allow JSON encoded of ResourceRecord.Value without encoded to base64. Second, to minimize unreleased packet due to the backing storage is still used when assigned to Value (or any []byte field in RDataXXX).
2020-08-10dns: split between MasterFile and masterParserShulhan
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().
2020-08-03dns: refactoring resource record fieldsShulhan
Previously, each record data is represented b¥ its own type, except for A, NS, CNAME, MB, MG, NULL, PTR, and TXT; represented b¥ slice of byte. This changes replace all record data with an interface{}.
2020-06-04dns: refactoring loading hosts and master filesShulhan
Instead of as methods in Server, we detach the LoadHostDir and LostMasterDir into functions that return list of filename and their content.
2020-02-13dns: check returned error from ListenAndServer in TestMainShulhan
2019-12-18dns: merge Start and Wait into ListenAndServeShulhan
2019-10-17dns: change the server certificate options to load from filesShulhan
Previously, the certificate is initialized by caller. This commit changes the certification initialization by using path to the files.
2019-10-16dns: refactoring server optionsShulhan
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().
2019-04-12dns: remove TCPPort on ServerOptionsShulhan
This commit change the ServerOptions to use single port field for UDP and TCP.
2019-04-12dns/client: add parameter to set recursion on Lookup()Shulhan
Previously, the recursion flags is on by default when we doing a Lookup. This may leak the DNS query to parent nameserver if client actually only want the local services. This commit add parameter to allow or disallow recursion when doing lookup.
2019-04-12dns: refactor server to use cachesShulhan
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.
2019-04-12dns/sender: change the Send parameter to slice of byte instead of MessageShulhan
Previously, we assume that the Message that passed to Send method is already Pack-ed. By changing the type parameter to slice of byte, we remove the assumsion (minimize confusion on how to use the method), and caller can pass the Message.Packet directly.
2019-04-12dns: use direct certificate instance on ServerOptionsShulhan
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.
2019-04-12dns: add caches for serverShulhan
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.
2019-04-12dns/server: refactor server to use Start, Wait, and StopShulhan
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().
2019-01-28lib/dns: remove request poolShulhan
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.
2019-01-28lib/dns: change the port number on testShulhan
The previous port number, 5353, is used by another program, which make the test run failed. The new port number is 5300.
2018-11-29all: fix warnings from lintersShulhan
2018-09-27lib/dns: add field Kind to requestShulhan
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.
2018-09-25lib/dns: add type server options to configure serverShulhan
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.
2018-09-25lib/dns: implement client and server for DNS over HTTPSShulhan
The implementation is based on latest draft [1]. [1] https://tools.ietf.org/html/draft-ietf-doh-dns-over-https-14
2018-09-05lib/dns: add examples for server, TCP client, and UDP clientShulhan