Documentation ¶
Index ¶
- func GetHostname(env *Env) string
- func GetOutboundIP(env *Env) net.IP
- func NewAsciicastReadCloser(r io.ReadCloser, conn ssh.ConnMetadata, width int, height int, ...) io.ReadCloser
- func Save(env *Env)
- type AsciicastReadCloser
- type AuthRules
- type ColorLog
- type Config
- type ConnChan
- type ConnReq
- type Env
- type LiveSession
- type SSHProxyClient
- type SSHServerClient
- type Session
- type User
- type WsClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetHostname ¶
GetHostname returns the hostname of the machine the bastion is running on
func GetOutboundIP ¶
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
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
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 ¶
ColorLog is a wrapper around a certain color for logging
func NewColorLog ¶
NewColorLog creates a new color for formatted logging
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 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
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