aboutsummaryrefslogtreecommitdiff
path: root/_doc
AgeCommit message (Collapse)Author
2026-03-28_doc: add missing SPDX headers in changelog.cssShulhan
2026-02-09Release pakakeh.go v0.61.0 (2026-02-09)v0.61.0Shulhan
=== all 💧 all: convert license and copyright to use SPDX identifiers With the help of spdxconv tool, we able to bulk update all files license and copyright format to comply with SPDX formats. === cmd/httpdfs 🌼 cmd/httpdfs: implement systemd socket activation The httpdfs program now can be activated using systemd.socket(5). === lib/dns 🌼 lib/dns: use separate ServeMux for handling DoH Using the [http.DefaultServeMux] will cause panic when the server restarted manually using Stop-Start flow. 🌼 lib/dns: skip caching empty answer only for query type A Previously, we did not store response with empty RR answer for all record types. Meanwhile, some domains still does not have AAAA(28) and HTTPS(65) records set, but browser will requesting them. So, to minimize traffic for those query we skip caching only for query type A and cache the rest of types. 🌼 lib/dns: remove DebugLevelDNS The DebugLevelDNS log the error on DNS level, for example empty answer, error on name, class not implemented, refused; which is now on by default. 🌱 lib/dns: add option to set hook on server when receiving answer The hook function, OnAnswerReceived, will be triggered when server receive valid answer but before its put to caches. 🌱 lib/dns: add method to set TTL on Message The SetTTL method set all RRs answer time to live. 🌼 lib/dns: print the answer TTL in DebugLevelCache The log level cache changed to the following format, ... {MSG_ID QNAME TYPE TTL} ... where MSG_ID is the message ID, QNAME is the question name, TYPE is the type of question, and TTL is the time-to-live of the answer. 🌼 lib/dns: simplify log message for DebugLevelCache For each logged request, there should be one line of response logged, success or fail. This changes remove redundant log "^" (request forwarded) and "~" (answer is expired). The final log would be only "+" (new answer cached), or "#" (answer updated), or "!" (error). 🌼 lib/dns: increase the client default timeout from 6 to 60 seconds 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. This method accept second paramter "format", default to '%h,%at,%an,%ae,%s’ which print short hash, author commit timestamp, author name, author email, and subject; respectively separated by comma. === lib/git 🌱 lib/git: expose the API for IgnorePattern The IgnorePattern is not exclusive to git only. Some program, like REUSE, use the same pattern in the REUSE.toml path configuration. 🌱 lib/git: add method LogFollow The LogFollow method return history of single file path, following rename. 🌱 lib/git: add Git type with method IsIgnored The Git type is for working with single git repository. The [Git.IsIgnored] method is to check if the path is ignored by git. This is processed by matching it with all of the pattern in the ".gitignore" file from the path directory and its parent until the root of Git repository. The Git type implement Equaler interface. The Equaler interface provide the method Equal that when implemented can be used to compare two instances of struct. 🌱 lib/git: implement Gitignore Gitignore is a type that represent ".gitignore" file. There are two ways to populate Gitignore, by using [LoadGitignore] function, or by using [Gitignore.Parse] method. After the Gitignore created, one can check if a path is ignored by using [Gitignore.IsIgnored] method, relative to the Gitignore directory. === lib/http 🪵 lib/http: change HandleFS redirect status code to 301 According to MDN Redirections in HTTP the HTTP status 302 Found use case is for "Web page (that) is temporarily unavailable for unforeseen reasons.". This probably to re-route the page until the original page is fixed. While HTTP status 301 is for "Reorganization of a website.". Since the redirection in HandleFS only happen when user access directory without slash, we should make it permanent. 🌼 lib/http: set HandleFS to always end with slash "/" Previously, if request to directory does not end with "/", the HTTP server will return the index.html of that directory. This cause relative link inside the index.html broken when visited from browser. This changes make the request to directory always end with "/" by redirecting the request with status 303 Found. 🌱 lib/http: add field Listener to ServerOptions The field Listener allow user to pass [net.Listener] for accepting new connection using [http.Serve] or [http.ServeTLS]. 🪵 lib/http: add second return value, statusCode, to FSHandler Non-zero status code indicates that the function already response to the request, and the server will return immediately. Zero status code indicates that the function did not process the request, it is up to server to process the returned node out. === lib/ini 🌼 lib/ini: improve error message when parsing variable name Display the invalid character in the error message with quote, so space can detected. Also, export the error variable so external caller can detect it using the variable. === lib/os 🌱 lib/os: add function IsBinaryStream The IsBinaryStream return true if the content has more than 75% non-printable characters, excluding spaces. While at it, replace the body of IsBinary with it and update the test cases to use the internal files. === lib/systemd 🌱 lib/systemd: new package for socket-based activation The lib/systemd package implement function Listeners that return list of file descriptor as [net.Listener], that enable program to run with systemd.socket(5) based activation. === lib/test 🌼 lib/test: ignore line prefixed with "//" The first line in test data file may contains line prefixed with "//" as comment. The use case is for license and copyright lines. 🌱 lib/test: implement method ExtractInput on Data Given the path to directory destDir, create all of the [test.Data.Input] with key as its file name. If the input name contains "/", the path before the base name will be created along with its parent as long as it is under the destDir. For example, given input name "a/b/c.txt", it will create path "a/b/" inside destDir first, followed by file "c.txt" inside that path. 🌼 lib/test: export the constant for default data file name suffix Also, fix typo on the LoadDataDir regarding suffix by replacing it with the exported constant.
2026-02-08_doc: split the changelog for 2025Shulhan
While at it, use consistent title in the changelog files.
2026-02-08_doc: remove ":sectlinks:" attribute from adoc filesShulhan
The sectlinks attribute cause the sections header become hyperlinks, which is misleading since it is not link to other page or sites.
2026-02-06_doc: fix typo on RFC 4686 "Analysis of Threats Motivating DKIM"Shulhan
2026-01-15all: convert license and copyright to use SPDX identifiersShulhan
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/
2025-07-02_doc: fix broken linksShulhan
Using [jarink] we can found which links are broken. [jarink]: https://kilabit.info/project/jarink/
2025-07-02_doc: merge index.adoc into README.mdShulhan
Also, use the README as the index. This allow us to us the _doc directory to be served under https://kilabit.info/project/pakakeh.go
2025-02-01Release pakakeh.go v0.60.0 (2025-02-01)v0.60.0Shulhan
Some changes that affected almost all packages are * replacing "interface{}" with "any" (added since Go 1.18), * using for-range on numeric value (supported on Go 1.22). === lib/bytes [BREAKING CHANGES] We remove Copy and Concat functions in favor of standard library. Since Go 1.20, the standard bytes package have the Copy function. Since Go 1.22, the standard slices package have the Concat function. [BREAKING CHANGES] We also remove "lib/bytes.AppendXxx", "lib/bytes.ReadXxx", and "lib/bytes.WriteXxx" in favor of standard library. Since Go 1.19, package "encoding/binary" support appending byte order. The ReadXxx and WriteXxx can be replaced with standard library BigEndian/LittleEndian UintXxx and PutUintXxx. === lib/debug [BREAKING CHANGES] The global Value variable has been removed. Using global variable inside one package is a mistake. If, for example, package X set debug.Value to 1, another packages that does need to be debugged will print unnecessary log messages. === lib/dns [BUG FIX] We fix unpacking HTTPS where the response answers contains RR other than SVCB parameters, for example CNAME. [ENHANCEMENT] This release now detect invalid response header earlier, like invalid op code and response code, before we continue unpacking the rest data. Previously, we unpack the header and then question without detecting whether the header itself is valid or not. This cause the unpacking question return an error like label length overflow at index xxx One of the case is when someone sent random or HTTP request to DoT port. [ENHANCEMENT] In the logging part, we improve the logging prefix on serveTCPClient. The serveTCPClient is used to serve TCP and DoT clients. Previously, the error returned from this method is prefixed based on the kind, for example serveTCPClient TCP: ... serveTCPClient DoT: ... This changes pass the log prefix to the method so now it become serveTCPClient: ... serveDoTClient: ... === lib/http [ENHANCEMENT] On server with TryDirect is true, a GET request to a directory now always rescan the content and the generate the new "index.html". In the generated "index.html" we display the file time in UTC instead of local time. The ParseContentRange function now return an error instead of nil "*RangePosition". === lib/goanalysis [NEW FEATURE] Package goanalysis implement go static analysis using [Analyzer] that are not included in the default "go vet", but included in the [passes] directory, including: fieldalignment, nilness, reflectvaluecompare, shadow, sortslice, unusedwrite, and waitgroup. This package is not mean to be imported directly by other package except main, like we have in [cmd/gocheck]. === lib/hunspell This package has been renamed to "_hunspell". The hunspell is still in progress and we did not have time to continue it, so we rename it to "_hunspell" for now to prevent it being checked by linters or being imported. === lib/memfs [BUG FIX] Fix possible panic on AddChild if path is not included. === lib/play [ENHANCEMENT] One of the major issue that we previously have is the Run and Test functions can write file in any unsafe path. Another issue is default GoVersion and Timeout is set on the package level. This release introduce new type "Go" as the top level type that can be instantiate with different Root, GoVersion, and Timeout. The instance of Go then can Format, Run, or Test the Go code in their own scope. Any request to Run or Test Go code that requires writing new files now joined with the [GoOptions.Root] first. If the final absolute path does not have Root as the prefix it will return an error [os.ErrPermission]. This fix possible security issue where file may be written outside of the Root directory. === lib/test [ENHANCEMENT] Inside the Assert, we call the [T.Helper] method. The Helper method mark the Assert function as test helper, which when printing file and line information, the stack trace from Assert function will be skipped. This remove manual lines skipping that previously we have.
2025-01-06Release pakakeh.go v0.59.0 (2025-01-06)v0.59.0Shulhan
This is the first release of pakakeh.go on the year 2025. There are many new features and cleaning up, including packages that merged into single package with help of type parameters. The first major changes is indicated by using "go 1.23.4" as minimum Go version in this module, to allow us using new packages like "slices" and "maps". In this release notes, we try new format. Instead of grouping each changes by Breaking changes, New features, Bug fixes, Enhancements, and/or Chores; we group them by package. Each paragraph in the package sections will be prefixed with tag "[BREAKING CHANGE]", "[NEW FEATURE]", "[BUG FIX]", "[ENHANCEMENT]", "[CHORE]" to indicates the type of changes. === lib/binary The "lib/binary] is new package that complement the standard binary package. [NEW FEATURE] Implement append-only binary that encode the data using [binary.Writer]. We call them "Apo" for short. [NEW FEATURE] Implement buffer for reading/writing in BigEndian. The BigEndianBuffer provides backing storage for writing (most of) Go native types into binary in big-endian order. The zero value of BigEndianBuffer is an empty buffer ready to use. The following basic types are supported for Write and Read: bool, byte, int, float, complex, and string. The slice and array are also supported as long as the slice’s element type is one of basic types. === lib/bytes [BREAKING CHANGE] In the "lib/bytes" we split the hexdump related functions to separate package, "lib/hexdump". === lib/floats64 [BREAKING CHANGE] This package has been removed, merged into "slices" package. === lib/hexdump [NEW FEATURE] Package hexdump implements reading and writing bytes from and into hexadecimal number. It support parsing output from hexdump(1) tool. === lib/http [NEW FEATURE] In the [lib/http.Client] we add new method Transport that return default HTTP Transport. The returned [http.Transport] is created after the Client instantiated. Their value can be customized by user when needed, which should affect the Transport inside the Client. === lib/ints [BREAKING CHANGE] This package has been removed, merged into "slices" package. === lib/ints64 [BREAKING CHANGE] This package has been removed, merged into "slices" package. === lib/memfs [ENHANCEMENT] In the "lib/memfs" we refactoring the Watch method to use the new "watchfs/v2" package. [BREAKING CHANGE] The old Watcher and DirWatcher types now moved to watchfs package. This changes require exporting method [memfs.MemFS.UpdateContent]. === lib/numbers [CHORE] In the package level, we remove unused README and LICENSE files. This package README has been merged into the package documentation and the LICENSE is same with the module one. We also remove some package documentation that should be in "lib/slices". === lib/play [NEW FEATURE] The [lib/play] now has function and HTTP handler to run Go test code. Since the test must run inside the directory that contains the Go file to be tested, the [HTTPHandleTest] API accept the following request format, { "goversion": <string>, "file": <string>, "body": <string>, "without_race": <boolean> } The "file" field define the path to the "_test.go" file, default to "test_test.go" if its empty. The "body" field contains the Go code that will be saved to "file". The test will run, by default, with "go test -count=1 -race $dirname" where "$dirname" is the path directory to the "file" relative to where the program is running. If "without_race" is true, the test command will not run with "-race" option. [ENHANCEMENT] On package level, the home and cache directory now initialized on package init since there are never changes when program running. If Go failed to get the home and cache it will be set to system temporary directory. [ENHANCEMENT] We also simplify running Go code by removing the field pid in the struct command that wait for process ID. Instead we execute cmd with Run directly. In the Run function, we use the UnsafeRun to store temporary directory and move the statements that writes go.mod and main.go into the method writes of Request. This remove unnecessary unsafeRun function. === lib/reflect [BREAKING CHANGE] This release changes the Equal signature from "Equal(v any) bool" to "Equal(v any) error". The reason for this changes is to force the method to return an error message that is understand-able by caller. === lib/slices [NEW FEATURE] Package "lib/ints", "lib/ints64", and "lib/floats64" are merged into "slices". Now that Go has type parameter, we can use it to use the same function that accept different types for working with slice of int, int64, and float64. === lib/ssh [ENHANCEMENT] In the lib/ssh, we implement Run with context internally. Instead of depends on fork of crypto with CL that needs proposal, we implement them in here so we can update crypto module to the latest release. === lib/watchfs The watchfs package now contains the original, v1, of the Watcher and DirWatcher types from "lib/memfs". === lib/watchfs/v2 [NEW FEATURE] The "lib/watchfs/v2" is the new package that implement new file and directory watcher, that replace the Watcher and DirWatcher in the "lib/memfs". The new implementation, FileWatcher, much more simple than what we have in [memfs.Watcher]. The new directory watcher, DirWatcher, scan the content of directory in [fs.DirWatcherOptions.Root] recursively for the files to be watched, using the [fs.DirWatcherOptions.Includes] field. A single file, [fs.DirWatcherOptions.FileWatcherOptions.FilePath], will be watched for changes that trigger re-scanning the content of Root recursively. The result of re-scanning is list of the Includes files (only files not new directory) that are changes, which send to channel C. On each [os.FileInfo] received from C, a deleted file have [os.FileInfo.Size] equal to [NodeFlagDeleted]. The channel send an empty slice if no changes. The implementation of file changes in this code is naive, using loop and comparison of mode, modification time, and size; at least it should works on most operating system.
2024-08-04_doc: add partial note and summary for RFC 2183Shulhan
The RFC 2183 is define Content-Disposition header field in the internet message.
2024-04-12lib/dns: fix packing and unpacking OPT recordShulhan
The RDATA in OPT records can contains zero or _more_ options. Previously, we only handle unpacking and packing one option, now we handle multiple options.
2024-03-26_doc: add summary of RFC 9460Shulhan
The RFC 9460 is specification for DNS record 64 (Service Binding, or SVCB) and 65 (HTTPS, SVCB compliant).
2024-03-22_doc: update index to group RFC documentations by featureShulhan
2024-03-09_doc: rename the share module to "pakakeh.go"Shulhan
2024-03-02all: move the repository to "git.sr.ht/~shulhan/pakakeh.go"Shulhan
There are several reasons that why we move from github.com. First, related to the name of package. We accidentally name the package with "share" a common word in English that does not reflect the content of repository. By moving to other repository, we can rename it to better and unique name, in this "pakakeh.go". Pakakeh is Minang word for tools, and ".go" suffix indicate that the repository related to Go programming language. Second, supporting open source. The new repository is hosted under sourcehut.org, the founder is known to support open source, and all their services are licensed under AGPL, unlike GitHub that are closed sources. Third, regarding GitHub CoPilot. The GitHub Terms of Service [1], allow any public content that are hosted there granted them to parse the content. On one side, GitHub helps and flourish the open source, but on another side have an issues regarding scraping the copyleft license [2]. [1]: https://docs.github.com/en/site-policy/github-terms/github-terms-of-service#4-license-grant-to-us [2]: https://githubcopilotinvestigation.com
2024-01-06Release share v0.52.0 (2024-01-06)v0.52.0Shulhan
=== New features * ssh/config: add method MarshalText and WriteTo * lib/ssh: implement method Output on Client * ssh/sftp: implement method MkdirAll on Client * cmd/httpdfs: implement [libhttp.Server] with [memfs.MemFS] === Breaking changes * ssh/config: refactoring the Config merge * ssh/config: add parameter Config to NewSection * lib/ssh: add parameter context to Execute method * lib/time: remove UnixMicro and UnixMilli * lib/io: removed, this package has been merged into "lib/os" * lib/parser: removed, this package has been merged into lib/strings === Bug fixes * ssh/config: fix setting the default values * ssh/config: set the Hostname if its not set on [Config.Get] * http/sseclient: fix data race on [Client.Close] * http/sseclient: fix Retry value not set to millisecond * ssh/sftp: fix Stat on empty remote file name * ssh/sftp: fix non-nil returned error on Close === Enhancements * ssh/config: merge the Section slice values on [Section.merge] * ssh/config: set the default UserKnownHostsFile in setDefaults
2023-06-03lib/email: refactoring Field parsingShulhan
Split the parsing into two methods: parseName and parseValue. The error returned from those methods are prefixed by its name.
2023-05-30_doc: remove the author attribute from RFC documentsShulhan
I am not the authors of those RFCs, only make the summary to make it simple to understand and to implement.
2023-05-24_doc: prefix the simplified RFC file name with "RFC XXXX"Shulhan
The idea is to know which file belong to which RFC without opening it. Sometimes I forgot that I have read and summarize the RFC.
2023-05-18all: convert README from Asciidoc to MarkdownShulhan
I use two remote repositories: GitHub and SourceHut. GitHub support rendering README using asciidoc while SourceHut not. This cause the repository that use README.adoc rendered as text in SourceHut which make the repository page less readable. Also, the pkg.go.dev now render README but only support Markdown. Since we cannot control the SourceHut and go.dev, the only option is to support converting Markdown in ciigo so I can write README using Markdown and the rest of documentation using Asciidoc.
2023-03-12_doc: add link to CHANGELOG 2022 in indexShulhan
2023-03-12_doc: split the CHANGELOG in year 2022 to separate fileShulhan
While at it, reformat the current CHANGELOG files, add missing suffix to subsection and fix the date on v0.43.0 release.
2022-08-25_doc: cleaning up the documentationShulhan
In the _doc, we remove generated HTML files. In the index, we add link to README and section about Development that include links to repository, issues, and patches. In the README, we reformat it to use AsciiDoc markup, remove the sanitizer library, add CLI for epoch, ini, and xtrk.
2022-08-05Release share v0.40.0 (2022-08-05)v0.40.0Shulhan
=== Breaking changes * lib/memfs: set the Root SysPath to the first MemFS instance on Merge * lib/memfs: rename Option field Development to TryDirect === New features * _bin: add script to run Go benchmark * _bin: add script to run Go test and generate HTML coverage * _bin: add script go-mod-tip.sh * cmd/epoch: print the weekday in local and UTC time * cmd/epoch: add flag to parse time from RFC3339 and RFC1123 format * cmd/ini: a CLI to get and set values in the INI file format * lib/test: implement Data, a type to load formatted file for helping test === Bug fixes * lib/ini: fix parsing and saving multi line variables * lib/ini: fix marshaling pointer to nil field * lib/memfs: ignore error on Get when calling node Update === Enhancements * lib/dns: add field SOA to the ServerOptions * lib/http: add server options to generate index.html automatically * lib/ini: support escaped double-quote and colon in tag subsection * lib/ini: handle marshaling slice of time.Time
2022-07-03Release share v0.39.0 (2022-07-03)v0.39.0Shulhan
Breaking changes * all: move lib/sanitize.HTML to net/html.Sanitize New features, * lib/mlog: add method Close to MultiLogger * lib/clise: implement json.Marshaler on Clise * net/html: add function NormalizeForID * lib/http: add function to unmarshal url.Values using tag `form:` * lib/reflect: implement Set function to set reflect.Value by string * lib/reflect: add function Unmarshal * lib/reflect: add function Tag to simplify lookup on struct's field tag Enhancements, * lib/memfs: update the template format * net/html: use inline replacement to clean up white spaces * lib/mlog: minimize allocation when generating log * lib/dns: use Shutdown to stop DoH server * lib/websocket: realign all struct to minimize allocations
2022-07-03doc: split changelog files by yearShulhan
Since we release each month, the changelog growth bigger every times. In order to focus reader to latest changes, we move old changelogs to another files grouped by year.
2022-05-31Release share v0.38.0 (2022-06-05)v0.38.0Shulhan
This release update the minimum Go version to 1.17. === Breaking changes * lib/dns: move all caches operations from Server to Caches type 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. * lib/dns: change the Zone SOA field type from ResourceRecord to RDataSOA Using the RDataSOA type directly minimize interface check and conversion. === Enhancements * lib/dns: replace Ticker with Timer on Caches’ worker Since the worker call time.Now() inside the body, we can minimize it by using Timer. * lib/dns: export the Caches type and field on Server The idea is move all server’s caches operations (methods) to this type later. * lib/dns: split storage between internal and external caches Previously, the indexed caches for internal (records from hosts or zone files) and external (records from parent name servers) are stored inside single map. This changes split those internal and external caches into two maps, so any operation on one caches does not affect the other one, and vice versa. * lib/dns: return the removed record on caches RemoveCachesByRR If the record being removed found on caches, it will return it; otherwise it will return nil without error. * lib/dns: disable JSON marshaling Zone Records field On service that manage many zones, providing an API to fetch list of zones only will return large payload if we include the Records field in the response. So, it is recommended to provide another API to fetch the records on specific zone. * lib/dns: print the field Value on ResourceRecord Stringer instead of rdlen * lib/dns: export the zoneRecords type Since the Zone type is exported and its contains exported field Records with type zoneRecords, then that field type should also exported. * lib/dns: return the deleted record on HostsFile RemoveRecord Previously, the RemoveRecord method on HostsFile return a boolean true if the record found. This changes the return type to the ResourceRecord being deleted, to allow the caller inspect and/or print the record. === Chores * all: rewrite all codes to use "var" instead of ":=" 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. * lib/memfs: format comment in embedded Go template according to gofmt tip In the next gofmt (Go v1.19), the comment format does not allow empty lines "//" at the top and bottom of the comment. This changes make the generated Go code from Embed method to match as close as possible with output of gofmt.
2022-05-31all: reformat CHANGELOG to use _ instead of . for anchorShulhan
Using . for reference ID break anchor on unsupported browser.
2022-05-09Release share v0.37.0 (2022-05-09)v0.37.0Shulhan
== Breaking changes * lib/dns: refactor Server RemoveCachesByNames to return removed Answer * lib/memfs: change the Watch method to accept struct == New features * lib/dns: add method to get the record in HostsFile by name and/or value * lib/dns: add method CachesClear to remove all caches * lib/net: add method to populate query on ResolvConf * lib/dns: add function to create new client using name server URL == Bug fixes * lib/ini: fix panic when marshaling unexported field with type struct * lib/memfs: make the Node’s addChild to be idempotent == Enhancements * lib/ini: implement marshaling and unmarshaling map with struct element == Chores * all: reformat all codes using gofmt 1.19 (the Go tip) * all: replace any usage of ioutil package with os or io
2022-04-03Release share v0.36.0 (2022-04-03)v0.36.0Shulhan
== Breaking changes * lib/memfs: update the file mode and/or content on DirWatcher * lib/memfs: changes the DirWatcher and Watcher to use channel * all: move the DirWatcher and Watcher types from io to memfs == New features * lib/http: implement handler to check each request to Server Memfs * lib/memfs: add method to stop the Watch * lib/xmlrpc: add method to get boolean field value on Value * lib/memfs: add method Watch to MemFS == Enhancements * lib/http: use package mlog for logging == Bug fixes * lib/memfs: check for possible nil on Get * lib/xmlrpc: use %v to convert non-string type on GetFieldAsString == Chores * lib/memfs: differentiate prefix on MemFS’s Update and Node’s Update * email/dkim: remove amazonses.com domain from test cases * lib/memfs: move the test for NewWatcher and DirWatcher as example
2022-03-04all: add section links to the CHANGELOG documentShulhan
This is to allow us to share any section on the CHANGELOG link with meaningful URL.
2022-03-04Release share v0.35.0 (2022.03.04)v0.35.0Shulhan
6d9a750 lib/dns: increase the default UDP packet size to 1232 6299999 lib/memfs: export the Remount method 9cdda70 lib/memfs: revert remount on GoEmbed 8f0a22c lib/memfs: make the GoEmbed re-mount the Root before generate Go file de8a9f0 lib/memfs: embed the field CommentHeader on generated Go file 1c0f0a6 cmd/sendemail: command line interface to send an email f8e4959 lib/email: set the Date and Message-ID on Message Pack 3a1a271 lib/email: reorder the MIME header to write the mime-version first 2d2ea4d lib/email: make Message Pack works with single text or HTML part dc880bc lib/email: make the NewMultipart test working by mocking Epoch 835edbb lib/email: add methods to modify Message 5242d7a lib/email: store the unpacked content type into MIME 2f9ffc6 lib/email: change the Header and Body fields on Message to non-pointer 3008d44 lib/email: realign all structs 7ecd609 lib/email: set the header Date field on NewMultipart fa03d15 lib/io: fix DirWatcher not removing old files on rename d539f4d lib/smtp: refactoring NewClient to use struct instead of parameters 7743eb3 _doc: update documentation index and SASL aec0fb9 lib/smtp: add status codes from RFC 4954 c50c628 lib/smtp: rename Mechanism to SaslMechanism bda173f lib/smtp: realign all structs 511c473 lib/smtp: provide an example of how to create MailTx from email package 1ae36f8 lib/smtp: rename mail.go to mail_tx.go bd0b941 lib/mlog: make the Outf method always add new line at the end e2a220a lib/mlog: change default mlog instance to non-pointer c847880 lib/mlog: realign the struct MultiLogger a702bcf lib/memfs: add option CommentHeader to EmbedOptions a4f9a21 go.mod: update all dependencies b2dfeda lib/dns: check for possible index out of range when unpacking RR f6326ee lib/ini: realign all structs bc9beab lib/ini: make the Marshal on map field sorted by keys f7f2230 cmd/xtrk: command line interface to uncompress and/or unarchive file 39a9ce9 all: reformat CHANGELOG to make the generated HTML readable
2022-02-18_doc: update documentation index and SASLShulhan
On index, fix the text link on ESMTP_DSN get cut due to comma. On SASL, use the asciidoc numbering (using '.') instead of manual.
2022-02-08lib/dns: check for possible index out of range when unpacking RRShulhan
There is a possibility that record data (rdata) length inside the packet is greater than length of packet itself. Some of the reasons are corrupted packet from server or packet poisoning (attacking the DNS server by sending invalid packet). This changes fix this issue by checking the index and rdata length with the length of packet before consuming the rdata itself.
2022-02-06lib/ini: make the Marshal on map field sorted by keysShulhan
Given the following struct, type ADT struct { Amap map[string]string `ini:"section:sub"` } and ini text, [test "map"] c = 3 b = 2 a = 1 Unmarshal-ing the text into ADT and then Marshal-ing it again will result in unpredictable keys order. This changes fix this issue by sorting the keys on ADT.Amap on Marshal-ing, to make the written output predictable.
2022-02-06cmd/xtrk: command line interface to uncompress and/or unarchive fileShulhan
xtrk accept single file to uncompress and/or archived into a directory output dir". If directory output "dir" is not defined, it will be set to current directoy. The compression and archive format is detected automatically based on the following file input extension: * .bz2: decompress using bzip2. * .gz: decompress using gzip. * .tar: unarchive using tar. * .zip: unarchive using zip. * .tar.bz2: decompress using bzip2 and unarchive using tar. * .tar.gz: decompresss using gzip and unarchive using tar. The input file will be removed on success.
2022-02-05all: reformat CHANGELOG to make the generated HTML readableShulhan
The idea of CHANGELOG in this repository is to record changes in between version so third parties can read ("what was changes since X version") from HTML (not from adoc file). The adoc file is for written not for read.
2022-02-05Release share v0.34.0 (2022-02-05)v0.34.0Shulhan
=== Breaking changes * lib/sql: make the table migration customizable + -- In the method Migrate() we add parameter "tableMigration" which define the name of table where the state of migration will be saved. If its empty default to "_migration". -- === New features * lib/os: implement function to Extract compressed and/or archived file + -- The Extract function uncompress and/or unarchive file from fileInput into directory defined by dirOutput. This is the high level API that combine standard archive/zip, archive/tar, compress/bzip2, and/or compress/gzip. The compression and archive format is detected automatically based on the following fileInput extension: * .bz2: decompress using compress/bzip2. * .gz: decompress using compress/gzip. * .tar: unarchive using archive/tar. * .zip: unarchive using archive/zip. * .tar.bz2: decompress using compress/bzip2 and unarchive using archive/tar. * .tar.gz: decompress using compress/gzip and unarchive using archive/tar. The output directory, dirOutput, where the decompressed and/or unarchived file stored. will be created if not exist. If its empty, it will set to current directory. On success, the compressed and/or archived file will be removed from the file system. -- * lib/http: implement method Download() on Client + The Download method get a resource from remote server and write it into DownloadRequest.Output (a io.Writer). === Enhancements * lib/websocket: return error if parameter is empty on RegisterTextHandler + Previously, the RegisterTextHandler method return nil if method, target, or handler parameter is not set. This may cause confusion and hard to debug handler when no connection receive but the RegisterTextHandler does not have any error. === Chores * lib/http: change the test port for testing HTTP server + Previously, the test port for HTTP server is set to 8080 and may conflict with any service that running on the local (due to common use of 8080). + This changes it to 14832 and we make the full server address stored as global variable so any tests can references it.
2022-01-10Release share v0.33.0 (2022-01-09)v0.33.0Shulhan
Happy New Year! Three years has passed since the first release of this multi-libraries (or Go module), and we have released at least 33 new features with several bugs here and there. For anyone who use this module, I hope it help you, as the module name intended "share", and sorry if its too many breaking changes. Live long and prosper! See you again next year.
2021-02-21all: use the ciigo binary instead of library to generate docsShulhan
Previously, we use the ciigo as library to convert and server the internal documentation. This cause circular dependencies in go.mod where ciigo depends on share module and share module depends on ciigo. There is nothing wrong with that and everything seems working fine, until we need to use "replace" to test the changes on share module from ciigo module. This changes remove the use of ciigo library through internal/cmd/docs-serve and internal/cmd/docs and replace them by calling the ciigo binary directly.
2020-12-06Release share v0.21.0 (2020-12-06)v0.21.0Shulhan
=== Breaking changes * test: refactoring Assert with better error message The new Assert function use the reflect.DoEqual that return an error which describe which field have unmatched value. === New features * http: allow Endpoint to register custom error handler The new field ErrorHandler on Endpoint allow the implementor to define their own function to handler error from Endpoint.Call. If the ErrorHandler is nil it will default to DefaultErrorHandler. * totp: new package that implement TOTP protocol Package totp implement Time-Based One-Time Password Algorithm based on RFC 6238. === Bug fixes * parser: fix Line method that always return non-empty line In case of content end without new line, for example "a\nb", the Line() method always return "b, 0" on the last line. * smtp: update the expired test certificate * websocket: create buffered channel for running queue. This is to fix Stop() method waiting for running channel to be consumed. === Enhancements * big: update the latest expected error message with Go tip * http: add an example on how to write custom HTTP status code The example show how to use http.ResponseWriter.WriteHeader to write custom HTTP status code instead of relying on errors.E. * net: always return the host name or IP on ParseIPPort. Previously, if the address is an IP address the returned value is empty, for example "127.0.0.1" will return empty host but with non-nil IP and port. This changes always return the host either as host name (the same as paremeter) or valid IP address. === Chores * all: replace the tasks to serve and generate docs using ciigo as library This way, one does not need to install ciigo binary, only require Go tools.
2020-12-06all: replace the tasks to serve and generate docs using ciigo as libraryShulhan
This way, one does not need to install ciigo binary, only require Go tools.
2020-12-06README: rewrite to make it readable on pkg.go.dev and sr.htShulhan
The "Documentation" section is moved as index.adoc on _doc directory.
2020-11-09all: regenerate documentations using latest ciigoShulhan
2020-10-08_doc: update generated HTML with latest changes on ciigoShulhan
Replace the use of asciidoc table with manual layout because ciigo can not parse the table yet.
2020-09-09paseto: new package for working with pasetoShulhan
Package paseto provide the opionated implementation of Platform-Agnostic SEcurity TOkens (PASETOs) as defined in draft of RFC 01 [1]. This implementation only support PASETO Protocol v2. This library focus on how to sign and verify data, everything else is handled and filled automatically. [1] https://github.com/paragonie/paseto/blob/master/docs/RFC/draft-paragon-paseto-rfc-01.txt
2020-09-08Release share v0.19.0 (2020-09-08)v0.19.0Shulhan
=== Breaking changes * dns: unexport the Messsage's Packet field * dns: change the HostsFile Messages to list of ResourceRecord * dns: unexport the master file path field * dns: refactoring the ResourceRecord values from []byte to string 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). * dns: dns: split between MasterFile and masterParser 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. * websocket: move the server handler to ServerOptions === New features * dns: add method to remove local caches by names on Server * dns: add method to search caches * dns: add method Delete to MasterFile * dns: add method to remove RR from cache and master file * dns: add method to save the master records to file * dns: implement method to add new RR to master file * dns: add method to update/insert resource record to caches * dns: add method to initialize and validate ResourceRecord * websocket: add server options to change the connect and status paths Previously, there is only one option for server, the port where it will listen. This changes add option to change the connect path (default to "/" previously) and new path and handler for retrieving server status. === Bug fixes * dns: fix parsing SOA resource record data from master file * dns: stop all forwarders on Stop() * http: write the HTTP status code after setting content-type on error * ini: ignore the last empty line on unsetAll
2020-06-05Release share v0.16.0 (2020-06-05)v0.16.0Shulhan
=== Breaking changes * dns: refactoring loading hosts and master files Instead of as methods in Server, we detach the LoadHostDir and LostMasterDir into functions that return list of filename and their content. * dns: disable serving DoH and DoT if port is not set (0) Previously, if HTTPPort or TLSPort is not set (0) we set it to default value and keep serving the DNS over HTTP and TLS. Sometimes, user may want to serve DNS over UDP only. This changes disable serving DNS over HTTP (DoH) and TLS (DoT) if port is not set, or 0. * email: rename ParseAddress function to ParseMailboxes * http: add parameter "insecure" when creating new client * ini: fix inconsistencies between empty string and boolean true In Git specification, an empty variable is equal to boolean true. This cause inconsistency between empty string and boolean true. * memfs: simplify the API, add directory parameter to New This changes add parameter directory to be mounted in New(), so user did not need to call Mount manually This cause the Mount method and its sibling, Unmount and IsMounted become unneeded, so we remove them. === Bug fixes * api/telegram/bot: fix request parameter on GetMyCommands === New features * bytes: add function MergeSpaces The function MergeSpaces will convert sequences of white space into single space ' '. * email: add methods to unmarshal/marshal Mailbox from/to JSON * email: add function to parse single mailbox * email: add function to create multipart text and HTML message * http: support CORS with white list of origin and headers * ini: add method UnsetAll to remove all variables in section and/or subsection that match with the key * ini: add method to Unmarshal ini values to struct * os/exec: new package to simplify the standard "os/exec" New extension to standard package is function ParseCommandArgs() that receive input as string and return itas command and list of arguments. Unlike strings.Fields() which only separated the field by space, ParseCommandArgs can detect possible single, double, or back quotes. Another extension is Run() function that accept the string command to be executed and their standard output and error. * sql: add method to migrate database schema The Migrate method migrate the database using list of SQL files inside a directory. Each SQL file in directory will be executed in alphabetical order based on the last state. The state of migration will be saved in table "_migration" with the SQL file name that has been executed and the timestamp. === Enhancements * api/telegram/bot: delete webhook upon setting new webhook * dns: do not load hidden hosts and master file Previously, the LoadHostDir and LoadMasterDir load all files inside the directory without checking if its hidden (starting with dot) or not. This changes make the hidden file not loaded so one can disable it temporarily by prefixing it with dot. * ini: make the add method append the variable after existing same key * memfs: make the Node Readdir works when calling from generated Go code Previously, the Go generated code from call to GoGenerate() set only mapping of path to node. Calling Readdir() using http.File using root, err := mfs.Open("/") fis, err := root.Readdir(0) will return nil on fis. This changes add all child nodes to generated node. * websocket: allow "https" scheme on Client's Endpoint
2020-05-08all: rename directory "doc" to "_doc"Shulhan
This is to prevent the directory being processed by Go tools.