alias

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2020 License: MIT Imports: 9 Imported by: 2

Documentation

Overview

Package alias provides utility functions related to alias configuration file management.

The alias configuration files are stored on `$HOME/.mole` on files named after the alias name.

Index

Constants

View Source
const (
	InstancePidFile = "pid"
	InstanceLogFile = "mole.log"
	ShowTemplate    = `` /* 504-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func Add

func Add(alias *Alias) error

Add persists an tunnel alias to the disk

func Delete

func Delete(alias string) error

Delete destroys a alias configuration file.

func Dir

func Dir() (string, error)

Dir returns directory path where all alias files are stored.

func Show

func Show(aliasName string) (string, error)

Show displays the configuration parameters for the given alias name.

func ShowAll

func ShowAll() (string, error)

ShowAll displays the configuration parameters for all persisted aliases.

Types

type AddressInput

type AddressInput struct {
	User string
	Host string
	Port string
}

AddressInput holds information about a host

func (AddressInput) Address

func (ai AddressInput) Address() string

Address returns a string representation of AddressInput to be used to perform network connections.

func (*AddressInput) Set

func (ai *AddressInput) Set(value string) error

Set parses a string representation of AddressInput into its proper attributes.

func (AddressInput) String

func (ai AddressInput) String() string

String returns a string representation of a AddressInput

func (*AddressInput) Type

func (ai *AddressInput) Type() string

Type return a string representation of AddressInput.

type AddressInputList

type AddressInputList []AddressInput

AddressInputList represents a collection of AddressInput objects

func (AddressInputList) List

func (il AddressInputList) List() []string

List returns an array of the string representation of each AddressInput kept on the AddressInputList

func (*AddressInputList) Set

func (il *AddressInputList) Set(value string) error

Set adds a string representation of a AddressInput to the AddressInputList object

func (AddressInputList) String

func (il AddressInputList) String() string

String return the string representation of AddressInputList

func (*AddressInputList) Type

func (il *AddressInputList) Type() string

Type return a string representation of AddressInputList.

type Alias

type Alias struct {
	Name              string   `toml:"-"`
	TunnelType        string   `toml:"type"`
	Verbose           bool     `toml:"verbose"`
	Insecure          bool     `toml:"insecure"`
	Detach            bool     `toml:"detach"`
	Source            []string `toml:"source"`
	Destination       []string `toml:"destination"`
	Server            string   `toml:"server"`
	Key               string   `toml:"key"`
	KeepAliveInterval string   `toml:"keep-alive-interval"`
	ConnectionRetries int      `toml:"connection-retries"`
	WaitAndRetry      string   `toml:"wait-and-retry"`
	SshAgent          string   `toml:"ssh-agent"`
	Timeout           string   `toml:"timeout"`
}

Alias holds all attributes required to start a ssh port forwarding tunnel.

func Get

func Get(aliasName string) (*Alias, error)

Get returns an alias previously created

func (*Alias) Merge

func (a *Alias) Merge(tunnelFlags *TunnelFlags)

Merge overwrites certain Alias attributes based on the given TunnelFlags.

func (Alias) ParseTunnelFlags

func (a Alias) ParseTunnelFlags() (*TunnelFlags, error)

ParseTunnelFlags parses an Alias into a TunnelFlags

func (Alias) String

func (a Alias) String() string

type InstanceConfiguration

type InstanceConfiguration struct {
	Home    string
	LogFile string
	PidFile string
}

func NewInstanceConfiguration

func NewInstanceConfiguration(aliasName string) (*InstanceConfiguration, error)

type TunnelFlags

type TunnelFlags struct {
	TunnelType        string
	Verbose           bool
	Insecure          bool
	Detach            bool
	Source            AddressInputList
	Destination       AddressInputList
	Server            AddressInput
	Key               string
	KeepAliveInterval time.Duration
	ConnectionRetries int
	WaitAndRetry      time.Duration
	SshAgent          string
	Timeout           time.Duration

	// GivenFlags contains list of all flags that were given by the user.
	GivenFlags []string
}

TunnelFlags is a struct that holds all flags required to establish a ssh port forwarding tunnel.

func (TunnelFlags) FlagGiven added in v1.0.1

func (tf TunnelFlags) FlagGiven(flag string) bool

FlagGiven tells if a specific flag was given by the user through CLI.

func (TunnelFlags) ParseAlias

func (tf TunnelFlags) ParseAlias(name string) *Alias

ParseAlias translates a TunnelFlags object to an Alias object

func (TunnelFlags) String

func (tf TunnelFlags) String() string

Jump to

Keyboard shortcuts

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