Documentation ¶
Index ¶
- Constants
- Variables
- func AllocateRole2User(userID uint64, roles_id []int) (enconterError error)
- func AppendAuditLog(auditLog map[string]interface{})
- func CheckPortIsExistWithName(name string) bool
- func CheckTagIsExistWithName(name string) bool
- func CheckTemplateIsExistWithName(name string) bool
- func CreateHost(hostIP, host string, tagID int) (enconterError error)
- func CreateHostWithHost(host *Host) (enconterError error)
- func CreatePort(port uint16, protocol string, template_id int) (enconterError error)
- func CreateRich(query *queryapi.RichEditQuery) (enconterError error)
- func CreateRole(query *query2.RoleEditQuery, routers []Router) (enconterError error)
- func CreateTag(tagQuery *query.TagEditQuery) (enconterError error)
- func CreateTemplate(name, description, target string) (enconterError error)
- func CreateToken(SignedTo, description string) (enconterError error)
- func CreateUser(userQuery *query.UserQuery) (enconterError error)
- func DeleteHostWithID(id uint64) error
- func DeletePortWithID(id uint64) error
- func DeleteRichWithID(id uint64) error
- func DeleteRoleWithID(id uint64) error
- func DeleteTagWithID(id uint64) error
- func DeleteTemplateWithID(id uint64) error
- func DeleteTokenWithID(id uint64) error
- func DeleteUserWithID(id uint64) error
- func EncryptPassword(p string) string
- func GetAuditLogs(offset, limit int, sort string) (map[string]interface{}, error)
- func GetHosts(offset, limit int, sort string) (map[string]interface{}, error)
- func GetPorts(offset, limit int, sort string) (map[string]interface{}, error)
- func GetRequestIP(r *http.Request) (uint32, error)
- func GetRich(offset, limit int, sort string) (map[string]interface{}, error)
- func GetRoles(offset, limit int, sort string) (map[string]interface{}, error)
- func GetRouters(offset, limit int, sort string) (map[string]interface{}, error)
- func GetSimpleTemplates(offset, limit int, sort string) (map[string]interface{}, error)
- func GetTags(offset, limit int, sort string) (map[string]interface{}, error)
- func GetTemplates(offset, limit int, sort string) (map[string]interface{}, error)
- func GetTokens(offset, limit int, sort string) (map[string]interface{}, error)
- func GetUsers(offset, limit int, sort string) (map[string]interface{}, error)
- func HostCounter() int64
- func InitDB(driver string) error
- func LastLogin(uid int64, ip uint32) bool
- func TagCounter() int64
- func TemplateCounter() int64
- func TokenIsDestoryed(tokenStr string) bool
- func UpdateHostWithID(query *query.HostQuery) (enconterError error)
- func UpdatePortWithID(id uint64, port uint16, protocol string, template_id int) (enconterError error)
- func UpdateRichWithID(query *queryapi.RichEditQuery) (enconterError error)
- func UpdateRoleWithID(query *query2.RoleEditQuery) (enconterError error)
- func UpdateTagWithID(query *query.TagEditQuery) (enconterError error)
- func UpdateTemplateWithID(id uint64, name, description, target string) (enconterError error)
- func UpdateTokenWithID(id uint64, signedTo, description string, isUpdate bool) (enconterError error)
- func UpdateUserWithID(query *query.UserEditQuery) (enconterError error)
- type Audit
- type AuditList
- type Classify
- type Host
- type HostList
- type Port
- type PortList
- type Rich
- type RichList
- type Role
- type RoleInfo
- type RoleList
- type Router
- type RouterList
- type Tag
- type TagInfo
- type Template
- type TemplateList
- type Token
- type TokenList
- type User
- type UserInfo
- type UserList
- type UserRoles
Constants ¶
View Source
const Secret = "com.github.cylonchau"
Variables ¶
View Source
var DB *gorm.DB
Functions ¶
func AllocateRole2User ¶ added in v0.0.6
func AppendAuditLog ¶ added in v0.0.6
func AppendAuditLog(auditLog map[string]interface{})
func CheckTagIsExistWithName ¶
func CreateHost ¶
func CreateHostWithHost ¶
func CreatePort ¶
func CreateRich ¶
func CreateRich(query *queryapi.RichEditQuery) (enconterError error)
func CreateRole ¶ added in v0.0.6
func CreateRole(query *query2.RoleEditQuery, routers []Router) (enconterError error)
Create role
func CreateTag ¶
func CreateTag(tagQuery *query.TagEditQuery) (enconterError error)
func CreateTemplate ¶
func CreateToken ¶
func CreateUser ¶
func DeleteHostWithID ¶
func DeletePortWithID ¶
func DeleteRichWithID ¶
func DeleteRoleWithID ¶ added in v0.0.6
func DeleteTagWithID ¶
func DeleteTemplateWithID ¶
func DeleteTokenWithID ¶
func DeleteUserWithID ¶ added in v0.0.6
func EncryptPassword ¶
func GetAuditLogs ¶ added in v0.0.6
func GetRouters ¶ added in v0.0.6
Get all roles
func GetSimpleTemplates ¶
func GetTemplates ¶
func HostCounter ¶ added in v0.0.5
func HostCounter() int64
func TagCounter ¶ added in v0.0.5
func TagCounter() int64
func TemplateCounter ¶ added in v0.0.5
func TemplateCounter() int64
func TokenIsDestoryed ¶ added in v0.0.4
func UpdateHostWithID ¶
func UpdatePortWithID ¶
func UpdateRichWithID ¶
func UpdateRichWithID(query *queryapi.RichEditQuery) (enconterError error)
func UpdateRoleWithID ¶ added in v0.0.6
func UpdateRoleWithID(query *query2.RoleEditQuery) (enconterError error)
func UpdateTagWithID ¶
func UpdateTagWithID(query *query.TagEditQuery) (enconterError error)
func UpdateTemplateWithID ¶
func UpdateTokenWithID ¶
func UpdateUserWithID ¶ added in v0.0.6
func UpdateUserWithID(query *query.UserEditQuery) (enconterError error)
Types ¶
type Audit ¶ added in v0.0.6
type Audit struct { gorm.Model UserID uint64 `json:"user_id" gorm:"index;type:int"` IP uint32 `json:"ip" gorm:"index;type:int"` Method string `json:"method" gorm:"type:char(5)"` Path string `json:"path" gorm:"varchar(50)"` Browser string `json:"browser" gorm:"varchar(50)"` System string `json:"system" gorm:"varchar(50)"` }
type AuditList ¶ added in v0.0.6
type AuditList struct { Username string `json:"username" gorm:"index;type:varchar(20)"` IP uint32 `json:"ip" gorm:"index;type:int"` Method string `json:"method" gorm:"type:char(5)"` Path string `json:"path" gorm:"varchar(50)"` Browser string `json:"browser" gorm:"varchar(50)"` System string `json:"system" gorm:"varchar(50)"` }
type Classify ¶ added in v0.0.5
func HostClassify ¶ added in v0.0.5
type Host ¶
type Host struct { gorm.Model Hostname string `json:"hostname" gorm:"index;type:varchar(255)"` IP uint32 `json:"ip" gorm:"index;type:int"` TagId int `json:"tag_id" gorm:"index;type:int"` }
func QueryHostWithID ¶
func QueryHostWithName ¶
type HostList ¶
type PortList ¶
type Rich ¶
type Rich struct { gorm.Model Family string `form:"family" json:"family,omitempty" gorm:"type:char(4)"` Source *api.Source `form:"source" json:"source,omitempty" gorm:"json"` Destination *api.Destination `form:"destination" json:"destination,omitempty" gorm:"json"` Port []*api.Port `form:"port" json:"port,omitempty" gorm:"json"` Protocol *api.Protocol `form:"protocol" json:"protocol,omitempty" gorm:"json"` Action string `form:"action" json:"action,omitempty" gorm:"type:varchar(30)"` Limit uint16 `form:"limit" json:"limit,omitempty" gorm:"type:varchar(255)"` LimitUnit string `form:"limit_unit" json:"limit_unit,omitempty" gorm:"type:char(1)"` TemplateID int `form:"template_id" json:"template_id,omitempty" gorm:"type:int"` }
type RichList ¶
type RichList struct { ID int `json:"id"` Family string `form:"family" json:"family,omitempty"` Source *api.Source `form:"source" json:"source,omitempty" gorm:"json"` Destination *api.Destination `form:"destination" json:"destination,omitempty" gorm:"json"` Port []*api.Port `form:"port" json:"port,omitempty" gorm:"json"` Protocol *api.Protocol `form:"protocol" json:"protocol,omitempty" gorm:"json"` Action string `form:"action" json:"action,omitempty"` Limit uint16 `form:"limit" json:"limit,omitempty"` LimitUnit string `form:"limit_unit" json:"limit_unit,omitempty"` TemplateID int `form:"template_id" json:"template_id,omitempty"` Template string `json:"template"` }
type Role ¶ added in v0.0.6
type Role struct { gorm.Model Name string `gorm:"size:50;not null;unique" json:"name"` Routers []Router `gorm:"many2many:role_routers;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"` Users []User `gorm:"many2many:user_roles;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"` Tokens []Token `gorm:"many2many:token_roles;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"` Description string `gorm:"size:255;not null" json:"description"` }
Role model
func GenerateRoleWithID ¶ added in v0.0.6
type RoleInfo ¶ added in v0.0.6
type RoleList ¶ added in v0.0.6
type Router ¶ added in v0.0.6
type Router struct { gorm.Model Path string `json:"path" gorm:"type:varchar(255);not null;"` Method string `json:"method" gorm:"type:char(4);not null;"` Roles []Role `gorm:"many2many:role_routers;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"` }
Router model
func GenerateRouterWithID ¶ added in v0.0.6
type RouterList ¶ added in v0.0.6
type RouterList struct { ID int `json:"id" gorm:"primarykey;column:id"` Path string `json:"path" gorm:"type:varchar(255);not null;column:path"` Method string `json:"method" gorm:"type:char(4);not null;column:method"` CreatedAt time.Time `json:"created_at" gorm:"column:created_at"` }
func GetRoutersWithRID ¶ added in v0.0.6
func GetRoutersWithRID(roleIDs []string) (routers []*RouterList, encounterError error)
func (*RouterList) TableName ¶ added in v0.0.6
func (*RouterList) TableName() string
type Tag ¶
type Tag struct { gorm.Model Name string `json:"name" gorm:"index;type:varchar(255)"` Description string `json:"description" gorm:"type:varchar(255)"` Hosts []Host `json:"hosts" gorm:"foreignKey:TagId;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"` }
func CheckTagIsExistWithID ¶
type TagInfo ¶
type TemplateList ¶
type TemplateList struct { ID int `json:"id"` Name string `json:"name"` Target string `json:"target,omitempty"` Description string `json:"description,omitempty"` }
func (*TemplateList) TableName ¶
func (*TemplateList) TableName() string
type Token ¶
type Token struct { gorm.Model Token string `form:"token" json:"token" gorm:"index,type:text"` SignedTo string `form:"signed_to" json:"signed_to" gorm:"type:varchar(255)"` SignedBy string `form:"signed_by" json:"signed_by" gorm:"type:varchar(255)"` Description string `json:"description" gorm:"type:varchar(255)"` Roles []Role `gorm:"many2many:token_roles;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"` }
type TokenList ¶
type TokenList struct { ID int `json:"id"` Token string `form:"token" json:"token" gorm:"type:text"` SignedTo string `form:"signed_to" json:"signed_to" gorm:"type:varchar(255)"` SignedBy string `form:"signed_by" json:"signed_by" gorm:"type:varchar(255)"` Description string `json:"description" gorm:"type:varchar(255)"` }
type User ¶
type User struct { gorm.Model Username string `gorm:"index;type:varchar(20)"` Password string `gorm:"type:varchar(32)"` Roles []Role `gorm:"many2many:user_roles;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"` LoginIP int `json:"login_ip" gorm:"index;type:int"` }
func QueryUserWithUID ¶
func QueryUserWithUsername ¶
type UserInfo ¶ added in v0.0.6
type UserInfo struct { ID uint `gorm:"primarykey;column:id" json:"id"` Username string `gorm:"index;type:varchar(20);column:username" json:"username"` Roles []RoleInfo `` /* 171-byte string literal not displayed */ }
func GetRolesWithUID ¶ added in v0.0.6
type UserList ¶ added in v0.0.6
type UserList struct { ID uint `json:"id" gorm:"primarykey"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"update_at"` DeletedAt gorm.DeletedAt `json:"deleted_at" gorm:"index"` Username string `json:"username" gorm:"index;type:varchar(20)"` Roles []Role `json:"roles" gorm:"many2many:user_roles;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"` LoginIP int `json:"login_ip" gorm:"index;type:int"` }
Click to show internal directories.
Click to hide internal directories.