dbdata

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2021 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Allow = "allow"
	Deny  = "deny"
)
View Source
const PageSize = 10

Variables

View Source
var ErrNotFound = errors.New("ErrNotFound")

Functions

func Add

func Add(data interface{}) error

func CheckErrNotFound

func CheckErrNotFound(err error) bool

func CheckUser

func CheckUser(name, pwd, group string) error

验证用户登陆信息

func CountAll

func CountAll(data interface{}) int

func CountPrefix

func CountPrefix(fieldName string, prefix string, data interface{}) int

func Del

func Del(data interface{}) error

func Find

func Find(data interface{}, limit, page int) error

func GetGroupNames

func GetGroupNames() []string

func GetXdb

func GetXdb() *xorm.Engine

func One

func One(fieldName string, value interface{}, data interface{}) error

func Prefix

func Prefix(fieldName string, prefix string, data interface{}, limit, page int) error

func Set

func Set(data interface{}) error

更新全部字段

func SetGroup

func SetGroup(g *Group) error

func SetIpMap

func SetIpMap(v *IpMap) error

func SetUser

func SetUser(v *User) error

func SettingGet

func SettingGet(data interface{}) error

func SettingSessAdd

func SettingSessAdd(sess *xorm.Session, data interface{}) error

func SettingSet

func SettingSet(data interface{}) error

func Start

func Start()

func Stop

func Stop() error

func StructName

func StructName(data interface{}) string

func Update

func Update(fieldName string, value interface{}, data interface{}) error

Types

type AccessAudit

type AccessAudit struct {
	Id        int       `json:"id" xorm:"pk autoincr not null"`
	Username  string    `json:"username" xorm:"varchar(60) not null"`
	Protocol  uint8     `json:"protocol" xorm:"not null"`
	Src       string    `json:"src" xorm:"varchar(60) not null"`
	SrcPort   uint16    `json:"src_port" xorm:"not null"`
	Dst       string    `json:"dst" xorm:"varchar(60) not null"`
	DstPort   uint16    `json:"dst_port" xorm:"not null"`
	CreatedAt time.Time `json:"created_at" xorm:"DateTime"`
}

type Group

type Group struct {
	Id           int            `json:"id" xorm:"pk autoincr not null"`
	Name         string         `json:"name" xorm:"varchar(60) not null unique"`
	Note         string         `json:"note" xorm:"varchar(255)"`
	AllowLan     bool           `json:"allow_lan" xorm:"Bool"`
	ClientDns    []ValData      `json:"client_dns" xorm:"Text"`
	RouteInclude []ValData      `json:"route_include" xorm:"Text"`
	RouteExclude []ValData      `json:"route_exclude" xorm:"Text"`
	LinkAcl      []GroupLinkAcl `json:"link_acl" xorm:"Text"`
	Bandwidth    int            `json:"bandwidth" xorm:"Int"` // 带宽限制
	Status       int8           `json:"status" xorm:"Int"`    // 1正常
	CreatedAt    time.Time      `json:"created_at" xorm:"DateTime created"`
	UpdatedAt    time.Time      `json:"updated_at" xorm:"DateTime updated"`
}

type GroupLinkAcl

type GroupLinkAcl struct {
	// 自上而下匹配 默认 allow * *
	Action string     `json:"action"` // allow、deny
	Val    string     `json:"val"`
	Port   uint16     `json:"port"`
	IpNet  *net.IPNet `json:"ip_net"`
	Note   string     `json:"note"`
}

type IpMap

type IpMap struct {
	Id        int       `json:"id" xorm:"pk autoincr not null"`
	IpAddr    string    `json:"ip_addr" xorm:"varchar(32) not null unique"`
	MacAddr   string    `json:"mac_addr" xorm:"varchar(32) not null unique"`
	Username  string    `json:"username" xorm:"varchar(60)"`
	Keep      bool      `json:"keep" xorm:"Bool"` // 保留 ip-mac 绑定
	KeepTime  time.Time `json:"keep_time" xorm:"DateTime"`
	Note      string    `json:"note" xorm:"varchar(255)"` // 备注
	LastLogin time.Time `json:"last_login" xorm:"DateTime updated"`
	UpdatedAt time.Time `json:"updated_at" xorm:"DateTime updated"`
}

type Setting

type Setting struct {
	Id        int             `json:"id" xorm:"pk autoincr not null"`
	Name      string          `json:"name" xorm:"varchar(60) not null unique"`
	Data      json.RawMessage `json:"data" xorm:"Text"`
	UpdatedAt time.Time       `json:"updated_at" xorm:"DateTime updated"`
}

type SettingInstall

type SettingInstall struct {
	Installed bool `json:"installed"`
}

type SettingOther

type SettingOther struct {
	LinkAddr    string `json:"link_addr"`
	Banner      string `json:"banner"`
	AccountMail string `json:"account_mail"`
}

type SettingSmtp

type SettingSmtp struct {
	Host       string `json:"host"`
	Port       int    `json:"port"`
	Username   string `json:"username"`
	Password   string `json:"password"`
	From       string `json:"from"`
	Encryption string `json:"encryption"`
}

type User

type User struct {
	Id       int    `json:"id" xorm:"pk autoincr not null"`
	Username string `json:"username" xorm:"varchar(60) not null unique"`
	Nickname string `json:"nickname" xorm:"varchar(255)"`
	Email    string `json:"email" xorm:"varchar(255)"`
	// Password  string    `json:"password"`
	PinCode    string    `json:"pin_code" xorm:"varchar(32)"`
	OtpSecret  string    `json:"otp_secret" xorm:"varchar(255)"`
	DisableOtp bool      `json:"disable_otp" xorm:"Bool"` // 禁用otp
	Groups     []string  `json:"groups" xorm:"Text"`
	Status     int8      `json:"status" xorm:"Int"` // 1正常
	SendEmail  bool      `json:"send_email" xorm:"Bool"`
	CreatedAt  time.Time `json:"created_at" xorm:"DateTime created"`
	UpdatedAt  time.Time `json:"updated_at" xorm:"DateTime updated"`
}

type ValData

type ValData struct {
	Val    string `json:"val"`
	IpMask string `json:"ip_mask"`
	Note   string `json:"note"`
}

Jump to

Keyboard shortcuts

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