bmprotocol

package
v0.0.0-...-56464ea Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2020 License: GPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PullMail int = iota + 1
	PullGroup
)
View Source
const (
	PeerUnreachable int = iota + 1
	AddressUnavailable
)
View Source
const (
	ErrMsg_PeerUnreachable    string = "Peer is unreachable"
	ErrMsg_AddressUnavailable string = "Recipient is not available"
)

Variables

This section is empty.

Functions

func AddPackHead

func AddPackHead(bmtl *translayer.BMTransLayer, appendData []byte) ([]byte, error)

func GetNowMsTime

func GetNowMsTime() int64

func NewHeadBuf

func NewHeadBuf() []byte

func PackLongBytes

func PackLongBytes(data []byte) ([]byte, error)

func PackLongString

func PackLongString(s string) ([]byte, error)

func PackLongStringArray

func PackLongStringArray(arrs []string) ([]byte, error)

func PackShortBytes

func PackShortBytes(data []byte) ([]byte, error)

func PackShortBytesArray

func PackShortBytesArray(arrs [][]byte) ([]byte, error)

func PackShortString

func PackShortString(s string) ([]byte, error)

func PackShortStringArray

func PackShortStringArray(arrs []string) ([]byte, error)

func RegAesDecrypt

func RegAesDecrypt(dec func(cipherText, key []byte) (iv []byte, plainBytes []byte))

func RegAesEncrypt

func RegAesEncrypt(enc func(plainBytes, iv, key []byte) []byte)

func UnPackLongBytes

func UnPackLongBytes(data []byte) ([]byte, int, error)

func UnPackLongString

func UnPackLongString(data []byte) (string, int, error)

func UnPackLongStringArray

func UnPackLongStringArray(data []byte) ([]string, int, error)

func UnPackShortBytes

func UnPackShortBytes(data []byte) ([]byte, int, error)

func UnPackShortBytesArray

func UnPackShortBytesArray(data []byte) ([][]byte, int, error)

func UnPackShortString

func UnPackShortString(data []byte) (string, int, error)

func UnPackShortStringArray

func UnPackShortStringArray(data []byte) ([]string, int, error)

Types

type Attachment

type Attachment struct {
	Path string //if less 30MB, path is none,
	FileProperty
}

func (*Attachment) Pack

func (a *Attachment) Pack() ([]byte, error)

func (*Attachment) String

func (a *Attachment) String() string

func (*Attachment) UnPack

func (a *Attachment) UnPack(data []byte) (int, error)

type BMHello

type BMHello struct {
	translayer.BMTransLayer
}

func NewBMHello

func NewBMHello() *BMHello

func (*BMHello) Pack

func (bmh *BMHello) Pack() ([]byte, error)

func (*BMHello) String

func (bmh *BMHello) String() string

func (*BMHello) UnPack

func (bmh *BMHello) UnPack(data []byte) (int, error)

type BMHelloACK

type BMHelloACK struct {
	translayer.BMTransLayer
	// contains filtered or unexported fields
}

func NewBMHelloACK

func NewBMHelloACK(sn []byte) *BMHelloACK

func (*BMHelloACK) GetSn

func (bmha *BMHelloACK) GetSn() []byte

func (*BMHelloACK) Pack

func (bmha *BMHelloACK) Pack() ([]byte, error)

func (*BMHelloACK) String

func (bmha *BMHelloACK) String() string

func (*BMHelloACK) UnPack

func (bmha *BMHelloACK) UnPack(data []byte) (int, error)

type BMailAddrss

type BMailAddrss struct {
	MailAddress string
	Alias       string
	Desc        string
	Phone       Cell
	GroupId     Gid
}

func (*BMailAddrss) Pack

func (bma *BMailAddrss) Pack() ([]byte, error)

func (*BMailAddrss) UnPack

func (bma *BMailAddrss) UnPack(data []byte) (int, error)

type BPOPDelete

type BPOPDelete struct {
	translayer.BMTransLayer
	Section []DelSection
	Sn      []byte
	Sig     []byte
}

func NewBPOPDelete

func NewBPOPDelete() *BPOPDelete

func (*BPOPDelete) Pack

func (bd *BPOPDelete) Pack() ([]byte, error)

func (*BPOPDelete) String

func (bd *BPOPDelete) String() string

func (*BPOPDelete) UnPack

func (bd *BPOPDelete) UnPack(data []byte) (int, error)

type BPOPDeleteResp

type BPOPDeleteResp struct {
	translayer.BMTransLayer
	Result []DelSectionResult
	Sn     []byte
}

func NewBPOPDeleteResp

func NewBPOPDeleteResp() *BPOPDeleteResp

func (*BPOPDeleteResp) Pack

func (bd *BPOPDeleteResp) Pack() ([]byte, error)

func (*BPOPDeleteResp) String

func (br *BPOPDeleteResp) String() string

func (*BPOPDeleteResp) UnPack

func (bd *BPOPDeleteResp) UnPack(data []byte) (int, error)

type BPOPList

type BPOPList struct {
	translayer.BMTransLayer
	BeginID   int
	ListCount int
}

func NewBPOPList

func NewBPOPList() *BPOPList

func (*BPOPList) Pack

func (bl *BPOPList) Pack() ([]byte, error)

func (*BPOPList) String

func (bl *BPOPList) String() string

func (*BPOPList) UnPack

func (bl *BPOPList) UnPack(data []byte) (int, error)

type BPOPListResp

type BPOPListResp struct {
	translayer.BMTransLayer
	BeginID   int
	ListCount int
	Nodes     []*ListNode
}

func NewBPOPListResp

func NewBPOPListResp() *BPOPListResp

func (*BPOPListResp) Pack

func (bl *BPOPListResp) Pack() ([]byte, error)

func (*BPOPListResp) String

func (bl *BPOPListResp) String() string

func (*BPOPListResp) UnPack

func (bl *BPOPListResp) UnPack(data []byte) (int, error)

type BPOPRetr

type BPOPRetr struct {
	translayer.BMTransLayer
	BeginID   int
	RetrCount int
}

func NewBPOPRetr

func NewBPOPRetr() *BPOPRetr

func (*BPOPRetr) Pack

func (br *BPOPRetr) Pack() ([]byte, error)

func (*BPOPRetr) String

func (br *BPOPRetr) String() string

func (*BPOPRetr) UnPack

func (br *BPOPRetr) UnPack(data []byte) (int, error)

type BPOPRetrResp

type BPOPRetrResp struct {
	translayer.BMTransLayer
	Mails      []CryptEnvelope
	BeginID    int
	RetrCount  int
	TotalCount int
}

func NewBPOPRetrResp

func NewBPOPRetrResp() *BPOPRetrResp

func (*BPOPRetrResp) Pack

func (br *BPOPRetrResp) Pack() ([]byte, error)

func (*BPOPRetrResp) String

func (br *BPOPRetrResp) String() string

func (*BPOPRetrResp) UnPack

func (br *BPOPRetrResp) UnPack(data []byte) (int, error)

type BPOPStat

type BPOPStat struct {
	translayer.BMTransLayer
}

func NewBPOPStat

func NewBPOPStat() *BPOPStat

func (*BPOPStat) Pack

func (bps *BPOPStat) Pack() ([]byte, error)

func (*BPOPStat) UnPack

func (bps *BPOPStat) UnPack(data []byte) (int, error)

type BPOPStatResp

type BPOPStatResp struct {
	translayer.BMTransLayer
	Total            int
	Received         int
	TotalStoredBytes int64
	TotalSpaceBytes  int64
}

func NewBPOPStatResp

func NewBPOPStatResp() *BPOPStatResp

func (*BPOPStatResp) Pack

func (br *BPOPStatResp) Pack() ([]byte, error)

func (*BPOPStatResp) String

func (bs *BPOPStatResp) String() string

func (*BPOPStatResp) UnPack

func (br *BPOPStatResp) UnPack(data []byte) (int, error)

type Cell

type Cell struct {
	PhoneNum  string
	PhoneType string
}

func (*Cell) Pack

func (c *Cell) Pack() ([]byte, error)

func (*Cell) UnPack

func (c *Cell) UnPack(data []byte) (int, error)

type ConfirmEnvelope

type ConfirmEnvelope struct {
	Sn         []byte
	NewSn      []byte
	EId        translayer.EnveUniqID
	CxtHashSig []byte
	ErrId      int
}

func (*ConfirmEnvelope) Pack

func (ce *ConfirmEnvelope) Pack() ([]byte, error)

func (*ConfirmEnvelope) String

func (ce *ConfirmEnvelope) String() string

func (*ConfirmEnvelope) UnPack

func (ce *ConfirmEnvelope) UnPack(data []byte) (int, error)

type ContactAdd

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

client remote add===>IV,sig{sn(from server)},sn(from server),cipher text{mail list,group list} ==>server

func (*ContactAdd) Pack

func (ca *ContactAdd) Pack() ([]byte, error)

func (*ContactAdd) UnPack

func (ca *ContactAdd) UnPack(data []byte) (int, error)

type ContactAddResp

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

server response remote add ===> IV,cipher text{sn(old),sn(new from server)},error code===>client

func (*ContactAddResp) Pack

func (car *ContactAddResp) Pack() ([]byte, error)

type ContactDel

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

client remote del===>sig{sn},IV,cipher text{mail list,group list} ==>server

type ContactDelResp

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

server response remote del ===> IV,cipher text{sn(old),sn(new from server)},error code===client

type ContactHello

type ContactHello struct {
	SelfMA string
	// contains filtered or unexported fields
}

func NewContactHello

func NewContactHello() *ContactHello

func (*ContactHello) GetSn

func (mabh *ContactHello) GetSn() SN

func (*ContactHello) Pack

func (mabh *ContactHello) Pack() ([]byte, error)

func (*ContactHello) String

func (mabh *ContactHello) String() string

func (*ContactHello) UnPack

func (mabh *ContactHello) UnPack(data []byte) (int, error)

type ContactHelloResp

type ContactHelloResp struct {
	translayer.BMTransLayer
	// contains filtered or unexported fields
}

server response hello ===IV,sig{sn(from client)},sn(from server) ==>client

func NewContactHelloResp

func NewContactHelloResp() *ContactHelloResp

func (*ContactHelloResp) GetIV

func (mr *ContactHelloResp) GetIV() IV

func (*ContactHelloResp) Pack

func (mr *ContactHelloResp) Pack() ([]byte, error)

func (*ContactHelloResp) SetClientSN

func (mr *ContactHelloResp) SetClientSN(sn SN)

func (*ContactHelloResp) SetSigClientSn

func (mr *ContactHelloResp) SetSigClientSn(sig []byte)

func (*ContactHelloResp) String

func (mr *ContactHelloResp) String() string

func (*ContactHelloResp) UnPack

func (mr *ContactHelloResp) UnPack(data []byte) (int, error)

type ContactPull

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

client pull mail list or group list ===>sig{sn(from server)},IV,cipher text{command(pull mail list or pull all or pull group)} ==server

type ContactPullResp

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

server response pull ===>IV,cipher text{mail list,group list,sn(old),sn(new from server)}

type CryptContactAdd

type CryptContactAdd struct {
	translayer.BMTransLayer
	// contains filtered or unexported fields
}

func NewCryptContactAdd

func NewCryptContactAdd() *CryptContactAdd

func (*CryptContactAdd) Pack

func (cca *CryptContactAdd) Pack() ([]byte, error)

func (*CryptContactAdd) SetCipherTxt

func (cca *CryptContactAdd) SetCipherTxt(ct []byte)

func (*CryptContactAdd) SetIV

func (cca *CryptContactAdd) SetIV(iv IV)

func (*CryptContactAdd) SetServerSn

func (cca *CryptContactAdd) SetServerSn(sn SN)

func (*CryptContactAdd) SetSigServerSn

func (cca *CryptContactAdd) SetSigServerSn(sig []byte)

func (*CryptContactAdd) UnPack

func (cca *CryptContactAdd) UnPack(data []byte) (int, error)

type CryptContactAddResp

type CryptContactAddResp struct {
	translayer.BMTransLayer
	// contains filtered or unexported fields
}

type CryptContactDel

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

type CryptContactDelResp

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

type CryptContactHello

type CryptContactHello struct {
	translayer.BMTransLayer
	// contains filtered or unexported fields
}

client hello

func NewCryptContactHello

func NewCryptContactHello() *CryptContactHello

func (*CryptContactHello) GetIV

func (cm *CryptContactHello) GetIV() IV

func (*CryptContactHello) Pack

func (cm *CryptContactHello) Pack() ([]byte, error)

func (*CryptContactHello) SetCipherText

func (cm *CryptContactHello) SetCipherText(ct []byte)

func (*CryptContactHello) String

func (cm *CryptContactHello) String() string

func (*CryptContactHello) UnPack

func (cm *CryptContactHello) UnPack(data []byte) (int, error)

type CryptContactPull

type CryptContactPull struct {
	translayer.BMTransLayer
	// contains filtered or unexported fields
}

type CryptContactPullResp

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

type CryptEnvelope

type CryptEnvelope struct {
	EnvelopeSig
	EnvelopeRoute
	EnvelopeCryptDesc
	CipherTxt []byte
}

func EncodeEnvelope

func EncodeEnvelope(e *Envelope, key []byte) *CryptEnvelope

func (*CryptEnvelope) Pack

func (ce *CryptEnvelope) Pack() ([]byte, error)

func (*CryptEnvelope) String

func (ce *CryptEnvelope) String() string

func (*CryptEnvelope) UnPack

func (ce *CryptEnvelope) UnPack(data []byte) (int, error)

type DelSection

type DelSection struct {
	Begin int
	End   int
}

func (*DelSection) Pack

func (ds *DelSection) Pack() ([]byte, error)

func (*DelSection) String

func (ds *DelSection) String() string

func (*DelSection) UnPack

func (ds *DelSection) UnPack(data []byte) (int, error)

type DelSectionResult

type DelSectionResult struct {
	DelSection
	ErroCode int //0 success,1 failure
}

func (*DelSectionResult) Pack

func (dsr *DelSectionResult) Pack() ([]byte, error)

func (*DelSectionResult) String

func (dsr *DelSectionResult) String() string

func (*DelSectionResult) UnPack

func (dsr *DelSectionResult) UnPack(data []byte) (int, error)

type Envelope

func DeCodeEnvelope

func DeCodeEnvelope(ce *CryptEnvelope, key []byte) *Envelope

func (*Envelope) ForCrypt

func (e *Envelope) ForCrypt() ([]byte, error)

func (*Envelope) Pack

func (e *Envelope) Pack() ([]byte, error)

func (*Envelope) String

func (e *Envelope) String() string

func (*Envelope) UnPack

func (e *Envelope) UnPack(data []byte) (int, error)

type EnvelopeContent

type EnvelopeContent struct {
	To      []string
	CC      []string
	BC      []string
	Subject string
	Data    string
	Files   []Attachment
}

func (*EnvelopeContent) Pack

func (ec *EnvelopeContent) Pack() ([]byte, error)

func (*EnvelopeContent) String

func (ec *EnvelopeContent) String() string

func (*EnvelopeContent) UnPack

func (ec *EnvelopeContent) UnPack(data []byte) (int, error)

type EnvelopeCryptDesc

type EnvelopeCryptDesc struct {
	Mode    int //ps, pp, psp, pssp
	Pubkeys [][]byte
}

func (*EnvelopeCryptDesc) CopyTo

func (*EnvelopeCryptDesc) Pack

func (ecd *EnvelopeCryptDesc) Pack() ([]byte, error)

func (*EnvelopeCryptDesc) String

func (ecd *EnvelopeCryptDesc) String() string

func (*EnvelopeCryptDesc) UnPack

func (ecd *EnvelopeCryptDesc) UnPack(data []byte) (int, error)

type EnvelopeRoute

type EnvelopeRoute struct {
	From         string
	RecpAddr     string                //recipient
	RecpAddrType int                   //0 to,1 cc,2 bc
	EId          translayer.EnveUniqID //envelope unique id
}

func (*EnvelopeRoute) CopyTo

func (eh *EnvelopeRoute) CopyTo(to *EnvelopeRoute) *EnvelopeRoute

func (*EnvelopeRoute) Pack

func (eh *EnvelopeRoute) Pack() ([]byte, error)

func (*EnvelopeRoute) String

func (eh *EnvelopeRoute) String() string

func (*EnvelopeRoute) UnPack

func (eh *EnvelopeRoute) UnPack(data []byte) (int, error)

type EnvelopeSig

type EnvelopeSig struct {
	Sn  []byte `json:"sn"`
	Sig []byte `json:"sig"`
}

func (*EnvelopeSig) CopyTo

func (es *EnvelopeSig) CopyTo(to *EnvelopeSig) *EnvelopeSig

func (*EnvelopeSig) Pack

func (ee *EnvelopeSig) Pack() ([]byte, error)

func (*EnvelopeSig) String

func (et *EnvelopeSig) String() string

func (*EnvelopeSig) UnPack

func (ee *EnvelopeSig) UnPack(data []byte) (int, error)

type FileProperty

type FileProperty struct {
	Hash      []byte
	FileName  string
	FileType  int
	IsEnCrypt bool
	FileSize  int
}

func (*FileProperty) Pack

func (fp *FileProperty) Pack() ([]byte, error)

func (*FileProperty) String

func (fp *FileProperty) String() string

func (*FileProperty) UnPack

func (fp *FileProperty) UnPack(data []byte) (int, error)

type Gid

type Gid [32]byte

type GroupDesc

type GroupDesc struct {
	GroupId   Gid
	GroupType int //0 private,1 public in group, 2 public in mail domain, 3 public to all but no mail list
	GroupName string
}

func (*GroupDesc) Pack

func (gd *GroupDesc) Pack() ([]byte, error)

func (*GroupDesc) UnPack

func (gd *GroupDesc) UnPack(data []byte) (int, error)

type IV

type IV [16]byte

type ListNode

type ListNode struct {
	ID          int
	SizeOfBytes int
}

func (*ListNode) Pack

func (ln *ListNode) Pack() ([]byte, error)

func (*ListNode) String

func (ln *ListNode) String() string

func (*ListNode) UnPack

func (ln *ListNode) UnPack(data []byte) (int, error)

type RespSendAttachment

type RespSendAttachment struct {
	translayer.BMTransLayer
	FileProperty
	Sn    []byte
	NewSn []byte
	EId   translayer.EnveUniqID
	ErrId int
}

func NewRespSendAttachment

func NewRespSendAttachment() *RespSendAttachment

func (*RespSendAttachment) Pack

func (rsa *RespSendAttachment) Pack() ([]byte, error)

func (*RespSendAttachment) String

func (rsa *RespSendAttachment) String() string

func (*RespSendAttachment) UnPack

func (rsa *RespSendAttachment) UnPack(data []byte) (int, error)

type RespSendCryptEnvelope

type RespSendCryptEnvelope struct {
	translayer.BMTransLayer
	ConfirmEnvelope
}

ErrId: 0: success 1: Receipt Address not found 2: Receipt Address is forbidden 3: Data is forbidden 4: bmail command Not Found 5: Mail to large 6: Mail refused by server 7: Connect to Server failed

server -> client

func NewRespSendCryptEnvelope

func NewRespSendCryptEnvelope() *RespSendCryptEnvelope

func (*RespSendCryptEnvelope) Pack

func (rse *RespSendCryptEnvelope) Pack() ([]byte, error)

func (*RespSendCryptEnvelope) String

func (rse *RespSendCryptEnvelope) String() string

func (*RespSendCryptEnvelope) UnPack

func (rse *RespSendCryptEnvelope) UnPack(data []byte) (int, error)

type RespSendEnvelope

type RespSendEnvelope struct {
	translayer.BMTransLayer
	ConfirmEnvelope
}

server -> client

func NewRespSendEnvelope

func NewRespSendEnvelope() *RespSendEnvelope

func (*RespSendEnvelope) Pack

func (rse *RespSendEnvelope) Pack() ([]byte, error)

func (*RespSendEnvelope) String

func (rse *RespSendEnvelope) String() string

func (*RespSendEnvelope) UnPack

func (rse *RespSendEnvelope) UnPack(data []byte) (int, error)

type SAReader

type SAReader struct {
	Reader io.Reader
	// contains filtered or unexported fields
}

func (*SAReader) GetTotalSize

func (sar *SAReader) GetTotalSize() int

func (*SAReader) Read

func (sar *SAReader) Read(p []byte) (n int, err error)

type SN

type SN [16]byte

type SendAttachment

type SendAttachment struct {
	translayer.BMTransLayer
	FileProperty
	EnvelopeSig
	EId  translayer.EnveUniqID
	File *os.File
}

func NewSendAttachment

func NewSendAttachment() *SendAttachment

func (*SendAttachment) GetReader

func (sa *SendAttachment) GetReader() (*SAReader, error)

func (*SendAttachment) String

func (sa *SendAttachment) String() string

type SendCryptEnvelope

type SendCryptEnvelope struct {
	translayer.BMTransLayer
	CryptEnvelope
}

client -> server

func NewSendCryptEnvelope

func NewSendCryptEnvelope() *SendCryptEnvelope

func (*SendCryptEnvelope) Pack

func (se *SendCryptEnvelope) Pack() ([]byte, error)

func (*SendCryptEnvelope) String

func (se *SendCryptEnvelope) String() string

func (*SendCryptEnvelope) UnPack

func (se *SendCryptEnvelope) UnPack(data []byte) (int, error)

type SendEnvelope

type SendEnvelope struct {
	translayer.BMTransLayer
	Envelope
}

func NewSendEnvelope

func NewSendEnvelope() *SendEnvelope

func (*SendEnvelope) Pack

func (se *SendEnvelope) Pack() ([]byte, error)

func (*SendEnvelope) String

func (se *SendEnvelope) String() string

func (*SendEnvelope) UnPack

func (se *SendEnvelope) UnPack(data []byte) (int, error)

Jump to

Keyboard shortcuts

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