Documentation
¶
Overview ¶
Package log defines the optional diagnostic output used by shared XOps code. It does not inspect terminals or install a process-wide logger.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DiagnosticEnabled ¶ added in v0.15.0
func DiagnosticEnabled(observer DiagnosticObserver, level int) bool
DiagnosticEnabled supports an optional DiagnosticLevel() int capability. Observers without it accept all levels. Producers can avoid expensive metadata decoding when their observer has selected a lower verbosity.
func EmitDiagnostic ¶ added in v0.15.0
func EmitDiagnostic(observer DiagnosticObserver, event Diagnostic)
EmitDiagnostic does nothing when no observer is installed.
Types ¶
type DebugLogger ¶
DebugLogger implementations must be safe for concurrent calls.
var NopLogger DebugLogger = nopLogger{}
NopLogger discards diagnostic output without acquiring resources.
type Diagnostic ¶ added in v0.15.0
type Diagnostic struct {
// Level is 1..3; zero preserves the original DEBUG1 event behavior.
Level int
Kind DiagnosticKind
NodeID, Host, User string
Port int
Proxied bool
Accepted bool
ClientVersion, ServerVersion string
KeyExchange, HostKey, Fingerprint string
ReadCipher, WriteCipher, ReadMAC, WriteMAC string
Method string
Methods []string
StreamID uint64
Direction string
PacketType uint8
PacketID, PacketLength, ProtocolVersion uint32
StatusCode uint32
HasPacketID bool
HasStatus bool
HasExitCode bool
ExitCode int64
Attempt int // Privilege exchange/password attempt, 1-based; zero when not applicable.
Path, Extension, ExtensionVersion string
Truncated bool
Operation, Outcome string
// PrivilegeCommand is a payload-redacted invocation, never a user command.
// Prompts/patterns exclude response bytes and normalize random markers.
PrivilegeCommand, PrivilegePrompt, PrivilegePromptPattern string
Source, Destination string
Size int64
}
Diagnostic contains public protocol and redacted privilege metadata only. Never put credentials, private keys, file contents, or arbitrary error text in these fields. For AuthenticationAttempt, Method is the selected protocol method, not proof of success. For Authenticated, Method is the final successful method and Methods is the server-confirmed partial-success chain plus that final method. AuthenticationMethods uses Methods for the server's advertised alternatives.
type DiagnosticKind ¶ added in v0.15.0
type DiagnosticKind string
DiagnosticKind identifies an observed SSH/SFTP lifecycle transition.
const ( Connecting DiagnosticKind = "connecting" Connected DiagnosticKind = "connected" ConnectionReused DiagnosticKind = "connection_reused" HandshakeFailed DiagnosticKind = "handshake_failed" HostKeyChecked DiagnosticKind = "host_key_checked" AuthenticationMethods DiagnosticKind = "authentication_methods" AuthenticationAttempt DiagnosticKind = "authentication_attempt" Authenticated DiagnosticKind = "authenticated" Negotiated DiagnosticKind = "negotiated" SessionRequest DiagnosticKind = "session_request" SessionStarted DiagnosticKind = "session_started" SessionFinished DiagnosticKind = "session_finished" SessionCleanup DiagnosticKind = "session_cleanup" ForwardLifecycle DiagnosticKind = "forward_lifecycle" PrivilegeLifecycle DiagnosticKind = "privilege_lifecycle" SubsystemStarting DiagnosticKind = "subsystem_starting" SubsystemReady DiagnosticKind = "subsystem_ready" SubsystemFailed DiagnosticKind = "subsystem_failed" SFTPVersion DiagnosticKind = "sftp_version" SFTPExtension DiagnosticKind = "sftp_extension" SFTPOperation DiagnosticKind = "sftp_operation" SFTPPacket DiagnosticKind = "sftp_packet" SFTPMalformed DiagnosticKind = "sftp_malformed" SubsystemStderr DiagnosticKind = "subsystem_stderr" FileTransfer DiagnosticKind = "file_transfer" )
type DiagnosticObserver ¶ added in v0.15.0
type DiagnosticObserver interface{ ObserveDiagnostic(Diagnostic) }
DiagnosticObserver is optional and independent of DebugLogger. Implementations must be concurrency-safe and return promptly (for example, enqueue into a bounded buffer). They must not alter authorization or protocol behavior. The caller owns the observer and keeps it alive until its connector/clients have closed. A nil observer disables all events.