connection

package
v0.0.0-...-6a341f7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2024 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package connection provides a Go library for handling connections to Windows-based systems using WinRM and SSH protocols.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CMDResult

type CMDResult struct {
	StdOut string
	StdErr string
}

CMDResult represents the result of executing a command, including stdout and stderr.

type Config

type Config struct {
	WinRM *WinRMConfig
	SSH   *SSHConfig
}

Config contains configuration details for creating a Connection object.

type Connection

type Connection struct {
	WinRM *winrm.Client
	SSH   *ssh.Client
}

Connection represents a connection object that can be used to interact with a Windows system.

func NewConnection

func NewConnection(conf *Config) (*Connection, error)

NewConnection returns a Connection object based on the provided configuration. The returned Connection object may contain either a WinRM or SSH connection.

func (*Connection) Close

func (c *Connection) Close() error

Close closes any open connection, whether it's WinRM or SSH.

func (*Connection) Run

func (c *Connection) Run(ctx context.Context, cmd string) (CMDResult, error)

Run runs a command using the configured connection and context. It returns the result of the command execution, including stdout and stderr.

type ConnectionInterface

type ConnectionInterface interface {
	Run(ctx context.Context, cmd string) (CMDResult, error)
	Close() error
}

ConnectionInterface defines the interface for a connection, specifying methods like Run and Close.

type KerberosConfig

type KerberosConfig struct {
	Realm         string
	KrbConfigFile string
}

KerberosConfig represents the configuration details for Kerberos authentication.

type SSHConfig

type SSHConfig struct {
	SSHHost                  string
	SSHPort                  int
	SSHUsername              string
	SSHPassword              string
	SSHPrivateKey            string
	SSHPrivateKeyPath        string
	SSHKnownHostsPath        string
	SSHInsecureIgnoreHostKey bool
}

SSHConfig represents the configuration details for establishing an SSH connection.

type WinRMConfig

type WinRMConfig struct {
	WinRMUsername string
	WinRMPassword string
	WinRMHost     string
	WinRMPort     int
	WinRMUseTLS   bool
	WinRMInsecure bool
	WinRMTimeout  time.Duration
	WinRMKerberos *KerberosConfig
}

WinRMConfig represents the configuration details for establishing a WinRM connection.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL