node

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileType_file   uint8 = 1
	FileType_filler uint8 = 2
)

Variables

View Source
var (
	HEAD_FILE   = []byte("c100")
	HEAD_FILLER = []byte("c101")
)

Functions

func VerifyBucketName

func VerifyBucketName(name string) bool

Bucket name verification rules It can only contain numbers, lowercase letters, special characters (. -) And the length is 3-63 Must start and end with a letter or number Must not contain two adjacent points Must not be formatted as an IP address

func VerifySign

func VerifySign(pkey, signmsg, sign []byte) (bool, error)

Types

type AuthType

type AuthType struct {
	Account   string `json:"account"`
	Message   string `json:"message"`
	Signature []byte `json:"signature"`
}

type Client

type Client interface {
	SendFile(fid string, fsize int64, pkey, signmsg, sign []byte) error
	RecvFile(fid string, fsize int64, pkey, signmsg, sign []byte) error
}

func NewClient

func NewClient(conn NetConn, dir string, files []string) Client

type ConMgr

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

func (*ConMgr) RecvFile

func (c *ConMgr) RecvFile(fid string, fsize int64, pkey, signmsg, sign []byte) error

func (*ConMgr) SendFile

func (c *ConMgr) SendFile(fid string, fsize int64, pkey, signmsg, sign []byte) error

type CustomClaims

type CustomClaims struct {
	Account string `json:"account"`
	jwt.StandardClaims
}

type Message

type Message struct {
	Pubkey   []byte  `json:"pubkey"`
	SignMsg  []byte  `json:"signmsg"`
	Sign     []byte  `json:"sign"`
	Bytes    []byte  `json:"bytes"`
	FileName string  `json:"filename"`
	FileHash string  `json:"filehash"`
	FileSize uint64  `json:"filesize"`
	MsgType  MsgType `json:"msgtype"`
	LastMark bool    `json:"lastmark"`
	FileType uint8   `json:"filetype"`
}

func NewCloseMsg

func NewCloseMsg(fileName string, status Status) *Message

func NewEndMsg

func NewEndMsg(fileName, fileHash string, size, originSize uint64, lastmark bool) *Message

func NewFileMsg

func NewFileMsg(fileName string, buflen int, buf []byte) *Message

func NewHeadMsg

func NewHeadMsg(fileName string, fid string, lastmark bool, pkey, signmsg, sign []byte) *Message

func NewNotifyMsg

func NewNotifyMsg(fileName string, status Status) *Message

func NewRecvFileMsg

func NewRecvFileMsg(fid string) *Message

func NewRecvHeadMsg

func NewRecvHeadMsg(fid string, pkey, signmsg, sign []byte) *Message

type MsgType

type MsgType byte
const (
	MsgInvalid MsgType = iota
	MsgHead
	MsgFile
	MsgEnd
	MsgNotify
	MsgClose
	MsgRecvHead
	MsgRecvFile
)

type NetConn

type NetConn interface {
	HandlerLoop()
	GetMsg() (*Message, bool)
	SendMsg(m *Message)
	Close() error
	IsClose() bool
}

type Node

type Node struct {
	Confile confile.Confiler
	Chain   chain.Chainer
	Logs    logger.Logger
	Cache   db.Cacher
	Handle  *gin.Engine
	FileDir string
}

func New

func New() *Node

New is used to build a node instance

func (*Node) GetHandle

func (n *Node) GetHandle(c *gin.Context)

It is used to authorize users

func (*Node) Run

func (n *Node) Run()

type Notify

type Notify struct {
	Status byte
}

type Oss

type Oss interface {
	Run()
}

type RtnBlockInfo

type RtnBlockInfo struct {
	MinerId  uint64
	BlockId  string
	MinerIp  string
	MinerAcc string
}

file block info

type RtnFileType

type RtnFileType struct {
	FileSize   uint64
	FileState  string
	UserBriefs []RtnUserBrief
	BlockInfo  []RtnBlockInfo
}

type RtnUserBrief

type RtnUserBrief struct {
	User       string
	FileName   string
	BucketName string
}

type Status

type Status byte
const (
	Status_Ok Status = iota
	Status_Err
)

type TcpCon

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

func NewTcp

func NewTcp(conn *net.TCPConn) *TcpCon

func (*TcpCon) Close

func (t *TcpCon) Close() error

func (*TcpCon) GetMsg

func (t *TcpCon) GetMsg() (*Message, bool)

func (*TcpCon) HandlerLoop

func (t *TcpCon) HandlerLoop()

func (*TcpCon) IsClose

func (t *TcpCon) IsClose() bool

func (*TcpCon) SendMsg

func (t *TcpCon) SendMsg(m *Message)

Jump to

Keyboard shortcuts

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