Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We are introducing a new method for initiating and authenticating requested sessions. This update consolidates the associated pipeline within a
New
function and auxiliary helpers.During the authentication process, a session may fail, prompting the client to retry the connection. There are two common scenarios:
To address this, we have implemented a new Memento pattern capable of efficiently saving and recalling session snapshots. This approach mitigates redundant operations, such as repeated GET requests to the agent device. Additionally, it replaces the old metadata package. Instead of storing small pieces that comprise a session, we now have the capability to preserve the entire session. As a result, we are removing this package. Currently, we need to save two states of a session:
To illustrate a practical use of this pattern: Imagine a client that wants to connect to a specified device. It first calls the
PublicKeyHandler
with a specified context. At this stage, there are no sessions associated with the provided context, and a new one will be created. If it fails, the same client (and consequently the same context) will call thePasswordHandler
, which also callssession.New
. Since we have already created a session in the previous authentication attempt, instead of repeating all operations, we can safely retrieve the same session again but attempt authentication with a password this time.To align with these adjustments, the register and authentication processes are now invoked outside of
NewAgentConnection
, which is now solely responsible for establishing a connection to the agent. This method has been renamed toconnectAgent
and merged withNewAgentConnectionConfiguration
. Additionally,ClientConfigurationAuthenticationPublicKey
andClientConfigurationAuthenticationPassword
have been replaced withAuthPublicKey
andAuthPassword
, respectively, for simplification purposes.The upcoming steps can utilize the Memento to reuse the session.
Additionally, a new
sshconf
struct has been introduced.sshconf
serves as a global variable responsible for managing all immutable environment variables, enabling convenient access to environment configurations. Since these variables are guaranteed to remain constant, it is deemed safe to declaresshconf
as a global variable.