mole

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddressFormat = "%s:%s"
)
View Source
const (
	// IdFlagName is the name of the flag that carries the unique idenfier for a
	// mole instance.
	IdFlagName = "id"
)

Variables

This section is empty.

Functions

func Rpc

func Rpc(id, method string, params interface{}) (string, error)

Rpc calls a remote procedure on another mole instance given its id or alias.

func ShowLogs

func ShowLogs(id string, follow bool) error

ShowLogs displays all logs messages from a detached applications instance.

func ShowRpc

func ShowRpc(params interface{}) (json.RawMessage, error)

ShowRpc is a rpc callback that returns runtime information about the mole client.

Types

type AddressInput

type AddressInput struct {
	User string `mapstructure:"user" toml:"user"`
	Host string `mapstructure:"host" toml:"host"`
	Port string `mapstructure:"port" toml:"port"`
}

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 Client

type Client struct {
	Conf   *Configuration
	Tunnel *tunnel.Tunnel
	// contains filtered or unexported fields
}

Client manages the overall state of the application based on its configuration.

func New

func New(conf *Configuration) *Client

New initializes a new mole's client.

func (*Client) Running

func (c *Client) Running() (bool, error)

Running checks if an instance of mole is running on the system.

func (*Client) Runtime

func (c *Client) Runtime() (*Runtime, error)

func (*Client) Start

func (c *Client) Start() error

Start kicks off mole's client, establishing the tunnel and its channels based on the client configuration attributes.

func (*Client) Stop

func (c *Client) Stop() error

Stop shuts down a detached mole's application instance.

type Configuration

type Configuration struct {
	Id                string           `json:"id" mapstructure:"id" toml:"id"`
	TunnelType        string           `json:"tunnel-type" mapstructure:"tunnel-type" toml:"tunnel-type"`
	Verbose           bool             `json:"verbose" mapstructure:"verbose" toml:"verbose"`
	Insecure          bool             `json:"insecure" mapstructure:"insecure" toml:"insecure"`
	Detach            bool             `json:"detach" mapstructure:"detach" toml:"detach"`
	Source            AddressInputList `json:"source" mapstructure:"source" toml:"source"`
	Destination       AddressInputList `json:"destination" mapstructure:"destination" toml:"destination"`
	Server            AddressInput     `json:"server" mapstructure:"server" toml:"server"`
	Key               string           `json:"key" mapstructure:"key" toml:"key"`
	KeepAliveInterval time.Duration    `json:"keep-alive-interval" mapstructure:"keep-alive-interva" toml:"keep-alive-interval"`
	ConnectionRetries int              `json:"connection-retries" mapstructure:"connection-retries" toml:"connection-retries"`
	WaitAndRetry      time.Duration    `json:"wait-and-retry" mapstructure:"wait-and-retry" toml:"wait-and-retry"`
	SshAgent          string           `json:"ssh-agent" mapstructure:"ssh-agent" toml:"ssh-agent"`
	Timeout           time.Duration    `json:"timeout" mapstructure:"timeout" toml:"timeout"`
	SshConfig         string           `json:"ssh-config" mapstructure:"ssh-config" toml:"ssh-config"`
	Rpc               bool             `json:"rpc" mapstructure:"rpc" toml:"rpc"`
	RpcAddress        string           `json:"rpc-address" mapstructure:"rpc-address" toml:"rpc-address"`
}

func (*Configuration) Merge

func (c *Configuration) Merge(al *alias.Alias, givenFlags []string) error

Merge overwrites Configuration from the given Alias.

Certain attributes like Verbose, Insecure and Detach will be overwritten only if they are found on the givenFlags which should contain the name of all flags given by the user through UI (e.g. CLI).

func (Configuration) ParseAlias

func (c Configuration) ParseAlias(name string) *alias.Alias

ParseAlias translates a Configuration object to an Alias object.

type DetachedInstance

type DetachedInstance struct {
	// Id is the unique identifier of a detached application instance. The value
	// can be either the alias or a unique alphanumeric value.
	Id string
	// LogFile points to a file path in the file system where the application
	// log file is stored.
	LogFile string
	// PidFile points to a file path in the file system where the application
	// procces identifier is stored.
	PidFile string
}

DetachedInstance holds the location to directories and files associated with an application instance running on background.

func NewDetachedInstance

func NewDetachedInstance(id string) (*DetachedInstance, error)

NewDetachedInstance returns a new instance of DetachedInstance, making sure the application instance directory is created.

type Formatter

type Formatter interface {
	Format(format string) (string, error)
}

type InstancesRuntime

type InstancesRuntime []Runtime

func ShowInstances

func ShowInstances() (*InstancesRuntime, error)

ShowInstances returns the runtime information about all instances of mole running on the system with rpc enabled.

func (InstancesRuntime) Format

func (ir InstancesRuntime) Format(format string) (string, error)

func (InstancesRuntime) ToToml

func (ir InstancesRuntime) ToToml() (string, error)

type Runtime

type Runtime Configuration

Runtime holds runtime data about an application instance.

func ShowInstance

func ShowInstance(id string) (*Runtime, error)

ShowInstance returns the runtime information about an application instance from the given id or alias.

func (Runtime) Format

func (rt Runtime) Format(format string) (string, error)

Format parses a Runtime object into a string representation based on the given format (i.e. toml).

func (Runtime) ToToml

func (rt Runtime) ToToml() (string, error)

Jump to

Keyboard shortcuts

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