Skip to content

Latest commit

 

History

History
664 lines (504 loc) · 18.3 KB

CHANGELOG.adoc

File metadata and controls

664 lines (504 loc) · 18.3 KB

CHANGELOG

This library is released every month, usually at the first week of month.

Changelog in 2023. This is changelog for pakakeh.go module since v0.43.0 until v0.51.0.

Changelog in 2022. This is changelog for pakakeh.go module since v0.33.0 until v0.42.0.

Changelog in 2021. This is changelog for pakakeh.go module since v0.22.0 until v0.32.0.

Changelog in 2020. This is changelog for pakakeh.go module since v0.12.0 until v0.21.0.

Changelog from 2018 to 2019. This is changelog for pakakeh.go module since v0.1.0 until v0.11.0.

pakakeh.go v0.55.1 (2024-06-20)

Enhancements

lib/http: add request type HTML

The RequestTypeHTML define the content type "text/html".

lib/path: add method Path to Route

Unlike String method that may return the key’s name in returned path, the Path method return the path with all the keys has been substituted with values, even if its empty.

pakakeh.go v0.55.0 (2024-05-04)

Breaking changes

lib/http: refactoring "multipart/form-data" parameters in ClientRequest

Previously, ClientRequest with type RequestTypeMultipartForm pass the type "map[string][]byte" in Params. This type hold the file upload, where key is the file name and []byte is content of file. Unfortunately, this model does not correct because a "multipart/form-data" can contains different field name and file name, for example

--boundary
Content-Disposition: form-data; name="field0"; filename="file0"
Content-Type: application/octet-stream

<Content of file0>

This changes fix this by changing the parameter type for RequestTypeMultipartForm to [*multipart.Form], which affect several functions including [Client.PutFormData] and [GenerateFormData].

Bug fixes

lib/dns: fix packing and unpacking OPT record

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.

telegram/bot: fix Webhook URL registration

Using [path.Join] cause "https://domain" become "https:/domain" which is not a valid URL. This bug caused by refactoring in b89afa24f.

Enhancements

lib/memfs: set embed file mode to print as octal

Using octal in mode make the embedded code more readable, for example mode with permission "0o644" much more readable than 420".

telegram/bot: register GET endpoint to test webhook

The call to get "GET <Webhook.URL.Path>/<Token>" will return HTTP status 200 with JSON body '{"code":200,"message":"OK"}'.

This endpoint is to check if the bot server is really running.

lib/http: allow all HTTP method to generate HTTP request with body

Although the RFC 7231 says that no special defined meaning for a payload in GET, some implementation of HTTP API sometimes use GET with content type "application/x-www-form-urlencoded".

lib/http: add new function [CreateMultipartFileHeader]

The CreateMultipartFileHeader help creating [multipart.FileHeader] from raw bytes, that can be assigned to [*multipart.Form].

pakakeh.go v0.54.0 (2024-04-04)

This is the first release after we move the repository to SourceHut under different name: "pakakeh.go". There are several reasons for moving and naming.

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, 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 issues regarding scraping the copyleft license.

Breaking changes

Since we are moving to new repository, we fix all linter warnings and inconsistencies that we cannot changes on previous module.

Breaking changes related to naming,

  • api/slack: [Message.IconUrl] become [Message.IconURL]

  • lib/dns: DefaultSoaMinumumTtl become DefaultSoaMinimumTTL

  • lib/email: [Message.SetBodyHtml] become [Message.SetBodyHTML]

  • lib/http: [Client.GenerateHttpRequest] become [Client.GenerateHTTPRequest]

  • lib/http: [ClientOptions.ServerUrl] become [ClientOptions.ServerURL]

  • lib/http: [EndpointRequest.HttpWriter] become [EndpointRequest.HTTPWriter]

  • lib/http: [EndpointRequest.HttpRequest] become [EndpointRequest.HTTPRequest]

  • lib/http: [ServerOptions.EnableIndexHtml] become [ServerOptions.EnableIndexHTML]

  • lib/http: [SSEConn.HttpRequest] become [SSEConn.HTTPRequest]

  • lib/smtp: [ClientOptions.ServerUrl] become [ClientOptions.ServerURL]

  • lib/ssh/sftp: [FileAttrs.SetUid] become [FileAttrs.SetUID]

  • lib/ssh/sftp: [FileAttrs.Uid] become [FileAttrs.UID]

Changes on packages,

lib/sql: remove deprecated Row type

The Row type has been replaced with Meta type with more flexibility and features for generating type-safe SQL DML.

lib/memfs: remove deprecated Merge function

The Merge function has been replaced with [memfs.MemFS.Merge] for better API.

lib: move package "net/html" to "lib/html"

Putting "html" under "net" package make no sense. Another reason is to make the package flat under "lib/" directory.

lib: move package "ssh/config" to "lib/sshconfig"

Previously the "ssh/config" is used by the parent package "ssh" and "ssh/sftp" which is break the rule of package layer (the top package should be imported by sub package, not the other way around).

lib/http: refactor of RegisterEndpoint and RegisterSSE to non-pointer

Once the endpoint registered, the caller should not able to changes any values on endpoint again.

lib/http: refactoring NewServer and NewClient

The NewServer and NewClient now accept non-pointer options, so the caller unable to modify the options once the server or client has been created.

lib/http: refactor Client methods to use struct ClientRequest

Instead of three parameters, the Client methods now accept single struct [ClientRequest].

lib/http: refactoring Client methods to return struct ClientResponse

Instead of returning three variables, [http.Response], []byte, and error, we combine the [http.Response] and []byte into single struct: ClientResponse.

lib/http: refactoring type of RequestMethod from int to string

The reason is to make storing or encoding the RequestMethod value readable from user point of view instead of number, 0, 1, 2, etc.

lib/http: refactor type of RequestType from int to string

The reason is to make storing or encoding the RequestType value readable from human point of view instead of number, 0, 1, 2, etc.

lib/http: refactoring type of ResponseType from int to string

The reason is to make storing or encoding the value readable from human point of view instead of number, 0, 1, 2, etc.

lib/http: refactoring FSHandler type to return [*memfs.Node]

Changing FSHandler type to return [*memfs.Node], allow the handler to redirect or return custom node.

One of the use case is when service Single Page Application (SPA), where route is handled by JavaScript.

For example, when user requested "/dashboard" but dashboard directory does not exist, one can write the following handler to return "/index.html",

node, _ = memfs.Get(`/index.html`)
return node
lib/dns: refactor [Message.Unpack] to [UnpackMessage]

The previous API for Message is a little bit weird. Its provides creating Message manually, but expose the method [UnpackHeaderQuestion], meanwhile the field packet itself is unexported.

In order to make it more clear we refactor [Message.Unpack] to function [UnpackMessage] that accept raw DNS packet.

New features

test/httptest: new helper for testing HTTP server handler

The Simulate function simulate HTTP server handler by generating [http.Request] from fields in [SimulateRequest]; and then call [http.HandlerFunc].

The HTTP response from serve along with its raw body and original HTTP request then returned in [*SimulateResult].

lib/dns: implements RFC 9460 for SVCB RR and HTTPS RR

The dns package now support packing and unpacking DNS with record type 64 (SVCB) and 65 (HTTPS).

cmd/ansua: command line interface to help tracking time

Usage,

ansua <duration> [ "<command>" ]

ansua execute a timer on defined duration and optionally run a command when timer finished.

When ansua timer is running, one can pause the timer by pressing p+Enter, and resume it by pressing r+Enter, or stopping it using CTRL+c.

Bug fixes

lib/memfs: trim trailing slash ("/") in the path of Get method

The MemFS always store directory without slash. If caller request a directory node with slash, it will always return nil.

lib/dns: use ParseUint to parse escaped octet in "\NNN" format

Previously, we use ParseInt to parse escaped octet "\NNN", but using this method only allow decimal from 0 to 127, while the specification allow 0 to 255.

Enhancements

lib/http: handle CORS independently

Previously, if [CORSOptions.AllowOrigins] not found we return it immediately without checking request "Access-Control-Request-Method", "Access-Control-Request-Headers", and other CORS options.

This changes check each of them, a missing allow origins does not means empty allowed method, headers, MaxAge, or credentials.

lib/bytes: add parameter networkByteOrder to ParseHexDump

If networkByteOrder is true, the ParseHexDump read each hex string in network byte order or as order defined in text.

While at it, fix reading and parsing single byte hex.

cmd/httpdfs: set default include options to empty

By default httpdfs now serve all files under base directory.

pakakeh.go v0.53.1 (2024-03-02)

Enhancements

lib/sql: handle binding with the same name

If [Meta.Bind] is called with the same name again, it should replace the existing named value.

lib/dns: ignore invalid message

If Query return a message but the failed to unpack due to invalid format, for example

unpackOPT: data length is out of range

ignore it instead of disconnect the client connection.

lib/http: export function to generate "multipart/form-data"

The GenerateFormData generate the request body with boundary for HTTP content-type "multipart/form-data" from map[string][]byte.

lib/dns: change the log mechanism by mode instead of by level

This changes introduce three mode of debug:

  • DebugLevelDNS: log error on DNS level, in example empty answer, ERR_NAME (domain name is invalid or not known) and so on.

  • DebugLevelCache: log cache operations.

  • DebugLevelConnPacket: log low level connection and package, including request and response.

pakakeh.go v0.53.0 (2024-02-04)

New features

test/mock: implement mock for crypto [rand.Reader]

The RandReader implement [io.Reader]. To provide predictable result, the RandReader is seeded with slice of bytes. A call to Read will fill the passed bytes with those seed.

For example, given seed as "abc" (length is three), calling Read with bytes length five will return "abcab".

lib/sql: add new type Meta

Meta contains the DML meta data, including driver name, list of column names, list of column holders, and list of values.

The Meta type replace the Row type.

lib/path: new package to work with path

The path package provide a new type Route, detached from "lib/http".

A Route represent a parsed path. A path can have a key, or binding, that can be replaced with string value. For example, "/org/:user/:repo" have two keys "user" and "repo".

Route handle the path in case-insensitive manner.

Bug fixes

_bin/go-mod-tip: use committer timestamp instead of author timestamp

If the tip is rebased to upstream, the author timestamp is not changes, but the commit timestamp changes.

Enhancements

lib/totp: add method GenerateWithTime and GenerateNWithTime

The GenerateWithTime and GenerateNWithTime accept parameter [time.Time] as the relative time for generated password.

lib/http: add support for If-Modified-Since in HandleFS

If the node modification time is less than requested time value in request header If-Modified-Since, server will response with 304 Not Modified.

lib/http: refactoring Range request, limit content served by server

When server receive,

GET /big
Range: bytes=0-

and the requested resources is quite larger, where writing all content of file result in i/o timeout, it is best practice [1][2] if the server write only partial content and let the client continue with the subsequent Range request.

In the above case, the server should response with,

HTTP/1.1 206 Partial content
Content-Range: bytes 0-<limit>/<size>
Content-Length: <limit>

Where limit is maximum packet that is reasonable [3] for most of the client. In this server we choose 8MB as limit.

lib/http: add method Head to Client

The Head method send the HEAD request to path, with optional headers, and params in query parameters.

lib/ini: add method Keys

The Keys method return sorted list of all section, subsection, and variables as string where each of them separated by ":", for example "section:sub:var".

pakakeh.go v0.52.0 (2024-01-06)

New features

ssh/config: add method MarshalText and WriteTo

The MarshalText method encode the Section back to ssh_config format with two spaces as indentation in key.

The WriteTo method marshal the Section into text and write it to [io.Writer] w.

lib/ssh: implement method Output on Client

The Output method run the command and return its standard output and error as is. Any other error beside standard error, like connection, will be returned as error.

ssh/sftp: implement method MkdirAll on Client

The MkdirAll create directory on the server, from left to right. Each directory is separated by '/', where the left part is the parent of the right part. This method is similar to [os.MkdirAll].

cmd/httpdfs: implement [libhttp.Server] with [memfs.MemFS]

The httpdfs is a program to serve a directory under HTTP.

Breaking changes

ssh/config: refactoring the Config merge

This changes rename method [Config.Prepend] to [Config.Merge].

The way that how the other Config merged is changed. Instead of appending all of other’s sections into the current Config, append the other Config instance to the current instance of Config.

During [Config.Get] the top Config will be evaluated first, and then the other Config is evaluated in order of Merge.

ssh/config: add parameter Config to NewSection

This changes how the Section and parser initialized.

Previously, the Config depends on the parser to set the workDir and homeDir and Section depends on Config only on Get; now its the other way around, from top to bottom. Config initialized first, then parser initialized using Config instance, and then Section initialized also using Config instance.

lib/ssh: add parameter context to Execute method

This changes require the fork of our golang.org/x/crypto.

lib/time: remove UnixMicro and UnixMilli

Both of those methods has been added into standard library as [Time.UnixMicro] and [Time.UnixMilli] since Go 1.17.

lib/io: removed, this package has been merged into "lib/os"

While some functions are merged to "lib/os", some are not used anymore like io.Reader.

lib/parser: removed, this package has been merged into lib/strings

=== Bug fixes

ssh/config: fix setting the default values

The field default value should be set on Get, after all the Host or Match fields merged. In this way, if the field key already set, its not overridden by the default value or subsequent Host or Match value.

ssh/config: set the Hostname if its not set on [Config.Get]

Per manual ssh_config(5) on Hostname,

The default is the name given on the command line.

So, if the requested host name match with one of Host or Match, but Hostname is not set, it should be default to the requested parameter name.

http/sseclient: fix data race on [Client.Close]

The data race happened when Close set conn to nil but the consume method still on Read. The fix is by waiting for 100ms so consume goroutine can check if closeq is triggered from Close or not.

http/sseclient: fix Retry value not set to millisecond

When client receive "retry:" message, the value is in millisecond, but when we store it we only convert it to [time.Duration] which default to nanosecond.

While at it, update comments on field [Client.Retry] and [Client.Insecure].

ssh/sftp: fix Stat on empty remote file name

The implementation of SSH server (openssh) for Stat is not consistent with the RFC. The RFC mentioned that

An empty path name is valid, and it refers to the user’s default directory (usually the user’s home directory).

But this only working on some command, like Mkdir, but not Stat.

ssh/sftp: fix non-nil returned error on Close

This changes fix the Close that always return an error.

Enhancements

ssh/config: merge the Section slice values on [Section.merge]

Instead of using [Section.Set], set the key-value directly.

While at it, merge the certificateFile, IdentityFile, knownHostFiles, and sendEnv.

ssh/config: set the default UserKnownHostsFile in setDefaults

While at it, unfold each value of IdentityFile and UserKnownHostsFile in setDefaults, by expanding "~" into user’s home directory or joining with "config" directory if its relative.