| Age | Commit message (Collapse) | Author |
|
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).
|
|
HTTP request now implicitly create request with context.
Any false positive related to not closing HTTP response body has been
annotated with "nolint:bodyclose".
In the example code, use consistent "// Output:" comment format, by
prefixing with single space.
Any comment on code now also prefixing with single space.
An error returned without variables now use [errors.New] instead of
[fmt.Errorf].
Any error returned using [fmt.Errorf] now wrapped using "%w" instead of
"%s".
Also, replace error checking using [errors.Is] or [errors.As], instead
of using equal/not-equal operator.
Any statement like "x = x OP y" now replaced with "x OP= y".
Also, swap statement is simplified using "x, y = y, x".
Any switch statement with single case now replaced with if-condition.
Any call to defer on function or program that call [os.Exit], now
replaced by calling the deferred function directly.
Any if-else condition now replaced with switch statement, if possible.
|
|
Instead of annotating the lines that caught by linters, fix it to comply
with the recommendations.
This causes several breaking changes, especially 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]
|
|
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
|
|
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.
|
|
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.
|
|
There are some reports that I disagree with revive, in example, code
should not declare the type after variables.
In my opinion, on some cases, declaring the type make the code more
readable and explicit.
Since I did not want to add new configuration file, we changes it and
follow revive for now.
|
|
The goal of config package is to store the configuration key and value
from ssh_config(5), everything else should be stored by user of this
package, including the valid private key file and object or parsed
identity file.
|
|
Using the maximum int64 allow the section key contains value larger than
int.
|
|
|
|
The NewSection function are required to test NewClientInteractive later.
|
|
The UserKnownHostsFile define list of the known_hosts files to be read,
separated by spaces.
If not set default to "~/.ssh/known_hosts" and "~/.ssh/known_hosts2".
|
|
An example of CASignatureAlgorithms is ssh-ed25519, so it make senses to
convert it to lowercase.
The value of Hostname is either a domain or IP address so it also make
senses to convert it to lowercase.
The value of User is not case insensitive since we can create user name
"Foo" and "foo" in the same system.
|
|
Instead of storing each Section value in separate field, store them
inside a map, Field.
This reduce the size of Section and simplify adding or getting the
key that we are not supported but maybe usable by user in the future.
This changes introduce several new methods as replacement of field:
* CASignatureAlgorithms: a method that return list of signature
algorithms that Section set or the default
* CanonicalDomains: a method that return CanonicalDomains set in Section
* CanonicalizePermittedCNames: return the permitted CNAMEs set in Section,
from KeyCanonicalizePermittedCNames.
* CertificateFile: return list of certificate file
* Environments: return system and/or custom environment that will be
passed to remote machine.
The key and value is derived from "SendEnv" and "SetEnv".
* FieldBool: return field value as boolean
* FieldInt: return the field value as int
* Hostname: return the Hostname in this Section
* IdentityAgent: return the path to SSH agent socket to be used
* Port: return the remote machine port
* User: return the remote user name
* Set: set the Field using key and value
|
|
Previously, if ssh config contains non-wildacard and wildcard pattern,
and the requested hostname only return the first section that match.
For example, given the following SSH config
foo.local
User foo
*foo.local
User allfoo
If we request Get("foo.local"), tt will return all fields under
"foo.local" only not "*foo.local".
This changes fix this by returning new section that contains all fields
from matched Section.
|
|
The section name is the string after "Host" or "Match" keyword.
By storing the section name, we can tell which host or pattern the
Section belong.
|
|
The idea is to make the Config know the working directory and home
directory of all sections that they store.
|
|
The Field store the unpacked key and value of Section.
Using the Field, we can set store unknown key while inside Section.
|
|
Instead of setting them inside the Config, move them into the method
set under Section so we can re-use them later.
This changes also move the constants for key under Host or Match into
Section file.
|
|
Changes,
* Config: changes allocated size from 32 to 16 bytes (-8 bytes)
* parser: changes allocated size from 40 to 32 bytes (-8 bytes)
* Section: changes allocated size from 392 to 360 bytes (-32 bytes)
The rest of changes that are not mentioned are from test files.
|
|
This is to make the method compatible with ssh.PublicKeysCallback.
Each parsed and unsigned IdentityFile is stored in field PrivateKeys,
replacing the Signers field (which is conflict with method names).
|
|
|
|
Since Go 1.16, the ioutil package has been deprecated.
This changes replace any usage that use functions from ioutil package
with their replacement from package os or package io.
|
|
There are four possible value for IdentityAgent: SSH_AUTH_SOCK,
<$STRING>, <PATH>, or "none".
If SSH_AUTH_SOCK, the socket path is read from the environment variable
SSH_AUTH_SOCK.
If value start with "$", then the socket path is set based on value of
that environment variable.
Other string beside "none" will be considered as path to socket.
|
|
There are two reasons for moving to sub-package. First, the code for
parsing the ssh_config(5) take almost 99% of the lines in the ssh package.
Second, in case we want to submit the code to upstream,
golang.org/x/crypto, we need the package to be independent, less external
dependencies as possible.
|