config

package
v0.0.0-...-a4160af Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetHostname

func GetHostname(env *Env) string

GetHostname returns the hostname of the machine the bastion is running on

func GetOutboundIP

func GetOutboundIP(env *Env) net.IP

GetOutboundIP get's the outbound internal ip https://stackoverflow.com/questions/23558425/how-do-i-get-the-local-ip-address-in-go

func NewAsciicastReadCloser

func NewAsciicastReadCloser(r io.ReadCloser, conn ssh.ConnMetadata, width int, height int, chanInfo *ConnChan, env *Env) io.ReadCloser

NewAsciicastReadCloser initializes an AsciiCast ReaderCloser for SSH logging

func Save

func Save(env *Env)

Save saves current Env data into the database and configs

Types

type AsciicastReadCloser

type AsciicastReadCloser struct {
	io.ReadCloser

	Name        string
	FileName    string
	SSHConn     ssh.ConnMetadata
	Cast        *asciicast.Cast
	Time        time.Time
	Buffer      bytes.Buffer
	Env         *Env
	BkWriter    io.WriteCloser
	BkContext   context.Context
	GZWriter    *gzip.Writer
	User        *User
	Host        string
	Hostname    string
	SidKey      string
	CurrentUser string
	Mutex       *sync.Mutex
	Users       string
	ChanInfo    *ConnChan
}

AsciicastReadCloser is the main Asciicast ReadCloser

func (*AsciicastReadCloser) Close

func (lr *AsciicastReadCloser) Close() error

Close closes the ReadCloser and uploads it to Google Cloud Storage

func (*AsciicastReadCloser) Read

func (lr *AsciicastReadCloser) Read(p []byte) (n int, err error)

type AuthRules

type AuthRules struct {
	gorm.Model
	Name            string `gorm:"type:varchar(255);"`
	AuthorizedHosts string `gorm:"type:MEDIUMTEXT;"`
	UnixUser        string `gorm:"type:varchar(255);"`
}

AuthRules is the model for different authorization rules (regex)

type ColorLog

type ColorLog struct {
	Color *color.Color
}

ColorLog is a wrapper around a certain color for logging

func NewColorLog

func NewColorLog(color *color.Color) *ColorLog

NewColorLog creates a new color for formatted logging

func (*ColorLog) Fatal

func (c *ColorLog) Fatal(a ...interface{})

Fatal is a passthru with colors

func (*ColorLog) Printf

func (c *ColorLog) Printf(format string, a ...interface{})

Printf is a passthru with colors

func (*ColorLog) Println

func (c *ColorLog) Println(a ...interface{})

Println is a passthru with colors

type Config

type Config struct {
	gorm.Model
	Expires          string `gorm:"default:'48h'"`
	PrivateKey       []byte `gorm:"type:varbinary(4096);"`
	UserPrivateKey   []byte `gorm:"type:varbinary(4096);"`
	ServerPrivateKey []byte `gorm:"type:varbinary(4096);"`
	DefaultHosts     string `gorm:"type:MEDIUMTEXT;"`
}

Config is the main config structure and DB Model

type ConnChan

type ConnChan struct {
	ChannelType string
	ChannelData []byte
	Reqs        []*ConnReq
	ClientConn  *ssh.ServerConn
	ProxyConn   ssh.Conn
	ProxyChan   *ssh.Channel
	ClientChan  *ssh.Channel
	Closer      *AsciicastReadCloser
	DBID        uint
}

ConnChan handles logged data from an SSH Channel

type ConnReq

type ConnReq struct {
	ReqType  string
	ReqData  []byte
	ReqReply bool
}

ConnReq handles logged data from an SSH Request

type Env

type Env struct {
	ForceGeneration  bool
	PKPassphrase     string
	SSHServerClients *sync.Map
	SSHProxyClients  *sync.Map
	WebsocketClients *sync.Map
	DB               *gorm.DB
	Config           *Config
	LogsBucket       *storage.BucketHandle
	Vconfig          *viper.Viper
	Red              *ColorLog
	Green            *ColorLog
	Yellow           *ColorLog
	Blue             *ColorLog
	Magenta          *ColorLog
	SSHPort          string
	SSHProxyPort     string
	HTTPPort         string
	MonPort          string
}

Env is our main context. A pointer of this is passed almost everywhere

func Load

func Load(forceCerts bool, webAddr string, sshAddr string, sshProxyAddr string, monAddr string) *Env

Load initializes the Env pointer with data from the database and elsewhere

type LiveSession

type LiveSession struct {
	gorm.Model
	Name            string `gorm:"type:MEDIUMTEXT;"`
	WS              string `gorm:"type:MEDIUMTEXT;"`
	Time            time.Time
	UserID          uint
	User            *User
	Host            string `gorm:"type:MEDIUMTEXT;"`
	Hostname        string `gorm:"type:MEDIUMTEXT;"`
	Command         string `gorm:"type:MEDIUMTEXT;"`
	Bastion         string `gorm:"type:MEDIUMTEXT;"`
	BastionHostname string `gorm:"type:MEDIUMTEXT;"`
	AuthCode        string `gorm:"type:MEDIUMTEXT;"`
}

LiveSession is the model for a specific live SSH session

type SSHProxyClient

type SSHProxyClient struct {
	Client           net.Conn
	SSHConn          ssh.Conn
	SSHClient        *ssh.Client
	SSHClientChans   <-chan ssh.NewChannel
	SSHClientReqs    <-chan *ssh.Request
	SSHServerClient  *SSHServerClient
	SSHShellSessions []*ConnChan
	SSHChans         []*ConnChan
	Mutex            *sync.Mutex
}

SSHProxyClient is a struct containing the proxy (server's) SSH connection

type SSHServerClient

type SSHServerClient struct {
	Client          *ssh.ServerConn
	RawProxyConn    net.Conn
	ProxyTo         string
	ProxyToHostname string
	Username        string
	Password        string
	PublicKey       ssh.PublicKey
	Agent           *agent.Agent
	User            *User
	Errors          []error
	Time            time.Time
}

SSHServerClient is a struct containing the client (user's) SSH connection

type Session

type Session struct {
	gorm.Model
	Name     string `gorm:"type:MEDIUMTEXT;"`
	Time     time.Time
	Cast     string `gorm:"type:LONGTEXT;"`
	UserID   uint
	User     *User
	Host     string `gorm:"type:MEDIUMTEXT;"`
	Hostname string `gorm:"type:MEDIUMTEXT;"`
	Users    string `gorm:"type:LONGTEXT;"`
	Command  string `gorm:"type:MEDIUMTEXT;"`
}

Session is the model for a specific SSH sessions

type User

type User struct {
	gorm.Model
	CertExpires     time.Time
	Email           string      `gorm:"type:varchar(255);"`
	AuthToken       string      `gorm:"type:MEDIUMTEXT;"`
	Cert            []byte      `gorm:"type:varbinary(4096);"`
	PrivateKey      []byte      `gorm:"type:varbinary(4096);"`
	Authorized      bool        `gorm:"default:false"`
	AuthorizedHosts string      `gorm:"type:MEDIUMTEXT;"`
	Admin           bool        `gorm:"default:false"`
	UnixUser        string      `gorm:"type:varchar(255);"`
	OTPSecret       string      `gorm:"type:varchar(255);"`
	AuthRules       []AuthRules `gorm:"many2many:user_auth_rules;"`
}

User is the model for users and their data

type WsClient

type WsClient struct {
	Client *websocket.Conn
}

WsClient is a struct that contains a websockets underlying data object

Jump to

Keyboard shortcuts

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