| Age | Commit message (Collapse) | Author |
|
|
|
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/
|
|
|
|
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
|
|
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.
|
|
|
|
|
|
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 Close method close the client sftp session and release all its
resources.
|
|
Since the method accept FileHandle, that is returned from OpenFIle,
then the method should changes with the same suffix.
This is also to make the method ambigous later when we add Close method
to close clinet connection.
|
|
The shadow tool [1] report a variable where its name is declared twice
or more, in different scope.
[1] https://pkg.go.dev/golang.org/x/tools@v0.13.0/go/analysis/passes/shadow
|
|
The realignment reduce the cost of the following struct,
* Client: from 88 to 80 bytes (-8)
* dirEntry: from 40 to 32 bytes (-8)
* FileAttrs: from 72 to 64 bytes (-8)
* packet: from 128 to 88 bytes (-40)
While at it, add missing comment to FileHandle type.
|
|
Previously, the NewClientInteractive blindly use the signers from
Section.Signers.
If one of the IdentityFile valid, it will add all the keys in
IdentityFile to SSH agent.
In this changes we try each IdentityFile independently.
If the key is valid, client connected to remote machine, then only that
key will be added to SSH agent.
While at it we also rename the method to NewClientInteractive to
indicate that the function will prompt for passphrase if one of the
IdentityFile is encrypted.
|
|
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
|
|
Current implementation exposes dirEntry.filename as fs.DirEntry.Name().
However fs.DirEntry.Info().Name() is always empty string.
Fix #2
|
|
|
|
Comment out unhandled packet types, the Extended and ExtendedReply.
|
|
The OpenFile method open remote file with custom flag and with specific
file attributes.
|
|
This changes check and return an error if
* the server does not support sftp subsystem as ErrSubsystem
* the client does not support the server version as ErrVersion
Some response status code from server actually can be mapped to
predefined errors from standar package, in this case
* io.EOF for SSH_FX_EOF (status code 1)
* fs.ErrNotExist for SSH_FX_NO_SUCH_FILE (status code 2)
* fs.ErrPermission for SSH_FX_PERMISSION_DENIED
Other errors are handled by wrapping ErrXxx variable withresponse message.
|
|
List of changes,
* Rename Node type to dirEntry and implement fs.DirEntry on it
* Change the Client Readdir, Readlink, and Realpath to return fs.DirEntry
* Make the response packet garbage collected by storing the result
in returned type and setting the response packet fields to nil
* Add field name to FileAttrs, which store the remote file name
* Implement fs.FileInfo interface in FileAttrs
* Store the remote path on FileHandle
|
|
The sftp package extend the golang.org/x/crypto/ssh package by
implementing "sftp" subsystem using the ssh.Client connection.
|