client

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SecIdentMaxPubKeyLen = 512
	SecIdentMaxSigLen    = 512
)
View Source
const MaxFileCommentLen = 128
View Source
const MaxPreviewBytes = 256 * 1024
View Source
const SourceExchange2Version byte = 4

SourceExchange2Version 为当前实现的 SX2 载荷版本(与 aMule SOURCEEXCHANGE2_VERSION 一致)。

View Source
const SourceExchangeIPv6Version byte = 5

SourceExchangeIPv6Version 为 goed2k 扩展的 IPv6 来源交换版本(v4 条目后追加 16 字节 IPv6)。

Variables

This section is empty.

Functions

func MultiPacketOpcode added in v0.1.3

func MultiPacketOpcode() byte

MultiPacketOpcode 返回 OP_MULTIPACKET_EXT2 操作码(供连接层识别)。

func NewPacketCombiner

func NewPacketCombiner() protocol.PacketCombiner

func PackMultiPacketExt2 added in v0.1.3

func PackMultiPacketExt2(frames [][]byte) ([]byte, error)

PackMultiPacketExt2 将多条已编码的 eMule TCP 帧 zlib 压缩后以 OP_MULTIPACKET_EXT2 (0xA9) 发出。

func SwapUint32

func SwapUint32(x uint32) uint32

SwapUint32 与 aMule wxUINT32_SWAP_ALWAYS 一致,用于 UserID 混合编码与旧版 SX1 兼容。

func UnpackMultiPacketExt2 added in v0.1.3

func UnpackMultiPacketExt2(payload []byte) ([][]byte, error)

UnpackMultiPacketExt2 解压 MultiPacket 载荷,返回内部原始 TCP 帧列表。

Types

type AICHAnswer added in v0.1.0

type AICHAnswer struct {
	Hash   protocol.Hash
	Hashes []protocol.AICHHash
	Data   []byte
}

func (AICHAnswer) BytesCount added in v0.1.0

func (a AICHAnswer) BytesCount() int

func (*AICHAnswer) Get added in v0.1.0

func (a *AICHAnswer) Get(src *bytes.Reader) error

func (AICHAnswer) Put added in v0.1.0

func (a AICHAnswer) Put(dst *bytes.Buffer) error

type AICHFileHashAnswer added in v0.1.0

type AICHFileHashAnswer struct {
	Hash     protocol.Hash
	RootHash protocol.AICHHash
}

AICHFileHashAnswer returns the file-level AICH root hash (deprecated in eMule).

func (AICHFileHashAnswer) BytesCount added in v0.1.0

func (a AICHFileHashAnswer) BytesCount() int

func (*AICHFileHashAnswer) Get added in v0.1.0

func (a *AICHFileHashAnswer) Get(src *bytes.Reader) error

func (AICHFileHashAnswer) Put added in v0.1.0

func (a AICHFileHashAnswer) Put(dst *bytes.Buffer) error

type AICHFileHashRequest added in v0.1.0

type AICHFileHashRequest struct {
	Hash protocol.Hash
}

AICHFileHashRequest asks for the file-level AICH root hash (deprecated in eMule).

func (AICHFileHashRequest) BytesCount added in v0.1.0

func (a AICHFileHashRequest) BytesCount() int

func (*AICHFileHashRequest) Get added in v0.1.0

func (a *AICHFileHashRequest) Get(src *bytes.Reader) error

func (AICHFileHashRequest) Put added in v0.1.0

func (a AICHFileHashRequest) Put(dst *bytes.Buffer) error

type AICHRequest added in v0.1.0

type AICHRequest struct {
	Hash   protocol.Hash
	Hashes []protocol.AICHHash
}

func (AICHRequest) BytesCount added in v0.1.0

func (a AICHRequest) BytesCount() int

func (*AICHRequest) Get added in v0.1.0

func (a *AICHRequest) Get(src *bytes.Reader) error

func (AICHRequest) Put added in v0.1.0

func (a AICHRequest) Put(dst *bytes.Buffer) error

type AcceptUpload

type AcceptUpload struct {
	protocol.WithoutDataPacket
}

type AnswerSources added in v0.1.3

type AnswerSources struct {
	Hash    protocol.Hash
	Entries []SourceExchangeEntry
}

AnswerSources(SX1):OP_EMULEPROT OP_ANSWERSOURCES (0x82)。 顺序:16 字节 hash + uint16 数量 + 每条目 12 字节(UserID、TCPPort、ServerIP、ServerPort)。

func (AnswerSources) BytesCount added in v0.1.3

func (a AnswerSources) BytesCount() int

func (*AnswerSources) Get added in v0.1.3

func (a *AnswerSources) Get(src *bytes.Reader) error

func (AnswerSources) Put added in v0.1.3

func (a AnswerSources) Put(dst *bytes.Buffer) error

type AnswerSources2

type AnswerSources2 struct {
	Version byte
	Hash    protocol.Hash
	Entries []SourceExchangeEntry
}

AnswerSources2:OP_EMULEPROT OP_ANSWERSOURCES2 载荷。 顺序:uint8 版本 + 16 字节 hash + uint16 来源数量 + 每条目(版本依赖,见 Get)。

func (AnswerSources2) BytesCount

func (a AnswerSources2) BytesCount() int

func (*AnswerSources2) Get

func (a *AnswerSources2) Get(src *bytes.Reader) error

func (AnswerSources2) Put

func (a AnswerSources2) Put(dst *bytes.Buffer) error

type CancelTransfer

type CancelTransfer struct {
	protocol.WithoutDataPacket
}

type CompressedPart32

type CompressedPart32 struct {
	Hash             protocol.Hash
	BeginOffset      uint32
	CompressedLength uint32
}

func (CompressedPart32) BytesCount

func (c CompressedPart32) BytesCount() int

func (*CompressedPart32) Get

func (c *CompressedPart32) Get(src *bytes.Reader) error

func (CompressedPart32) PayloadSize

func (c CompressedPart32) PayloadSize() int

func (CompressedPart32) Put

func (c CompressedPart32) Put(dst *bytes.Buffer) error

type CompressedPart64

type CompressedPart64 struct {
	Hash             protocol.Hash
	BeginOffset      uint64
	CompressedLength uint32
}

func (CompressedPart64) BytesCount

func (c CompressedPart64) BytesCount() int

func (*CompressedPart64) Get

func (c *CompressedPart64) Get(src *bytes.Reader) error

func (CompressedPart64) PayloadSize

func (c CompressedPart64) PayloadSize() int

func (CompressedPart64) Put

func (c CompressedPart64) Put(dst *bytes.Buffer) error

type ExtHello

type ExtHello struct {
	ExtendedHandshake
}

type ExtHelloAnswer

type ExtHelloAnswer struct {
	ExtendedHandshake
}

type ExtendedHandshake

type ExtendedHandshake struct {
	Version         byte
	ProtocolVersion byte
	Properties      protocol.TagList
}

func (ExtendedHandshake) BytesCount

func (e ExtendedHandshake) BytesCount() int

func (*ExtendedHandshake) Get

func (e *ExtendedHandshake) Get(src *bytes.Reader) error

func (ExtendedHandshake) Put

func (e ExtendedHandshake) Put(dst *bytes.Buffer) error

type FileAnswer

type FileAnswer struct {
	Hash protocol.Hash
	Name protocol.ByteContainer16
}

func (FileAnswer) BytesCount

func (f FileAnswer) BytesCount() int

func (*FileAnswer) Get

func (f *FileAnswer) Get(src *bytes.Reader) error

func (FileAnswer) Put

func (f FileAnswer) Put(dst *bytes.Buffer) error

type FileComment added in v0.1.0

type FileComment struct {
	Rating  byte
	Comment []byte
}

FileComment carries a peer file rating and comment (OP_FILEDESC / 0x61).

func (FileComment) BytesCount added in v0.1.0

func (f FileComment) BytesCount() int

func (*FileComment) Get added in v0.1.0

func (f *FileComment) Get(src *bytes.Reader) error

func (FileComment) Put added in v0.1.0

func (f FileComment) Put(dst *bytes.Buffer) error

type FileRequest

type FileRequest struct {
	Hash protocol.Hash
}

func (FileRequest) BytesCount

func (f FileRequest) BytesCount() int

func (*FileRequest) Get

func (f *FileRequest) Get(src *bytes.Reader) error

func (FileRequest) Put

func (f FileRequest) Put(dst *bytes.Buffer) error

type FileStatusAnswer

type FileStatusAnswer struct {
	Hash     protocol.Hash
	BitField protocol.BitField
}

func (FileStatusAnswer) BytesCount

func (f FileStatusAnswer) BytesCount() int

func (*FileStatusAnswer) Get

func (f *FileStatusAnswer) Get(src *bytes.Reader) error

func (FileStatusAnswer) Put

func (f FileStatusAnswer) Put(dst *bytes.Buffer) error

type FileStatusRequest

type FileStatusRequest struct {
	Hash protocol.Hash
}

func (FileStatusRequest) BytesCount

func (f FileStatusRequest) BytesCount() int

func (*FileStatusRequest) Get

func (f *FileStatusRequest) Get(src *bytes.Reader) error

func (FileStatusRequest) Put

func (f FileStatusRequest) Put(dst *bytes.Buffer) error

type HashSetAnswer

type HashSetAnswer struct {
	Hash  protocol.Hash
	Parts []protocol.Hash
}

func (HashSetAnswer) BytesCount

func (h HashSetAnswer) BytesCount() int

func (*HashSetAnswer) Get

func (h *HashSetAnswer) Get(src *bytes.Reader) error

func (HashSetAnswer) Put

func (h HashSetAnswer) Put(dst *bytes.Buffer) error

type HashSetRequest

type HashSetRequest struct {
	Hash protocol.Hash
}

func (HashSetRequest) BytesCount

func (h HashSetRequest) BytesCount() int

func (*HashSetRequest) Get

func (h *HashSetRequest) Get(src *bytes.Reader) error

func (HashSetRequest) Put

func (h HashSetRequest) Put(dst *bytes.Buffer) error

type Hello

type Hello struct {
	HashLength byte
	HelloAnswer
}

func (Hello) BytesCount

func (h Hello) BytesCount() int

func (*Hello) Get

func (h *Hello) Get(src *bytes.Reader) error

func (Hello) Put

func (h Hello) Put(dst *bytes.Buffer) error

type HelloAnswer

type HelloAnswer struct {
	Hash        protocol.Hash
	Point       protocol.Endpoint
	Properties  protocol.TagList
	ServerPoint protocol.Endpoint
}

func (HelloAnswer) BytesCount

func (h HelloAnswer) BytesCount() int

func (*HelloAnswer) Get

func (h *HelloAnswer) Get(src *bytes.Reader) error

func (HelloAnswer) Put

func (h HelloAnswer) Put(dst *bytes.Buffer) error

type NoFileStatus

type NoFileStatus struct {
	Hash protocol.Hash
}

func (NoFileStatus) BytesCount

func (n NoFileStatus) BytesCount() int

func (*NoFileStatus) Get

func (n *NoFileStatus) Get(src *bytes.Reader) error

func (NoFileStatus) Put

func (n NoFileStatus) Put(dst *bytes.Buffer) error

type OutOfParts

type OutOfParts struct {
	protocol.WithoutDataPacket
}

type PreviewAnswer added in v0.1.3

type PreviewAnswer struct {
	Hash       protocol.Hash
	PieceIndex uint16
	Data       []byte
}

PreviewAnswer:OP_EMULEPROT OP_PREVIEWANSWER (0x91)。 载荷:16 字节 hash + uint16 分片索引 + uint32 数据长度 + 数据。

func (PreviewAnswer) BytesCount added in v0.1.3

func (p PreviewAnswer) BytesCount() int

func (*PreviewAnswer) Get added in v0.1.3

func (p *PreviewAnswer) Get(src *bytes.Reader) error

func (PreviewAnswer) Put added in v0.1.3

func (p PreviewAnswer) Put(dst *bytes.Buffer) error

type PublicKey added in v0.1.0

type PublicKey struct {
	Key []byte
}

func (PublicKey) BytesCount added in v0.1.0

func (p PublicKey) BytesCount() int

func (*PublicKey) Get added in v0.1.0

func (p *PublicKey) Get(src *bytes.Reader) error

func (PublicKey) Put added in v0.1.0

func (p PublicKey) Put(dst *bytes.Buffer) error

type QueueRanking

type QueueRanking struct {
	Rank     uint16
	Padding1 uint32
	Padding2 uint32
	Padding3 uint16
}

func (QueueRanking) BytesCount

func (q QueueRanking) BytesCount() int

func (*QueueRanking) Get

func (q *QueueRanking) Get(src *bytes.Reader) error

func (QueueRanking) Put

func (q QueueRanking) Put(dst *bytes.Buffer) error

type RequestParts32

type RequestParts32 struct {
	Hash        protocol.Hash
	CurrentFree int
	BeginOffset [partsInRequest]uint32
	EndOffset   [partsInRequest]uint32
}

func (*RequestParts32) AppendRange

func (r *RequestParts32) AppendRange(rg data.Range)

func (RequestParts32) BytesCount

func (r RequestParts32) BytesCount() int

func (*RequestParts32) Get

func (r *RequestParts32) Get(src *bytes.Reader) error

func (RequestParts32) Put

func (r RequestParts32) Put(dst *bytes.Buffer) error

type RequestParts64

type RequestParts64 struct {
	Hash        protocol.Hash
	CurrentFree int
	BeginOffset [partsInRequest]uint64
	EndOffset   [partsInRequest]uint64
}

func (*RequestParts64) AppendRange

func (r *RequestParts64) AppendRange(rg data.Range)

func (RequestParts64) BytesCount

func (r RequestParts64) BytesCount() int

func (*RequestParts64) Get

func (r *RequestParts64) Get(src *bytes.Reader) error

func (RequestParts64) Put

func (r RequestParts64) Put(dst *bytes.Buffer) error

type RequestPreview added in v0.1.3

type RequestPreview struct {
	Hash       protocol.Hash
	PieceIndex uint16
}

RequestPreview:OP_EMULEPROT OP_REQUESTPREVIEW (0x90)。 载荷:16 字节 hash + uint16 预览分片索引(eMule 按分片请求预览数据)。

func (RequestPreview) BytesCount added in v0.1.3

func (r RequestPreview) BytesCount() int

func (*RequestPreview) Get added in v0.1.3

func (r *RequestPreview) Get(src *bytes.Reader) error

func (RequestPreview) Put added in v0.1.3

func (r RequestPreview) Put(dst *bytes.Buffer) error

type RequestSources added in v0.1.3

type RequestSources struct {
	Hash protocol.Hash
}

RequestSources(SX1):OP_EMULEPROT OP_REQUESTSOURCES (0x81),载荷为 16 字节文件 hash。

func (RequestSources) BytesCount added in v0.1.3

func (r RequestSources) BytesCount() int

func (*RequestSources) Get added in v0.1.3

func (r *RequestSources) Get(src *bytes.Reader) error

func (RequestSources) Put added in v0.1.3

func (r RequestSources) Put(dst *bytes.Buffer) error

type RequestSources2

type RequestSources2 struct {
	Version  byte
	Reserved uint16
	Hash     protocol.Hash
}

RequestSources2:OP_EMULEPROT OP_REQUESTSOURCES2 载荷。 顺序:uint8 版本(SourceExchange2Version)+ uint16 保留(0) + 16 字节文件 hash。

func (RequestSources2) BytesCount

func (r RequestSources2) BytesCount() int

func (*RequestSources2) Get

func (r *RequestSources2) Get(src *bytes.Reader) error

func (RequestSources2) Put

func (r RequestSources2) Put(dst *bytes.Buffer) error

type SecIdentState added in v0.1.0

type SecIdentState struct {
	State     byte
	Challenge uint32
}

func (SecIdentState) BytesCount added in v0.1.0

func (s SecIdentState) BytesCount() int

func (*SecIdentState) Get added in v0.1.0

func (s *SecIdentState) Get(src *bytes.Reader) error

func (SecIdentState) Put added in v0.1.0

func (s SecIdentState) Put(dst *bytes.Buffer) error

type SendingPart32

type SendingPart32 struct {
	Hash        protocol.Hash
	BeginOffset uint32
	EndOffset   uint32
}

func (SendingPart32) BytesCount

func (s SendingPart32) BytesCount() int

func (*SendingPart32) Get

func (s *SendingPart32) Get(src *bytes.Reader) error

func (SendingPart32) PayloadSize

func (s SendingPart32) PayloadSize() int

func (SendingPart32) Put

func (s SendingPart32) Put(dst *bytes.Buffer) error

type SendingPart64

type SendingPart64 struct {
	Hash        protocol.Hash
	BeginOffset uint64
	EndOffset   uint64
}

func (SendingPart64) BytesCount

func (s SendingPart64) BytesCount() int

func (*SendingPart64) Get

func (s *SendingPart64) Get(src *bytes.Reader) error

func (SendingPart64) PayloadSize

func (s SendingPart64) PayloadSize() int

func (SendingPart64) Put

func (s SendingPart64) Put(dst *bytes.Buffer) error

type Signature added in v0.1.0

type Signature struct {
	Signature []byte
}

func (Signature) BytesCount added in v0.1.0

func (s Signature) BytesCount() int

func (*Signature) Get added in v0.1.0

func (s *Signature) Get(src *bytes.Reader) error

func (Signature) Put added in v0.1.0

func (s Signature) Put(dst *bytes.Buffer) error

type SourceExchangeEntry

type SourceExchangeEntry struct {
	UserID       uint32
	TCPPort      uint16
	ServerIP     uint32
	ServerPort   uint16
	UserHash     protocol.Hash
	CryptOptions uint8
	IPv6         [16]byte
}

SourceExchangeEntry 表示 AnswerSources2 中单个来源(SX2 v4:含 UserHash 与 CryptOptions;v5 追加 IPv6)。

func (SourceExchangeEntry) EntryHasIPv6 added in v0.1.3

func (e SourceExchangeEntry) EntryHasIPv6() bool

EntryHasIPv6 判断条目是否携带有效 IPv6 地址。

func (SourceExchangeEntry) EntryIPv6Addr added in v0.1.3

func (e SourceExchangeEntry) EntryIPv6Addr() net.IP

EntryIPv6Addr 返回条目的 IPv6 地址(无则 nil)。

type StartUpload

type StartUpload struct {
	Hash protocol.Hash
}

func (StartUpload) BytesCount

func (s StartUpload) BytesCount() int

func (*StartUpload) Get

func (s *StartUpload) Get(src *bytes.Reader) error

func (StartUpload) Put

func (s StartUpload) Put(dst *bytes.Buffer) error

Jump to

Keyboard shortcuts

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