models

package
v0.0.0-...-aa13637 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2020 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Announcement

type Announcement struct {
	BaseModel
	Level   string `json:"level"`
	Title   string `json:"title"`
	Content string `json:"content"`
}

Announcement is used by admin to annouce sth

type BaseModel

type BaseModel struct {
	ID        uint64    `gorm:"primaryKey" json:"id" fake:"skip"`
	CreatedAt time.Time `json:"created_at" fake:"skip"`
	UpdatedAt time.Time `json:"updated_at" fake:"skip"`
}

type ForgetPassword

type ForgetPassword struct {
	BaseModel
	Token  string `json:"token" fake:"{uuid}"`
	UserID uint   `fake:"skip"`
	User   *User
}

type Group

type Group struct {
	BaseModel
	Name        string  `json:"groupname"`
	Description string  `json:"description"`
	Users       []*User `gorm:"many2many:groups_users;" json:"-"`
	Nodes       []*Node `gorm:"many2many:groups_nodes;" json:"-"`
}

type Mail

type Mail struct {
	From        string
	To          string
	Subject     string
	ContentType string
	Content     string
}

type MailConfig

type MailConfig struct {
	Host          string
	Port          int
	Username      string
	Password      string
	AllowInsecure bool
}

type Node

type Node struct {
	BaseModel
	Name           string     `json:"name"`
	Description    string     `json:"description"`
	Groups         []*Group   `gorm:"many2many:groups_nodes;" json:"-"`
	Services       []*Service `json:"-"`
	Host           string     `json:"host"` // The Host to access v2ray
	Ports          string     `json:"ports"`
	AccessToken    string     `json:"-"`
	CurrentTraffic uint64     `json:"current_traffic"`
	MaxTraffic     uint64     `json:"max_traffic"`
	HasUDP         bool       `json:"hasUDP"`
	HasMultiPort   bool       `json:"hasMultiPort"`
	Settings       `json:"settings"`
}

Node is a struct of node info

type Option

type Option struct {
	BaseModel
	Name  string `json:"name"`
	Value string `json:"value"`
}

type Service

type Service struct {
	BaseModel
	Name        string `json:"name"`
	Description string `json:"description"`
	UserID      uint64 `json:"uid"`
	NodeID      uint64 `json:"nid"`

	Host      string `json:"host"`
	Port      uint   `json:"port"`
	Protocol  string `json:"protocol"`
	VmessUser `json:"vmessUser"`
	VmessSetting
	ShadowsocksSetting
}

type Settings

type Settings struct {
	Listen             string `json:"listen"`
	Port               uint   `json:"port"`
	VmessSetting       `json:"vmessSettings"`
	ShadowsocksSetting `json:"shadowsocksSettings"`
}

type ShadowsocksSetting

type ShadowsocksSetting struct{}

type SniffingSettings

type SniffingSettings struct{}

type StreamSettings

type StreamSettings struct {
	TransportProtocol string `json:"protocol"`
}

type User

type User struct {
	BaseModel
	UUID              string               `gorm:"unique" json:"uuid" fake:"{uuid}"`
	Token             map[string]time.Time `json:"-" gorm:"-" fake:"skip"`            // gorm doesn't support complex type so hav to marshal it
	TokenStr          string               `json:"-" gorm:"column:token" fake:"skip"` // the actual data is stored here
	JwtKey            []byte               `json:"-" fake:"skip"`                     // Do not export it due to leak risk
	Email             string               `gorm:"unique" json:"email" fake:"{email}"`
	Username          string               `gorm:"unique" json:"username" fake:"{username}"`
	Password          string               `json:"-" fake:"{password:true,true,true,true,true,8}"`
	SubscriptionToken string               `json:"subscription_token"`
	CurrentTraffic    int64                `json:"current_traffic"`
	MaxTraffic        int64                `json:"max_traffic"`
	Groups            []*Group             `gorm:"many2many:groups_users;" json:"-" fake:"skip"`
}

User table model

func (*User) AfterFind

func (user *User) AfterFind(*gorm.DB) error

AfterFind unmarshal token map

func (*User) BeforeSave

func (user *User) BeforeSave(*gorm.DB) error

BeforeSave marshal the token map This is a GORM feature called hook

func (*User) GetJwtKey

func (user *User) GetJwtKey() (key []byte, err error)

GetJwtKey provide access to private var jwtKey, if jwtKey is nil then generate it

type VmessSetting

type VmessSetting struct {
	StreamSettings `json:"streamSettings"`
	SniffingSettings
	// contains filtered or unexported fields
}

type VmessUser

type VmessUser struct {
	Email    string `json:"email"`
	UUID     string `json:"uuid"`
	AlterID  uint   `json:"alterid"`
	Security string `json:"security"`
}

Jump to

Keyboard shortcuts

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