config

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Dir is the path where tpot store the configuration & cache
	// Dir will be overridden by flag -D
	Dir = os.Getenv("HOME") + "/.tpot/"

	// ErrValidateConfig is an error to indicate config is invalid
	ErrValidateConfig = errors.New("config is invalid")
)
View Source
var ErrEnvNotFound = fmt.Errorf("env not found")

Functions

This section is empty.

Types

type Config

type Config struct {

	// Editor is the editor to edit configuration
	// the default editor is nano
	Editor string `json:"editor"  yaml:"editor"`

	// Proxies is list of proxy configuration
	Proxies []*Proxy `json:"proxies" yaml:"proxies"`
}

Config is a config for tpot

func NewConfig added in v0.0.2

func NewConfig(isDev bool) (*Config, error)

NewConfig load config from the file and create it if no exist

func (*Config) Add added in v0.0.2

func (c *Config) Add() (string, error)

Add adds a new proxy configuration

func (*Config) AddPlain added in v0.0.2

func (c *Config) AddPlain(configPlain string) (string, error)

AddPlain adds a new proxy configuration by plain configuration

func (*Config) Edit added in v0.0.2

func (c *Config) Edit(envName string) (string, error)

Edit edits a particular proxy with match env name

func (*Config) EditAll added in v0.0.2

func (c *Config) EditAll() (string, error)

EditAll edit all the proxy configuration

func (*Config) EditAllPlain added in v0.0.2

func (c *Config) EditAllPlain(configPlain string) (string, error)

func (*Config) EditPlain added in v0.0.2

func (c *Config) EditPlain(envName, configPlain string) (string, error)

EditPlain edit specific proxy configuration by config plain

func (*Config) FindProxy added in v0.0.2

func (c *Config) FindProxy(env string) (*Proxy, error)

FindProxy finds the proxy by environment name

func (*Config) String added in v0.0.2

func (c *Config) String() (string, error)

String return the beauty configuration maybe in the future we can colorize the result

type Forwarding added in v0.0.3

type Forwarding struct {
	Interval int               `yaml:"interval"`
	Nodes    []*ForwardingNode `yaml:"nodes"`
}

type ForwardingNode added in v0.0.3

type ForwardingNode struct {
	Host       string `yaml:"host"`
	ListenPort string `yaml:"listen_port"`
	RemotePort string `yaml:"remote_port"`
	RemoteHost string `yaml:"remote_host"`
	UserLogin  string `yaml:"user_login"`
	Status     bool   `yaml:"-"`
	Error      string `yaml:"-"`
}

func (*ForwardingNode) Address added in v0.0.3

func (b *ForwardingNode) Address() string

func (*ForwardingNode) ViewName added in v0.0.3

func (b *ForwardingNode) ViewName() string

type Item

type Item struct {
	Hostname string `json:"hostname"`
	Address  string `json:"addr"`
}

type Node

type Node struct {
	Status *ProxyStatus `json:"status"`
	Items  []Item       `json:"items"`
}

func (*Node) ListHostname added in v0.0.2

func (n *Node) ListHostname() (res []string)

ListHostname return the list of hostname

func (*Node) LookUpIPAddress added in v0.0.2

func (n *Node) LookUpIPAddress(host string) (string, bool)

LookUpIPAddress lookup the IP address by host

type Proxy

type Proxy struct {
	Address  string `yaml:"address"        json:"address"`
	UserName string `yaml:"user_name"      json:"user_name"`
	Env      string `yaml:"env"            json:"env"`
	TwoFA    bool   `yaml:"two_fa"         json:"two_fa"`

	// For using OAUTH like GMAIL, Facebook etc
	// empty means using username & password
	AuthConnector string `yaml:"auth_connector" json:"auth_connector"`

	// TSHPath is the location of TSH binary
	// by default it'll use your PATH location
	TSHPath string `yaml:"tsh_path"       json:"tsh_path"`

	// Node contains the node information from teleport server
	Node Node `yaml:"node,omitempty" json:"node"`

	Forwarding Forwarding `yaml:"forwarding"`
}

func (*Proxy) AppendNode

func (p *Proxy) AppendNode(n Node) (Node, error)

AppendNode append the n to the proxy node list

func (*Proxy) GetNode

func (p *Proxy) GetNode() (Node, error)

GetNode get the node from proxy cache

func (*Proxy) ToEditString added in v0.0.4

func (p *Proxy) ToEditString() (string, error)

ToEditString generate the string for edit

func (*Proxy) UpdateNode

func (p *Proxy) UpdateNode(n Node) error

UpdateNode update the cache node

func (*Proxy) Validate added in v0.0.2

func (p *Proxy) Validate() error

Validate validates the proxy configuration the node will be ignored

type ProxySetter

type ProxySetter struct{}

func NewProxySetterStations

func NewProxySetterStations() *ProxySetter

func (*ProxySetter) Execute

func (ps *ProxySetter) Execute(p *Proxy) error

type ProxySetterStation

type ProxySetterStation interface {
	Execute(p *Proxy) error
}

type ProxyStatus added in v0.0.2

type ProxyStatus struct {
	// LoginAs is the username logged
	LoginAs string `json:"login_as"`

	// Roles is a list of teleport role
	Roles []string `json:"roles"`

	// UserLogins is a list of user login
	UserLogins []string `json:"user_logins"`
}

ProxyStatus contains data about proxy status

type SetAddressStation

type SetAddressStation struct {
	// contains filtered or unexported fields
}

func NewSetAddressStation

func NewSetAddressStation(next ProxySetterStation) *SetAddressStation

func (*SetAddressStation) Execute

func (s *SetAddressStation) Execute(p *Proxy) error

type SetAuthModeStation added in v0.0.2

type SetAuthModeStation struct {
	// contains filtered or unexported fields
}

func NewSetAuthConnectorStation added in v0.0.2

func NewSetAuthConnectorStation(next ProxySetterStation) *SetAuthModeStation

func (*SetAuthModeStation) Execute added in v0.0.2

func (s *SetAuthModeStation) Execute(p *Proxy) error

type SetEnvStation

type SetEnvStation struct {
	// contains filtered or unexported fields
}

func NewSetEnvStation

func NewSetEnvStation(next ProxySetterStation) *SetEnvStation

func (*SetEnvStation) Execute

func (s *SetEnvStation) Execute(p *Proxy) error

type SetTwoFAStation

type SetTwoFAStation struct {
	// contains filtered or unexported fields
}

func NewSetTwoFAStation

func NewSetTwoFAStation(next ProxySetterStation) *SetTwoFAStation

func (*SetTwoFAStation) Execute

func (s *SetTwoFAStation) Execute(p *Proxy) error

type SetUserNameStation

type SetUserNameStation struct {
	// contains filtered or unexported fields
}

func NewSetUserNameStation

func NewSetUserNameStation(next ProxySetterStation) *SetUserNameStation

func (*SetUserNameStation) Execute

func (s *SetUserNameStation) Execute(p *Proxy) error

Jump to

Keyboard shortcuts

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