| Age | Commit message (Collapse) | Author |
|
=== 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".
|
|
This is to fix several flaky tests on ExampleDirWatcher [1].
[1] https://github.com/shuLhan/share/actions/runs/7765975142
[2] https://github.com/shuLhan/share/actions/runs/7672754239
|
|
The test is flaky because we use range over map of [tdata.Input].
Since range over map will return random key, there is possibility that
the first test is writing "/dir-a/dir-b/file2" not "/dir-a/dir-b/file".
|
|
When binding parameter with BindWhere, the first parameter will be joined
with the holder. For example, BindWhere("colname>=", p) will result in
"colname>=$1".
While at it, set offset based on [Meta.kind].
|
|
The GenerateWithTime and GenerateNWithTime accept parameter
[time.Time] as the relative time for generated password.
|
|
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".
|
|
This type has never been used and the implementation is not correct.
|
|
This changes add parameter kind to NewMeta, which define the kind of
DML to be mapped by Meta.
The method Add renamed to Bind, and AddWhere renamed to BindWhere.
New methods added to Meta,
- Sub return the child of Meta for building subquery,
- UpdateValues return the merged of ListValue and ListWhereValue
for DML UPDATE
- WhereFields return string that merge the ListWhereCond and ListHolder
separated by "="
|
|
The WhereHolder method generate string of holder, for example "$1,$2,...",
based on number of item added with [Meta.AddWhere].
Similar to method Holders but for where condition.
|
|
The Keys method return list of key in path.
The NKey method return the number of key in path.
The IsKeyExists return true if the key exist in Route; otherwise it
will return false.
|
|
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.
|
|
|
|
The Set method set or replace the key's value in path with parameter val.
If the key exist it will return true; otherwise it will return false.
This changes remove unnecessary field key in routeNode and optimize
the String method using [strings.Builder].
|
|
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.
|
|
The Client methods when rendered in godoc is quite long make it uneasy
to read.
|
|
This rename all variable "Ids" into "ListID".
|
|
If the tip is rebased to upstream, the author timestamp is not changes,
but the commit timestamp changes.
|
|
|
|
If the node modification time is less than requested time value in
request header If-Modified-Since, server will response with
304 Not Modified.
|
|
While at it, group the constants by its values.
|
|
|
|
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.
[1]: https://stackoverflow.com/questions/63614008/how-best-to-respond-to-an-open-http-range-request
[2]: https://bugzilla.mozilla.org/show_bug.cgi?id=570755
[3]: https://docs.aws.amazon.com/whitepapers/latest/s3-optimizing-performance-best-practices/use-byte-range-fetches.html
|
|
The Head method send the HEAD request to path, with optional
headers, and params in query parameters.
|
|
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".
|
|
Since Go 1.17, the [reflect.StructField] add method IsExported which
give clear indication that the field is exported rather than checking
not-empty PkgPath.
|
|
=== 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
|
|
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.
|
|
Instead of using [Section.Set], set the key-value directly.
While at it, merge the certificateFile, IdentityFile, knownHostFiles,
and sendEnv.
|
|
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.
|
|
Make it clear that the passed parameter is a host name and the returned
section will contains default values if no host or match found.
|
|
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.
|
|
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 vaue.
|
|
This changes require the fork of our golang.org/x/crypto.
|
|
|
|
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.
|
|
Using test.Data make the output easy to audit and modified.
|
|
|
|
|
|
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.
|
|
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.
|
|
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].
|
|
The original idea of providing Now is to mock the current time in
testing Scheduler.
Since this variable can be overridden by other packages, it is not safe
to export it, hence we un-export it here so it can be used internal only.
|
|
Both of those methods has been added into standard library as
[Time.UnixMicro] and [Time.UnixMilli] since Go 1.17.
|
|
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.
|
|
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].
|
|
The implementation of SSH server 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.
|
|
This is to make sure that the passed value is in the correct, expected
size.
|
|
|
|
|
|
While some functions are merged to lib/os, some are not used anymore
like io.Reader.
|