db

package
v0.0.0-...-fd3d7d8 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthInfo

type AuthInfo struct {
	Status     AuthStatus `json:"status"`
	Username   string     `json:"username"`
	AuthMethod string     `json:"auth_method,omitempty"`
	RemoteAddr string     `json:"remote_addr"`
	Date       time.Time  `json:"date"`
}

type AuthStatus

type AuthStatus string
const (
	AuthAccepted     AuthStatus = "Accepted"
	AuthDisconnected AuthStatus = "Disconnected"
	AuthFailed       AuthStatus = "Failed"
)

type AuthStorage

type AuthStorage interface {
	UpsetAuthEvent(authInfo AuthInfo) (Session, error)
	GetUserSessions(username string) ([]Session, error)
}

Auth Storage Schema: Bucket<username> -*> Key<ip> -> Value<Session>

type Session

type Session struct {
	ID          uint64           `json:"session_id"`
	Status      AuthStatus       `json:"status"`
	Username    string           `json:"username"`
	AuthMethods map[string]int32 `json:"auth_methods,omitempty"`
	RemoteAddr  string           `json:"remote_addr"`

	ConnsCount     int32      `json:"conns_count"`
	FirstLogInTime *time.Time `json:"login_time,omitempty"`
	LastLogInTime  *time.Time `json:"login_time,omitempty"`
	LastLogOutTime *time.Time `json:"logout_time,omitempty"`

	FailsCount      int32      `json:"fails_count,omitempty"`
	LastAttemptTime *time.Time `json:"last_attempt_time,omitempty"`
}

func NewSession

func NewSession(sessionID uint64, info AuthInfo) Session

func (*Session) Update

func (s *Session) Update(info AuthInfo)

type SlackStorage

type SlackStorage interface {
}

type Storage

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

func (*Storage) Auth

func (st *Storage) Auth() AuthStorage

func (*Storage) Slack

func (st *Storage) Slack() SlackStorage

func (*Storage) TG

func (st *Storage) TG() TGStorage

type StorageI

type StorageI interface {
	Auth() AuthStorage
	TG() TGStorage
	Slack() SlackStorage
}

func NewStorage

func NewStorage(dbPath string) (StorageI, error)

type TGChatInfo

type TGChatInfo struct {
	ChatID int64
	Muted  bool
}

type TGStorage

type TGStorage interface {
	AddUser(username string, chatID int64) error
	Mute(username string, chatID int64) error
	GetUsers() (map[string]TGChatInfo, error)
	GetUser(username string) (TGChatInfo, error)
}

Jump to

Keyboard shortcuts

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