client

package
v0.0.0-...-5bdf5b5 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	ID        int64     `xorm:"pk autoincr"`                                                   //`json:"id" gorm:"primaryKey; autoIncrement:true"`
	Name      string    `xorm:"varchar(16) not null unique 'client_name' comment('NickName')"` //`json:"name" gorm:"not null; unique"`
	PWD       string    `xorm:"varchar(32) not null 'client_pwd'"`                             //`json:"-" gorm:"password"`
	Status    Status    `xorm:"smallint not null 'client_status'"`                             //`json:"status" gorm:"status"`
	CreatedAt time.Time `xorm:"created"`                                                       //`json:"created_at" gorm:"created_at"`
	UpdatedAt time.Time `xorm:"updated"`                                                       //`json:"updated_at" gorm:"updated_at"`
	Creds     []string  //`json:"-" gorm:"credentials"`
	// contains filtered or unexported fields
}

A Client represents some client in the system

func (*Client) ClientStatus

func (client *Client) ClientStatus() Status

ClientStatus returns the client status

func (*Client) GetAddr

func (client *Client) GetAddr() string

GetAddr returns the client addr

func (*Client) GetID

func (client *Client) GetID() int64

GetID returns the client addr

func (*Client) MatchPassword

func (client *Client) MatchPassword(pwd string) bool

MatchPassword returns true if, and only if, the provided hash do match with the pqssword's one

func (*Client) SetExtension

func (client *Client) SetExtension(ext Extension) bool

SetExtension sets an extension to the client

type Controller

type Controller interface {
	ClientStatus() Status
	MatchPassword(string) bool
	GetAddr() string
	GetID() int64
	SetExtension(Extension) bool
}

A Controller represents a registered client

func New

func New(name, pwd string) Controller

New builds a brand new client with a provided password

type Extension

type Extension interface {
	GetAddr() string
}

Extension represents a client extension

type Status

type Status int

Status represents the Status enum

const (
	PENDING Status = iota
	ACTIVATED
	DEACTIVATED
)

Status possible values

func (Status) String

func (s Status) String() string

Jump to

Keyboard shortcuts

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