uc

package
v0.0.0-...-a9387a1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAuthToken = logex.Define("invalid auth token")
)
View Source
var (
	ErrUserNotFound = logex.Define("user not found")
)

Functions

func GenToken

func GenToken() string

Types

type AuthData

type AuthData struct {
	UserName string
	Passcode []byte
}

type AuthRequest

type AuthRequest struct {
	UserName string `json:"username"`
	Token    []byte `json:"token"`
	IV       []byte `json:"iv"`
}

Token = aes_256_cfb(md5(pswd) + ":" + timestamp, key, iv) key = specified key by config iv = base64(rand(16))

func NewAuthRequest

func NewAuthRequest(userName string, timestamp int64, passcode, key []byte) *AuthRequest

passcode: sha1(password + salt)

func (*AuthRequest) Decode

func (a *AuthRequest) Decode(key []byte, nowTime int64) (*AuthData, error)

type AuthResponse

type AuthResponse struct {
	Gateway     string `json:"gateway"`
	UserId      int    `json:"userId"`
	MTU         int    `json:"mtu"`
	INet        string `json:"inet"`
	Token       string `json:"token"`
	DataChannel int    `json:"datachannel"`
	ChannelType string `json:"channeltype"`
}

type User

type User struct {
	*UserInfo
	Net   *ip.IP
	Token string
	// contains filtered or unexported fields
}

func NewUser

func NewUser(ui *UserInfo) *User

func (*User) GetFromController

func (u *User) GetFromController() (
	fromUser packet.RecvChan, toUser packet.SendChan)

func (*User) GetFromDataChannel

func (u *User) GetFromDataChannel() (
	fromUser packet.RecvChan, toUser packet.SendChan)

func (*User) GobDecode

func (u *User) GobDecode(data []byte) error

directly encode UserInfo to ignore other temporary variables

func (*User) GobEncode

func (u *User) GobEncode() ([]byte, error)

func (*User) IsOnline

func (u *User) IsOnline() bool

func (User) String

func (u User) String() string

type UserInfo

type UserInfo struct {
	Id       uint16
	Name     string
	Password string
	IsAdmin  bool
}

type Users

type Users struct {
	// contains filtered or unexported fields
}

func NewUsers

func NewUsers() *Users

func (*Users) AddUser

func (us *Users) AddUser(ui *UserInfo) *User

func (*Users) Find

func (us *Users) Find(username string) *User

func (*Users) FindByIP

func (us *Users) FindByIP(addr ip.IP) *User

func (*Users) FindId

func (us *Users) FindId(id int) *User

func (*Users) Load

func (u *Users) Load(fp string) error

func (*Users) Login

func (us *Users) Login(userId int, pswd string) *User

func (*Users) LoginByName

func (us *Users) LoginByName(name string, pswd string) *User

func (*Users) Register

func (us *Users) Register(name string, pswd string) *User

func (*Users) Save

func (u *Users) Save(fp string) error

func (*Users) Show

func (us *Users) Show() []User

Jump to

Keyboard shortcuts

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