rpc

package
v0.0.0-...-d9311aa Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EncryptTypeNotNeedEncrypt = 0x00
	EncryptTypeEncryptByD2Key = 0x01
	EncryptTypeEncryptByZeros = 0x02
)
View Source
const (
	FlagNoCompression   = 0x00000000
	FlagZlibCompression = 0x00000001
)
View Source
const (
	VersionDefault = 0x0000000a
	VersionSimple  = 0x0000000b
)

Variables

View Source
var (
	ErrCachedPush = errors.New("cached push")
	ErrNotHandled = errors.New("not handled")

	ErrHeartbeatTimeout = errors.New("heartbeat timeout")

	ErrWriteClosed  = errors.New("write closed")
	ErrWriteTimeout = errors.New("write timeout")
)
View Source
var (
	ContextErrorKey = struct{}{}
)

Functions

This section is empty.

Types

type Args

type Args struct {
	Version       uint32 `json:"version,omitempty"`
	Uin           int64  `json:"uin,omitempty"`
	Seq           int32  `json:"seq,omitempty"`
	ServiceMethod string `json:"service_method,omitempty"`
	ReserveField  []byte `json:"reserve_field,omitempty"`
	Payload       []byte `json:"-"`
}

type Call

type Call struct {
	ServiceMethod string
	Seq           int32
	Version       uint32
	Args          *Args
	Reply         *Reply
	Error         error
	Done          chan *Call
}

type Client

type Client interface {
	BindCancelFunc(cancel context.CancelFunc)

	DialDefault(ctx context.Context) error
	Dial(ctx context.Context, network, address string) error

	Close() error
	Go(serviceMethod string, args *Args, reply *Reply, done chan *Call) *Call
	Call(serviceMethod string, args *Args, reply *Reply) error
	Handle(serviceMethod string, reply *Reply) (*Args, error)
	Register(serviceMethod string, handler Handler) error

	GetNextSeq() int32
	GetFakeSource(uin int64) *fake.Source
	GetServerTime() int64
	GetSession(uin int64) *Session
	GetTickets(uin int64) *Tickets
	SetSession(uin int64, tlvs map[uint16]tlv.Codec)
	SetSessionAuth(uin int64, auth []byte)
	SetSessionCookie(uin int64, cookie []byte)
	SetTickets(uin int64, tlvs map[uint16]tlv.Codec)
}

type Codec

type Codec interface {
	Close() error

	ReadResponseHeader(*Response) error
	ReadResponseBody(*Reply) error
	WriteRequest(*Request, *Args) error
}

type Handler

type Handler func(reply *Reply) (*Args, error)

type Key16Bytes

type Key16Bytes [16]byte

func (*Key16Bytes) Get

func (v *Key16Bytes) Get() [16]byte

func (Key16Bytes) MarshalJSON

func (v Key16Bytes) MarshalJSON() ([]byte, error)

func (*Key16Bytes) Set

func (v *Key16Bytes) Set(b [16]byte)

func (*Key16Bytes) UnmarshalJSON

func (v *Key16Bytes) UnmarshalJSON(b []byte) error

type Reply

type Reply struct {
	Version       uint32 `json:"version,omitempty"`
	Uin           int64  `json:"uin,omitempty"`
	Seq           int32  `json:"seq,omitempty"`
	Code          int32  `json:"code,omitempty"`
	Message       string `json:"message,omitempty"`
	ServiceMethod string `json:"service_method,omitempty"`
	Cookie        []byte `json:"cookie,omitempty"`
	Flag          uint32 `json:"flag,omitempty"`
	ReserveField  []byte `json:"reserve_field,omitempty"`
	Payload       []byte `json:"-"`
}

type Request

type Request struct {
	ServiceMethod string `json:"service_method,omitempty"`
	Seq           int32  `json:"seq,omitempty"`
	Version       uint32 `json:"version,omitempty"`
	EncryptType   uint8  `json:"encrypt_type,omitempty"`
	Username      string `json:"username,omitempty"`
}

type Response

type Response struct {
	ServiceMethod string `json:"service_method,omitempty"`
	Seq           int32  `json:"seq,omitempty"`
	Version       uint32 `json:"version,omitempty"`
	EncryptType   uint8  `json:"encrypt_type,omitempty"`
	Username      string `json:"username,omitempty"`
}

type Sender

type Sender interface {
	Close() error
	Go(serviceMethod string, args *Args, reply *Reply, done chan *Call) *Call

	Run(ctx context.Context, cancel context.CancelFunc)
}

func NewSender

func NewSender(c Client, codec Codec) Sender

type Session

type Session struct {
	Auth   []byte `json:"auth,omitempty"`
	Cookie []byte `json:"cookie,omitempty"`

	RandomKey  Key16Bytes `json:"random_key,omitempty"`
	RandomPass Key16Bytes `json:"random_pass,omitempty"`

	PrivateKey   *ecdh.PrivateKey `json:"-"`
	KeyVersion   int16            `json:"key_version,omitempty"`
	SharedSecret Key16Bytes       `json:"shared_secret,omitempty"`
}

type Ticket

type Ticket struct {
	Key Key16Bytes `json:"key,omitempty"`
	Sig []byte     `json:"sig,omitempty"`
	Exp int64      `json:"exp,omitempty"`
	Iss int64      `json:"iss,omitempty"`
}

func (Ticket) Valid

func (t Ticket) Valid() bool

type Tickets

type Tickets struct {
	A1       *Ticket           `json:"a1,omitempty"`
	A2       *Ticket           `json:"a2,omitempty"`
	A5       *Ticket           `json:"a5,omitempty"`
	A8       *Ticket           `json:"a8,omitempty"`
	D2       *Ticket           `json:"d2,omitempty"`
	LSKey    *Ticket           `json:"lskey,omitempty"`
	SKey     *Ticket           `json:"skey,omitempty"`
	SID      *Ticket           `json:"sid,omitempty"`
	Sig64    *Ticket           `json:"sig64,omitempty"`
	SuperKey *Ticket           `json:"super_key,omitempty"`
	ST       *Ticket           `json:"st,omitempty"`
	STWeb    *Ticket           `json:"stweb,omitempty"`
	VKey     *Ticket           `json:"vkey,omitempty"`
	Domains  map[string]string `json:"domains,omitempty"`
	KSID     []byte            `json:"ksid,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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