model

package
v0.0.0-...-f69eaad Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2020 License: GPL-3.0 Imports: 8 Imported by: 0

README

数据层

Documentation

Index

Constants

View Source
const (
	AllAction      = "all"
	ConnectAction  = "connect"
	UploadAction   = "upload_file"
	DownloadAction = "download_file"
)
View Source
const (
	OperateRemoveDir = "Rmdir"
	OperateDownaload = "Download"
	OperateUpload    = "Upload"
	OperateRename    = "Rename"
	OperateMkdir     = "Mkdir"
	OperateDelete    = "Delete"
	OperateSymlink   = "Symlink"
)
View Source
const (
	ContextKeyUser contextKey = iota + 1
	ContextKeyRemoteAddr
	ContextKeyClient
	ContextKeyConfirmRequired
	ContextKeyConfirmFailed
)
View Source
const (
	HighRiskFlag = "1"
	LessRiskFlag = "0"
)
View Source
const (
	PingEvent    = "Ping"
	DataEvent    = "Data"
	WindowsEvent = "Windows"

	MaxIdleEvent        = "MaxIdle"   // 退出
	ExitEvent           = "Exit"      // 退出
	LogoutEvent         = "Logout"    // 退出
	AdminTerminateEvent = "Terminate" //退出

)
View Source
const LoginModeManual = "manual"

Variables

This section is empty.

Functions

func SortAssetNodesByKey

func SortAssetNodesByKey(assetNodes []Node)

func SortSystemUserByPriority

func SortSystemUserByPriority(users []SystemUser)

Types

type Asset

type Asset struct {
	ID        string   `json:"id"`
	Hostname  string   `json:"hostname"`
	IP        string   `json:"ip"`
	Os        string   `json:"os"`
	Domain    string   `json:"domain"`
	Comment   string   `json:"comment"`
	Protocols []string `json:"protocols,omitempty"`
	OrgID     string   `json:"org_id"`
	OrgName   string   `json:"org_name"`
	Platform  string   `json:"platform,omitempty"`
}

func ConvertMetaToAsset

func ConvertMetaToAsset(body []byte) (asset Asset, err error)

func (*Asset) IsSupportProtocol

func (a *Asset) IsSupportProtocol(protocol string) bool

func (*Asset) ProtocolPort

func (a *Asset) ProtocolPort(protocol string) int

type AssetList

type AssetList []Asset

func (AssetList) SortBy

func (a AssetList) SortBy(tp string) AssetList

type AssetNodeSorter

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

func (*AssetNodeSorter) Len

func (a *AssetNodeSorter) Len() int

func (*AssetNodeSorter) Less

func (a *AssetNodeSorter) Less(i, j int) bool

func (*AssetNodeSorter) Swap

func (a *AssetNodeSorter) Swap(i, j int)

type AssetsPaginationResponse

type AssetsPaginationResponse struct {
	Total       int     `json:"count"`
	NextURL     string  `json:"next"`
	PreviousURL string  `json:"previous"`
	Data        []Asset `json:"results"`
}

type Command

type Command struct {
	SessionID  string `json:"session"`
	OrgID      string `json:"org_id"`
	Input      string `json:"input"`
	Output     string `json:"output"`
	User       string `json:"user"`
	Server     string `json:"asset"`
	SystemUser string `json:"system_user"`
	Timestamp  int64  `json:"timestamp"`
	RiskLevel  int64  `json:"risk_level"`
}

type Database

type Database struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	DBType  string `json:"type"`
	Host    string `json:"host"`
	Port    int    `json:"port"`
	DBName  string `json:"database"`
	OrgID   string `json:"org_id"`
	Comment string `json:"comment"`
}

func (Database) String

func (db Database) String() string

type Domain

type Domain struct {
	ID       string    `json:"id"`
	Gateways []Gateway `json:"gateways"`
	Name     string    `json:"name"`
}

type FTPLog

type FTPLog struct {
	User       string `json:"user"`
	Hostname   string `json:"asset"`
	OrgID      string `json:"org_id"`
	SystemUser string `json:"system_user"`
	RemoteAddr string `json:"remote_addr"`
	Operate    string `json:"operate"`
	Path       string `json:"filename"`
	DataStart  string `json:"data_start"`
	IsSuccess  bool   `json:"is_success"`
}

type Gateway

type Gateway struct {
	ID         string `json:"id"`
	Name       string `json:"Name"`
	IP         string `json:"ip"`
	Port       int    `json:"port"`
	Protocol   string `json:"protocol"`
	Username   string `json:"username"`
	Password   string `json:"password"`
	PrivateKey string `json:"private_key"`
}

type Node

type Node struct {
	ID           string `json:"id"`
	Key          string `json:"key"`
	Name         string `json:"name"`
	Value        string `json:"value"`
	Parent       string `json:"parent"`
	AssetsAmount int    `json:"assets_amount"`
	OrgID        string `json:"org_id"`
}

func ConvertMetaToNode

func ConvertMetaToNode(body []byte) (node Node, err error)

type NodeList

type NodeList []Node

type NodeTreeAsset

type NodeTreeAsset struct {
	ID       string                 `json:"id"`
	Name     string                 `json:"name"`
	Title    string                 `json:"title"`
	Pid      string                 `json:"pId"`
	IsParent bool                   `json:"isParent"`
	Meta     map[string]interface{} `json:"meta"`
}

type NodeTreeList

type NodeTreeList []NodeTreeAsset

type RoomMessage

type RoomMessage struct {
	Event string `json:"event"`
	Body  []byte `json:"data"`
}

func (RoomMessage) Marshal

func (m RoomMessage) Marshal() []byte

func (RoomMessage) UnMarshal

func (m RoomMessage) UnMarshal(p interface{})

type RuleAction

type RuleAction int
const (
	ActionDeny    RuleAction = 0
	ActionAllow   RuleAction = 1
	ActionUnknown RuleAction = 2

	TypeRegex = "regex"
	TypeCmd   = "command"
)

type SystemUser

type SystemUser struct {
	ID                   string   `json:"id"`
	Name                 string   `json:"name"`
	Username             string   `json:"username"`
	Priority             int      `json:"priority"`
	Protocol             string   `json:"protocol"`
	Comment              string   `json:"comment"`
	LoginMode            string   `json:"login_mode"`
	Password             string   `json:"password"`
	PrivateKey           string   `json:"private_key"`
	Actions              []string `json:"actions"`
	SftpRoot             string   `json:"sftp_root"`
	OrgId                string   `json:"org_id"`
	OrgName              string   `json:"org_name"`
	UsernameSameWithUser bool     `json:"username_same_with_user"`
}

type SystemUserAuthInfo

type SystemUserAuthInfo struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	UserName   string `json:"username"`
	Protocol   string `json:"protocol"`
	LoginMode  string `json:"login_mode"`
	Password   string `json:"password"`
	PrivateKey string `json:"private_key"`
}

type SystemUserFilterRule

type SystemUserFilterRule struct {
	Priority int        `json:"priority"`
	Type     string     `json:"type"`
	Content  string     `json:"content"`
	Action   RuleAction `json:"action"`
	// contains filtered or unexported fields
}

func (*SystemUserFilterRule) Match

func (sf *SystemUserFilterRule) Match(cmd string) (RuleAction, string)

func (*SystemUserFilterRule) Pattern

func (sf *SystemUserFilterRule) Pattern() *regexp.Regexp

type Terminal

type Terminal struct {
	Name           string `json:"name"`
	Comment        string `json:"comment"`
	ServiceAccount struct {
		ID        string `json:"id"`
		Name      string `json:"name"`
		AccessKey struct {
			ID     string `json:"id"`
			Secret string `json:"secret"`
		} `json:"access_key"`
	} `json:"service_account"`
}

type TerminalTask

type TerminalTask struct {
	ID         string `json:"id"`
	Name       string `json:"name"`
	Args       string `json:"args"`
	IsFinished bool
}

type TokenUser

type TokenUser struct {
	UserID         string `json:"user"`
	UserName       string `json:"username"`
	AssetID        string `json:"asset"`
	Hostname       string `json:"hostname"`
	SystemUserID   string `json:"system_user"`
	SystemUserName string `json:"system_user_name"`
}

type User

type User struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Username string `json:"username"`
	Email    string `json:"email"`
	Role     string `json:"role"`
	IsValid  bool   `json:"is_valid"`
	IsActive bool   `json:"is_active"`
	OTPLevel int    `json:"otp_level"`
}

Jump to

Keyboard shortcuts

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