aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2019-05-07share v0.6.0v0.6.0Shulhan
This release bring major changes on dns package. Most notable changes are adding caches and query forwarding (recursion), and removing the server handler. === Breaking Changes * `dns`: ** refactor server to use Start(), Wait(), and Stop() ** use direct certificate instance on ServerOptions ** rename Send to Write, and change the parameter type to slice of byte ** remove "elapsed" parameter on Message.IsExpired() ** unexport the Request type ** remove receiver interface ** unexport connection type ** remove unused address parameter on client's Query() ** unexport all fields from UDP and TCP clients ** remove TCPPort on ServerOptions * `http`: ** change server initialization using options * `io`: ** simplify Watcher to use callback instead of channel * `memfs`: ** refactoring go generate file to use type from memfs === New Features * `crypto`: new package that provide a wrapper for standard crypto library * `dns`: ** add caches to server ** add method to set AA, Query, RD, RCode on Message ** add mapping of response code to human readable names ** implement recursion, forwarding request to parent name servers ** check for zero TTL on authorities and additionals RR on IsExpired * `io`: ** implement naive directory change notification, DirWatcher * `memfs`: ** add parameter to make reading file content become optional ** add method to unmount directory ** add method to check if memfs contains mounted directory ** add method to update node content and information ** export the method to add new child ** add method to remove child from any node * `smtp`: add field DKIMOptions to Domain === Bug Fixes * `dns`: ** fix data race issue when running test ** set the TTL offset when packing resource record ** fix parsing TXT from zone file * `http`: ** allow serving directory with slash * `memfs`: ** fix possible invalid system path on file with symbolic link ** refresh the directory tree in Development mode if page not found === Documentation * add documentation for Sender Policy Framework (RFC 7208)
2019-05-07smtp: remove unused global variable "testSMTPAddress" on test fileShulhan
2019-05-07smtp: remove unused parameter "cmd" on handleDATAShulhan
2019-05-07io: check and log error from calling NewWatcherShulhan
2019-05-07dns: suppress linter warning on struct ServerOptions could be alignedShulhan
We can move the boolean field "DoHAllowInsecure" to the bottom of struct to make the struct aligned, but it will make the fields "unstructured". We prefer the options grouped by their usage.
2019-05-07dns: change the server forwarder methods parameter type to stringShulhan
Previous runXxxForwarder methods on server, pass the remote address as TCPAddr and UDPAddr, while inside the method we convert them to string. To minimize calling String(), we change the parameter type into string.
2019-05-07dns: suppress linter warning on global variable "rcodeNames"Shulhan
2019-05-07dns: suppress linter warnings on duplicate statementsShulhan
2019-05-07io: fix data race on testing DirWatcherShulhan
2019-05-07email: changes affected by update on dns packageShulhan
2019-05-07dns: use the prefix "!" for response with error codeShulhan
Previous log format for response with error code is, dns: response error <question>, code: <error-code> The new format is dns: ! <connection-type> <error-code> <ID>:<question> This give a consistent format with the rest of request and response.
2019-05-07dns: remove duplicate log on invalid responseShulhan
The isResponseValid already log the cause of invalid, there is no need to repeat the same log at process response routine.
2019-05-07dns: restart UDP forwarder on errorShulhan
When UDP client got read timeout, the next read from the same connection may read the previous response. This will cause a mismatch between request and response for subsequence forward operations. To handle this, we close the UDP connection and start a new one.
2019-05-07dns: check for zero TTL on authorities and additionals RR on IsExpiredShulhan
Since the server accept empty answers on query response (as long as the response code is OK), the response message should be expired if one of resource record in authority or additional is zero.
2019-05-07memfs: fix possible invalid system path on file with symbolic linkShulhan
This is a quick fix, may not work, we will need to investigate it more later.
2019-04-19memfs: refresh the directory tree in Development mode if page not foundShulhan
If the program run in Development mode, any request URL that does not exist in mapped path will trigger the memfs to rescan the directory structure.
2019-04-19io: watch included files on DirWatcherShulhan
When the DirWatcher start or when new file is added to directory, start watching all regular files inside directory for modification.
2019-04-19io: simplify Watcher to use callback instead of channelShulhan
There are two other reasons for using callback: first, implementor of Watcher does not need to create its own iteration to consume the channel; second, it can be used by DirWatcher to watch modified file.
2019-04-19memfs: export the NewNode functionShulhan
The implication for exporting NewNode function is the parent parameter can be nil, and if its nil the SysPath and Path will be derived from FileInfo.Name(). The reason for exporting this function is to allow creating independent node from FileInfo.
2019-04-19io: implement naive directory change notification, DirWatcherShulhan
DirWatcher watch for new or deleted files in root directory and its sub directories using timer.
2019-04-19doc: add documentation for Sender Policy Framework (RFC 7208)Shulhan
2019-04-19memfs: add method to remove child from any nodeShulhan
The child will be removed if and only if child is part of parent node's childs; otherwise the method will return nil.
2019-04-19memfs: export the method to add new childShulhan
2019-04-19memfs: add modification time to NodeShulhan
2019-04-19memfs: change the function parameters on create new nodeShulhan
Previous new node function only initialize the node information based on file information by calling os.Stat on path parameter. The content and its type is loaded through separated methods. This change combine all process so that when calling newNode it will be ready to use, completely loaded and initialize.
2019-04-19memfs: add method to update node content and informationShulhan
The method will update node content and/or information in memory based on new file information. This method only check if the node name is equal with new file name, but it's not checking whether the node is part of memfs (node is parent or have the same root node).
2019-04-19memfs: add method to check if memfs contains mounted directoryShulhan
Method IsMounted will return true if a directory in file system has been mounted to memory; otherwise it will return false.
2019-04-19memfs: add method to unmount directoryShulhan
The method Unmount can be used to clear the memory and remount another directory into memory file system.
2019-04-19memfs: add parameter to make reading file content become optionalShulhan
Previously, when a directory is mount-ed, all the content of file will be mapped to memory as long as its size less than MaxFileSize. The new parameter "withContent" allow the file content to be mapped or not mapped to memory. If its false, the MemFS will behave as directory tree.
2019-04-17memfs: refactoring go generate file to use type from memfsShulhan
Previous Go generated file use their own Node and provide single function Get() to get the node based on path. This method does not work when using it directly with memfs. For example, on server that contains instance of memfs and want to use the output from GoGenerate, it would need to add their own wrapper for Get() and memfs.Get(). It should be more simple than that. This change add global variable GeneratedPathNode to memfs package, that will be set by file from go generate. If the GeneratedPathNode is not nil, memfs will use it as internal mapping of path and node.
2019-04-15http: allow serving directory with slashShulhan
Previously, if a directory contains "index.html" and client request the directory with slash, server will return 404. For example, "/a/index.html" accessed through "/a/" will return an error but "/a" or "/a/index.html" will return the content of "index.html". This commit fix this issue by checking if memfs.Get return an os.ErrNotExist or not. If its ErrNotExist, concat the request path with "index.html".
2019-04-15http: change server initialization using optionsShulhan
Previously, we only pass the root directory to be served and custom http Server connection when creating new server. This commit use a custom type to initialize server using ServerOptions. This model is more robust and flexible. Caller can set custom address, setting filter to include or exclude specific files in file system, and allow development mode.
2019-04-12dns: print the connection type on debug outputShulhan
2019-04-12dns: cache response with empty answer resource recordShulhan
As long as the response is OK (response code 0), we should accept response with no answer RR. One of the case is when query is AAAA and the domain does not have IPv6 address, it would response with empty answer with response code OK.
2019-04-12dns: remove unnecessary index when updating answerShulhan
2019-04-12dns: add worker for pruning old caches by thresholdShulhan
The worker prune process will run based on prune delay and it will remove any cached answer that has not been accessed less than prune threshold value.
2019-04-12dns: update accessed time when answer found on cachesShulhan
Also, remove process of moving the answer to the back of LRU when doing upsert on caches, since this is already handled by get().
2019-04-12dns: add debugging for request, forwarding, and responseShulhan
If debug.Value is set to value greater than 1, server will print each processed request, forward, and response. The debug information prefixed with single character to differentiate single action, < : incoming request from client > : the answer is sent to client ! : no answer found on cache and the query is not recursive ^ : request is forwarded to parent name server - : answer exist on cache but its expired + : new answer is added to caches # : the expired answer is renewed and updated on caches Following the prefix is message ID and question, separated by colon.
2019-04-12dns: always set is local to true when answer found on cacheShulhan
If the answer found in cache, local or non local, when processing it as response it should be pass as local; otherwise the same answer will moved to back twice.
2019-04-12CHANGELOG: update for the next releaseShulhan
2019-04-12dns: remove TCPPort on ServerOptionsShulhan
This commit change the ServerOptions to use single port field for UDP and TCP.
2019-04-12dns: unexport all fields from UDP and TCP clientsShulhan
Client should use the SetTimeout and/or SetRemoteAddr to modify the fields.
2019-04-12dns: remove address parameter on client QueryShulhan
The parameter address is not used anymore, even on UDP client. The address is default to the parsed nameserver when creating client.
2019-04-12dns: simplify server request using io.WriterShulhan
Previously, we need the UDP address of client to write back response to client on UDP connection and http ResponseWriter to write back response to client of DoH connection. This changes simplify the sender using io.Writer. On UDP connection, writer is an instance of UDPClient with connection reference to UDP server and with peer address. On TCP connection, writer is a TCP connection from accept. On Doh connection, writer is http ResponseWriter.
2019-04-12dns: unexport connection typeShulhan
Since the caches and forwarding now is handled internally, and Request has been unexported, there is no need for exporting the connection type anymore.
2019-04-12dns: remove receiver interfaceShulhan
The interface is not used anymore, client should provide only Lookup and Query to minimize API.
2019-04-12dns: unexport requestShulhan
Since the caches and forwarding now is handled internally, there is no need for exporting the request anymore.
2019-04-12dns/server: implement recursion, forwarding request to parent name serversShulhan
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.
2019-04-12dns: add mapping of response code to human readable namesShulhan
This mapping can be used to print an error message based on error code on response.
2019-04-12dns/message: remove elapsed parameter on message IsExpired()Shulhan
Since this function is called after the TTL has been subtracted, there is no need to compare them with elapsed time; we only need to check if TTL is zero or not.