storage

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2018 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsExist

func IsExist(err error) bool

func IsNotExist

func IsNotExist(err error) bool

Types

type Agent

type Agent struct {
	ID        int       `json:"id" db:"id"`
	UserID    int       `json:"user_id" db:"user_id"`
	Hash      string    `json:"hash" db:"hash"`
	Device    string    `json:"device" db:"device"` // os, kernel, arch
	Version   string    `json:"version" db:"version"`
	Status    string    `json:"status" db:"status"`
	Delayed   string    `json:"delayed" db:"delayed"`
	Tag       string    `json:"tag" db:"tag"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
	Tunnels   []Tunnel  `json:"tunnels,omitempty" db:"-"`
}

func (Agent) MarshalJSON

func (agent Agent) MarshalJSON() ([]byte, error)

type AgentForJSON

type AgentForJSON Agent // Use alias to avoid infinite recursive.

type DB

type DB struct {
	*sqlx.DB
	// contains filtered or unexported fields
}

func New

func New(datadir string) (*DB, error)

func (*DB) CreateAgent

func (db *DB) CreateAgent(username, hash, tag string) error

func (*DB) CreateTunnel

func (db *DB) CreateTunnel(username, ahash, hash, proto, exportAddr, serverAddr, tag string) error

func (*DB) CreateUser

func (db *DB) CreateUser(name, password, email string, isAdmin bool) error

func (*DB) DeleteAgent

func (db *DB) DeleteAgent(username, hash string) error

func (*DB) DeleteAgents

func (db *DB) DeleteAgents(username string) error

func (*DB) DeleteTunnel

func (db *DB) DeleteTunnel(username, ahash, hash string) error

func (*DB) DeleteTunnels

func (db *DB) DeleteTunnels(username, ahash string) error

func (*DB) DeleteUser

func (db *DB) DeleteUser(name string) error

func (*DB) IsEmpty

func (db *DB) IsEmpty() (bool, error)

func (*DB) QueryAgent

func (db *DB) QueryAgent(username, hash string) (Agent, error)

func (*DB) QueryAgentCount

func (db *DB) QueryAgentCount(username string) (n int, err error)

func (*DB) QueryAgentHashs

func (db *DB) QueryAgentHashs(username string) ([]string, error)

func (*DB) QueryAgents

func (db *DB) QueryAgents(username string) ([]Agent, error)

func (*DB) QueryTunnel

func (db *DB) QueryTunnel(username, ahash, hash string) (Tunnel, error)

func (*DB) QueryTunnelCount

func (db *DB) QueryTunnelCount(username, ahash string) (n int, err error)

func (*DB) QueryTunnels

func (db *DB) QueryTunnels(username, ahash string) ([]Tunnel, error)

func (*DB) QueryUser

func (db *DB) QueryUser(name string) (User, error)

func (*DB) QueryUserCount

func (db *DB) QueryUserCount() (n int, err error)

func (*DB) QueryUsers

func (db *DB) QueryUsers() ([]User, error)

func (*DB) UpdateAgent

func (db *DB) UpdateAgent(username, hash string, args map[string]interface{}) (bool, error)

func (*DB) UpdateTunnel

func (db *DB) UpdateTunnel(username, ahash, hash string, args map[string]interface{}) (bool, error)

func (*DB) UpdateUser

func (db *DB) UpdateUser(name string, args map[string]interface{}) (bool, error)

type Tunnel

type Tunnel struct {
	ID         int       `json:"id" db:"id"`
	AgentID    int       `json:"agent_id" db:"agent_id"`
	Hash       string    `json:"hash" db:"hash"`
	Proto      string    `json:"proto" db:"proto"`
	ExportAddr string    `json:"export_addr" db:"export_addr"`
	ServerAddr string    `json:"server_addr" db:"server_addr"`
	Status     string    `json:"status" db:"status"`
	NumConn    int       `json:"num_conn" db:"num_conn"`
	TrafficIn  int64     `json:"traffic_in" db:"traffic_in"`
	TrafficOut int64     `json:"traffic_out" db:"traffic_out"`
	CountAt    time.Time `json:"count_at" db:"count_at"`
	Enabled    bool      `json:"enabled" db:"enabled"`
	Tag        string    `json:"tag" db:"tag"`
	CreatedAt  time.Time `json:"created_at" db:"created_at"`
	UpdatedAt  time.Time `json:"updated_at" db:"updated_at"`
}

func (Tunnel) MarshalJSON

func (tunnel Tunnel) MarshalJSON() ([]byte, error)

type TunnelForJSON

type TunnelForJSON Tunnel // Use alias to avoid infinite recursive.

type User

type User struct {
	ID        int       `json:"id" db:"id"`
	Name      string    `json:"name" db:"name"`
	Password  string    `json:"password" db:"password"`
	Email     string    `json:"email" db:"email"`
	IsAdmin   bool      `json:"is_admin" db:"is_admin"`
	CreatedAt time.Time `json:"created_at" db:"created_at"`
	UpdatedAt time.Time `json:"updated_at" db:"updated_at"`
}

func (User) MarshalJSON

func (user User) MarshalJSON() ([]byte, error)

type UserForJSON

type UserForJSON User // Use alias to avoid infinite recursive.

Jump to

Keyboard shortcuts

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