ed2k

package
v0.0.0-...-bfb3c54 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FileChunkSize is the size of file chunk.
	FileChunkSize = 9728000

	// MaxFileSize is the maximum file size in byte (2^38 = 256GB).
	MaxFileSize = 2 << 37
)
View Source
const (
	SearchEqual        = iota // eserver 16.45+
	SearchGreater             // dserver
	SearchLess                // dserver
	SearchGreaterEqual        // eserver 16.45+
	SearchLessEqual           // eserver 16.45+
	SearchNotEqual
)

ed2k search expression comparison operators. kad operators used to be different, but are the same since eMule 0.47a.

View Source
const (
	FileAudio    = "Audio"
	FileVideo    = "Video"
	FileImage    = "Image"
	FileDocument = "Doc"
	FileProgram  = "Pro"
	FileArchive  = "Arc" // *Mule internal use only
	FileCDImage  = "Iso" // *Mule internal use only
)

File media types.

View Source
const (
	SearchAND = iota
	SearchOR
	SearchNOT
)

Search operators.

View Source
const (
	SearchBoolean  = 0x00
	SearchName     = 0x01
	SearchMetadata = 0x02
	SearchLimit    = 0x3
)

file search types.

View Source
const (
	LimitMin = 0x01
	LimitMax = 0x02
)

Limit types

View Source
const (
	ProtoEDonkey = 0xE3
	ProtoEMule   = 0xC5
	ProtoPacked  = 0xD4
)

protocol ID

View Source
const (
	MessageNull              = 0x00
	MessageLoginRequest      = 0x01
	MessageRejected          = 0x05
	MessageGetServerList     = 0x14
	MessageOfferFiles        = 0x15
	MessageSearchRequest     = 0x16
	MessageDisconnect        = 0x18
	MessageSearchUser        = 0x1A
	MessageGetSources        = 0x19
	MessageGetSourcesOBFU    = 0x23
	MessageCallbackRequest   = 0x1C
	MessageMoreResult        = 0x21
	MessageServerList        = 0x32
	MessageSearchResult      = 0x33
	MessageServerStatus      = 0x34
	MessageCallbackRequested = 0x35
	MessageCallbackFailed    = 0x36
	MessageServerMessage     = 0x38
	MessageIDChange          = 0x40
	MessageServerIdent       = 0x41
	MessageFoundSources      = 0x42
	MessageUserList          = 0x43
	MessageFoundSourcesOBFU  = 0x44
)

Client-Server TCP messages.

View Source
const (
	MessageHello       = 0x01
	MessageHelloAnswer = 0x02
)

Client-Client TCP messages.

View Source
const (
	CSTCPMessage = 0x00 // client-server TCP message
	CSUDPMessage = 0x01 // client-server UDP message
	CCTCPMessage = 0x02 // client-client TCP message
	CCUDPMessage = 0x03 // client-client UDP message
)

message classes.

View Source
const (
	TagName         = 0x01
	TagSize         = 0x02
	TagType         = 0x03
	TagFormat       = 0x04
	TagDesc         = 0x0B
	TagVersion      = 0x11
	TagPort         = 0x0F
	TagServerFlags  = 0x20 // currently only used to inform a server about supported features.
	TagEMuleVersion = 0xFB

	// This flag indicates that the flag name is just 1 byte without size field.
	// The MSB of tag type will be turned on if set.
	TagCompactNameFlag = 0x100
)

tag names

View Source
const (
	TagHash16    = 0x01
	TagString    = 0x02
	TagUint32    = 0x03
	TagInteger   = 0x03 // uint32 alias
	TagFloat32   = 0x04
	TagFloat     = 0x04 // float32 alias
	TagBool      = 0x05
	TagBoolArray = 0x06
	TagBlob      = 0x07
	TagUint16    = 0x08
	TagUint8     = 0x09
	TagBsob      = 0x0A
	TagUint64    = 0x0B

	// Compressed string types
	TagStr0  = 0x10 // start tag
	TagStr1  = 0x11
	TagStr2  = 0x12
	TagStr3  = 0x13
	TagStr4  = 0x14
	TagStr5  = 0x15
	TagStr6  = 0x16
	TagStr7  = 0x17
	TagStr8  = 0x18
	TagStr9  = 0x19
	TagStr10 = 0x1A
	TagStr11 = 0x1B
	TagStr12 = 0x1C
	TagStr13 = 0x1D
	TagStr14 = 0x1E
	TagStr15 = 0x1F
	TagStr16 = 0x20

	// Additional media meta data tags from eDonkeyHybrid (note also the uppercase/lowercase)
	FileMediaArtist  = "Artist"
	FileMediaAlbum   = "Album"
	FileMediaTitle   = "Title"
	FileMediaLength  = "length"
	FileMediaBitrate = "bitrate"
	FileMediaCodec   = "codec"
)

Tag types

View Source
const (
	TagStringName = 0
	TagIntName    = 1
)

tag name type

View Source
const (
	CapZlib         = 0x0001
	CapIPInLogin    = 0x0002
	CapAuxPort      = 0x0004
	CapNewTag       = 0x0008
	CapUnicode      = 0x0010
	CapLargeFiles   = 0x0100
	CapSupportCrypt = 0x0200
	CapRequestCrypt = 0x0400
	CapRequireCrypt = 0x0800
)

Server capabilities, values for flags

View Source
const (
	ClientEMule         = 0
	ClientCDonkey       = 1
	ClientLXMule        = 2
	ClientAMule         = 3
	ClientShareaza      = 4
	ClientEMulePlus     = 5
	ClientHydraNode     = 6
	ClientMLDonkeyNew2  = 0x0a
	ClientLPhant        = 0x14
	ClientShareazaNew2  = 0x28
	ClientEDonkeyHybrid = 0x32
	ClientEDonkey       = 0x33
	ClientMLDonkey      = 0x34
	ClientEMuleOld      = 0x35
	ClientUnknown       = 0x36
	ClientShareazaNew   = 0x44
	ClientMLDonkeyNew   = 0x98
	ClientCompat        = 0xFF
)

EMule clients

View Source
const (
	MajorVersion  = 2
	MinorVersion  = 4
	UpdateVersion = 0
)

client version

View Source
const (
	// EDonkeyVerion is only used to server login. It has no real "version" meaning anymore.
	EDonkeyVerion = 0x3C
	// EMuleVersion is eMule Version (14-Mar-2004: requested by lugdunummaster (need for LowID clients which have no chance
	// to send an Hello packet to the server during the callback test)).
	EMuleVersion = ClientAMule<<24 | MajorVersion<<17 | MinorVersion<<10 | UpdateVersion<<7
)
View Source
const (
	// HeaderLength is the length of message header.
	// 1-byte protocol + 4-byte data size
	HeaderLength = 5
)

Variables

View Source
var (
	ErrShortBuffer      = io.ErrShortBuffer
	ErrWrongMessageType = errors.New("wrong message type")
)

errors

View Source
var (
	ErrInvalidProto = errors.New("invalid protocol")
)

errors

Functions

This section is empty.

Types

type CallbackFailedMessage

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

CallbackFailedMessage message sent from the server to the client indicating that the client’s callback request has failed.

func (*CallbackFailedMessage) Decode

func (m *CallbackFailedMessage) Decode(data []byte) (err error)

Decode decodes the message from binary data.

func (*CallbackFailedMessage) Encode

func (m *CallbackFailedMessage) Encode() (data []byte, err error)

Encode encodes the message to binary data.

func (*CallbackFailedMessage) Protocol

func (m *CallbackFailedMessage) Protocol() uint8

func (CallbackFailedMessage) String

func (m CallbackFailedMessage) String() string

func (CallbackFailedMessage) Type

func (m CallbackFailedMessage) Type() uint8

Type is the message type.

type CallbackRequestMessage

type CallbackRequestMessage struct {
	ClientID ClientID
	// contains filtered or unexported fields
}

CallbackRequestMessage message sent from the client to the server, requesting another client to call back - e.g. connect to the requesting client. The message is sent by a client that has a high ID who wishes to connect to a low ID client.

func (*CallbackRequestMessage) Decode

func (m *CallbackRequestMessage) Decode(data []byte) (err error)

Decode decodes the message from binary data.

func (*CallbackRequestMessage) Encode

func (m *CallbackRequestMessage) Encode() (data []byte, err error)

Encode encodes the message to binary data.

func (*CallbackRequestMessage) Protocol

func (m *CallbackRequestMessage) Protocol() uint8

func (CallbackRequestMessage) String

func (m CallbackRequestMessage) String() string

func (CallbackRequestMessage) Type

func (m CallbackRequestMessage) Type() uint8

Type is the message type.

type CallbackRequestedMessage

type CallbackRequestedMessage struct {
	IP   uint32
	Port uint16
	// contains filtered or unexported fields
}

CallbackRequestedMessage message sent from the server to the client indicating another client asks the receiving client to connect to it. The message is sent when the receiving client has a low ID. The receiving client tries to connect to the IP and port specified by the callback request packet.

func (*CallbackRequestedMessage) Decode

func (m *CallbackRequestedMessage) Decode(data []byte) (err error)

Decode decodes the message from binary data.

func (*CallbackRequestedMessage) Encode

func (m *CallbackRequestedMessage) Encode() (data []byte, err error)

Encode encodes the message to binary data.

func (*CallbackRequestedMessage) Protocol

func (m *CallbackRequestedMessage) Protocol() uint8

func (CallbackRequestedMessage) String

func (m CallbackRequestedMessage) String() string

func (CallbackRequestedMessage) Type

Type is the message type.

type ClientID

type ClientID uint32

ClientID is an a 4 byte identifier provided by the server at their connection handshake. A client ID is valid only through the lifetime of a client-server TCP connection although in case the client has a high ID it will be assigned the same ID by all servers until its IP address changes.

Client IDs are divided to low IDs and high IDs. The eMule server will typically assigns a client with a low ID when the client can’t accept incoming connections. Having a low ID restricts the client’s use of the eMule network and might result in the server’s rejecting the client’s connection.

A high ID is given to clients that allow other clients to freely connect to eMule’s TCP port on their host machine (the default port number is 4662). A client with a high ID has no restrictions in its use of the eMule network.

High IDs are calculated in the following way: assuming the host IP is X.Y.Z.W the ID will be X + 2^8 * Y + 2^16 * Z + 2^24 * W (big endian representation). A low ID is always lower than 16777216 (0x1000000).

func (ClientID) String

func (cid ClientID) String() string

type File

type File struct {
	// The result of a hash performed on the file contents.
	// The hash is used to uniquely identify files, ignoring name differences between clients.
	Hash [16]byte
	// The client ID in case the client has high ID, or zero otherwise.
	ClientID uint32
	// The Client’s TCP port or zero in case the client has low ID.
	Port uint16
	// File tags: name, size, type, etc.
	Tags []Tag
}

File is a single file entry.

func ReadFile

func ReadFile(r io.Reader) (*File, error)

ReadFile reads structured binary data from r and parses the data to file.

func (*File) Decode

func (f *File) Decode(data []byte) (err error)

Decode decodes the file from binary data.

func (*File) Encode

func (f *File) Encode() (data []byte, err error)

Encode encodes file struct to binary data.

func (*File) WriteTo

func (f *File) WriteTo(w io.Writer) (n int64, err error)

WriteTo writes file struct to w. The return value n is the number of bytes written.

type FileHash

type FileHash struct {
	Size     int64
	Hash     []byte
	PartHash [][]byte
}

FileHash is a 128 bit GUID hash calculated by the client and based on the file's contents.

func Hash

func Hash(r io.Reader) (hash *FileHash, err error)

Hash calculates the part hash and final hash.

func (FileHash) String

func (h FileHash) String() string

type FileSearcher

type FileSearcher interface {
	Encode() (data []byte, err error)
}

FileSearcher is a file search struct.

func FileNameSearcher

func FileNameSearcher(name string) FileSearcher

FileNameSearcher is a file searcher by file name.

type FoundSourcesMessage

type FoundSourcesMessage struct {
	Hash    [16]byte
	Sources []*net.TCPAddr
	// contains filtered or unexported fields
}

FoundSourcesMessage message sent from the server to the client with sources (other clients) for a file requested by the client for a file.

func (*FoundSourcesMessage) Decode

func (m *FoundSourcesMessage) Decode(data []byte) (err error)

Decode decodes the message from binary data.

func (*FoundSourcesMessage) Encode

func (m *FoundSourcesMessage) Encode() (data []byte, err error)

Encode encodes the message to binary data.

func (*FoundSourcesMessage) Protocol

func (m *FoundSourcesMessage) Protocol() uint8

func (FoundSourcesMessage) String

func (m FoundSourcesMessage) String() string

func (FoundSourcesMessage) Type

func (m FoundSourcesMessage) Type() uint8

Type is the message type.

type GetServerListMessage

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

GetServerListMessage message is sent when the client is configured to expand its list of eMule servers by querying its current server. This message may be sent from the client to the server immediately after a successful handshake completion.

func (*GetServerListMessage) Decode

func (m *GetServerListMessage) Decode(data []byte) (err error)

Decode decodes the message from binary data.

func (*GetServerListMessage) Encode

func (m *GetServerListMessage) Encode() (data []byte, err error)

Encode encodes the message to binary data.

func (*GetServerListMessage) Protocol

func (m *GetServerListMessage) Protocol() uint8

func (GetServerListMessage) String

func (m GetServerListMessage) String() string

func (GetServerListMessage) Type

func (m GetServerListMessage) Type() uint8

Type is the message type.

type GetSourcesMessage

type GetSourcesMessage struct {
	Hash [16]byte
	Size uint32
	// contains filtered or unexported fields
}

GetSourcesMessage message sent from the client to the server requesting sources (other clients) for a file.

func (*GetSourcesMessage) Decode

func (m *GetSourcesMessage) Decode(data []byte) (err error)

Decode decodes the message from binary data.

func (*GetSourcesMessage) Encode

func (m *GetSourcesMessage) Encode() (data []byte, err error)

Encode encodes the message to binary data.

func (*GetSourcesMessage) Protocol

func (m *GetSourcesMessage) Protocol() uint8

func (GetSourcesMessage) String

func (m GetSourcesMessage) String() string

func (GetSourcesMessage) Type

func (m GetSourcesMessage) Type() uint8

Type is the message type.

type Header struct {
	// Protocol ID, 0xE3 for eDonkey and 0xC5 for eMule.
	Protocol uint8
	// The size of the message in bytes not including the protocol and size fields.
	Size uint32
}

Header is the message header.

func (*Header) Decode

func (h *Header) Decode(data []byte) (err error)

Decode decodes the header from binary data.

func (*Header) Encode

func (h *Header) Encode() (data []byte, err error)

Encode encodes the header to binary data.

func (*Header) ReadFrom

func (h *Header) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom reads structured binary data from r and parses data to header h.

func (Header) String

func (h Header) String() string

func (*Header) WriteTo

func (h *Header) WriteTo(w io.Writer) (n int64, err error)

WriteTo writes header struct to w. The return value n is the number of bytes written.

type HelloAnswerMessage

type HelloAnswerMessage struct {
	UID      UID
	ClientID ClientID
	Port     uint16
	Tags     []Tag
	// The address of the server to which the client is connected.
	Server *net.TCPAddr
	// contains filtered or unexported fields
}

HelloAnswerMessage message is sent as an answer to a Hello message.

func (*HelloAnswerMessage) Decode

func (m *HelloAnswerMessage) Decode(data []byte) (err error)

Decode decodes the message from binary data.

func (*HelloAnswerMessage) Encode

func (m *HelloAnswerMessage) Encode() (data []byte, err error)

Encode encodes the message to binary data.

func (*HelloAnswerMessage) Protocol

func (m *HelloAnswerMessage) Protocol() uint8

func (HelloAnswerMessage) String

func (m HelloAnswerMessage) String() string

func (HelloAnswerMessage) Type

func (m HelloAnswerMessage) Type() uint8

Type is the message type.

type HelloMessage

type HelloMessage struct {
	UID      UID
	ClientID ClientID
	Port     uint16
	Tags     []Tag
	// The address of the server to which the client is connected.
	Server *net.TCPAddr
	// contains filtered or unexported fields
}

HelloMessage message is the first message in the handshake between two e-mule clients.

func (*HelloMessage) Decode

func (m *HelloMessage) Decode(data []byte) (err error)

Decode decodes the message from binary data.

func (*HelloMessage) Encode

func (m *HelloMessage) Encode() (data []byte, err error)

Encode encodes the message to binary data.

func (*HelloMessage) Protocol

func (m *HelloMessage) Protocol() uint8

func (HelloMessage) String

func (m HelloMessage) String() string

func (HelloMessage) Type

func (m HelloMessage) Type() uint8

Type is the message type

type IDChangeMessage

type IDChangeMessage struct {
	ClientID ClientID
	// Currently only 1 bit (the LSB) has meaning, setting it to 1 signals that the server supports compression.
	Bitmap uint32
	// contains filtered or unexported fields
}

IDChangeMessage message is sent by the server as a response to the login request message and signifies that the server has accepted the client connection.

func (*IDChangeMessage) Decode

func (m *IDChangeMessage) Decode(data []byte) (err error)

Decode decodes the message from binary data.

func (*IDChangeMessage) Encode

func (m *IDChangeMessage) Encode() (data []byte, err error)

Encode encodes the message to binary data.

func (*IDChangeMessage) Protocol

func (m *IDChangeMessage) Protocol() uint8

func (IDChangeMessage) String

func (m IDChangeMessage) String() string

func (IDChangeMessage) Type

func (m IDChangeMessage) Type() uint8

Type is the message type.

type LoginMessage

type LoginMessage struct {
	UID      UID
	ClientID ClientID
	// The TCP port used by the client, configurable.
	Port uint16
	Tags []Tag
	// contains filtered or unexported fields
}

LoginMessage is the first message send by the client to the server after TCP connection establishment.

func (*LoginMessage) Decode

func (m *LoginMessage) Decode(data []byte) (err error)

Decode decodes the message from binary data.

func (*LoginMessage) Encode

func (m *LoginMessage) Encode() (data []byte, err error)

Encode encodes the message to binary data.

func (*LoginMessage) Protocol

func (m *LoginMessage) Protocol() uint8

func (LoginMessage) String

func (m LoginMessage) String() string

func (LoginMessage) Type

func (m LoginMessage) Type() uint8

Type is the message type.

type Message

type Message interface {
	Protocol() uint8
	Type() uint8
	Encode() (data []byte, err error)
	Decode(data []byte) (err error)
	String() string
}

Message is message interface.

func ReadMessage

func ReadMessage(r io.Reader, class int) (m Message, err error)

ReadMessage reads structured binary data from r and parses the data to message.

type NullMessage

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

NullMessage is a message that it is size field of header is 0.

func (*NullMessage) Decode

func (m *NullMessage) Decode(data []byte) (err error)

Decode decodes the message from binary data.

func (*NullMessage) Encode

func (m *NullMessage) Encode() (data []byte, err error)

Encode encodes the message to binary data.

func (*NullMessage) Protocol

func (m *NullMessage) Protocol() uint8

func (NullMessage) String

func (m NullMessage) String() string

func (NullMessage) Type

func (m NullMessage) Type() uint8

Type is the message type

type OfferFilesMessage

type OfferFilesMessage struct {

	// An optional list of files, in any case no more than 200.
	// The Server can also set a lower limit to this number.
	Files []File
	// contains filtered or unexported fields
}

OfferFilesMessage is used by the client to describe local files available for other clients to download. In case the client has files to offer, the offer-files message is sent immediately after the connection establishment. The message is also transmitted when the client’s shared file list changes.

func (*OfferFilesMessage) Decode

func (m *OfferFilesMessage) Decode(data []byte) (err error)

Decode decodes the message from binary data.

func (*OfferFilesMessage) Encode

func (m *OfferFilesMessage) Encode() (data []byte, err error)

Encode encodes the message to binary data.

func (*OfferFilesMessage) Protocol

func (m *OfferFilesMessage) Protocol() uint8

func (OfferFilesMessage) String

func (m OfferFilesMessage) String() string

func (OfferFilesMessage) Type

func (m OfferFilesMessage) Type() uint8

Type is the message type.

type RejectedMessage

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

RejectedMessage message sent from the server to the client indicating that the server rejected the last command sent by the client.

func (*RejectedMessage) Decode

func (m *RejectedMessage) Decode(data []byte) (err error)

Decode decodes the message from binary data.

func (*RejectedMessage) Encode

func (m *RejectedMessage) Encode() (data []byte, err error)

Encode encodes the message to binary data.

func (*RejectedMessage) Protocol

func (m *RejectedMessage) Protocol() uint8

func (RejectedMessage) String

func (m RejectedMessage) String() string

func (RejectedMessage) Type

func (m RejectedMessage) Type() uint8

Type is the message type.

type SearchRequestMessage

type SearchRequestMessage struct {
	Searcher FileSearcher
	// contains filtered or unexported fields
}

SearchRequestMessage message is used to search for files by a user's search string. The search string may include the boolean conditions 'AND', 'OR', 'NOT'. The user may specify required file type and size and also set an availability threshold (e.g. show me results that are available from at least 5 other clients).

func (*SearchRequestMessage) Decode

func (m *SearchRequestMessage) Decode(data []byte) (err error)

Decode decodes the message from binary data.

func (*SearchRequestMessage) Encode

func (m *SearchRequestMessage) Encode() (data []byte, err error)

Encode encodes the message to binary data.

func (*SearchRequestMessage) Protocol

func (m *SearchRequestMessage) Protocol() uint8

func (*SearchRequestMessage) String

func (m *SearchRequestMessage) String() string

func (*SearchRequestMessage) Type

func (m *SearchRequestMessage) Type() uint8

Type is the message type.

type SearchResultMessage

type SearchResultMessage struct {
	Files []File
	// contains filtered or unexported fields
}

SearchResultMessage message sent from the server to the client as a reply to a search request. The message is usually compressed.

func (*SearchResultMessage) Decode

func (m *SearchResultMessage) Decode(data []byte) (err error)

Decode decodes the message from binary data.

func (*SearchResultMessage) Encode

func (m *SearchResultMessage) Encode() (data []byte, err error)

Encode encodes the message to binary data.

func (*SearchResultMessage) Protocol

func (m *SearchResultMessage) Protocol() uint8

func (SearchResultMessage) String

func (m SearchResultMessage) String() string

func (SearchResultMessage) Type

func (m SearchResultMessage) Type() uint8

Type is the message type.

type ServerIdentMessage

type ServerIdentMessage struct {

	// A GUID of the server (seems to be used for debug).
	Hash UID
	// The IP address of the server.
	IP uint32
	// The TCP port on which the server listens.
	Port uint16

	Tags []Tag
	// contains filtered or unexported fields
}

ServerIdentMessage message sent from the server to the client contains a server hash, the server IP address and TCP port (which may be useful when connecting through a proxy) and also server description information.

func (*ServerIdentMessage) Decode

func (m *ServerIdentMessage) Decode(data []byte) (err error)

Decode decodes the message from binary data.

func (*ServerIdentMessage) Encode

func (m *ServerIdentMessage) Encode() (data []byte, err error)

Encode encodes the message to binary data.

func (*ServerIdentMessage) Protocol

func (m *ServerIdentMessage) Protocol() uint8

func (ServerIdentMessage) String

func (m ServerIdentMessage) String() string

func (ServerIdentMessage) Type

func (m ServerIdentMessage) Type() uint8

Type is the message type.

type ServerListMessage

type ServerListMessage struct {

	// Server descriptor entries, each entry size is 6 bytes and contains 4 bytes IP address and then 2 byte TCP port.
	Servers []*net.TCPAddr
	// contains filtered or unexported fields
}

ServerListMessage message sent from the server to the client contains information about additional eMule servers to be used to expand the client’s server list.

func (*ServerListMessage) Decode

func (m *ServerListMessage) Decode(data []byte) (err error)

Decode decodes the message from binary data.

func (*ServerListMessage) Encode

func (m *ServerListMessage) Encode() (data []byte, err error)

Encode encodes the message to binary data.

func (*ServerListMessage) Protocol

func (m *ServerListMessage) Protocol() uint8

func (ServerListMessage) String

func (m ServerListMessage) String() string

func (ServerListMessage) Type

func (m ServerListMessage) Type() uint8

Type is the message type.

type ServerMessage

type ServerMessage struct {

	// A list of server messages separated by new lines.
	Messages string
	// contains filtered or unexported fields
}

ServerMessage is variable length message that is sent from the server to client. A single server-message may contain several messages separated by new line characters ('\r','\n' or both). Messages that start with "server version", "warning", "error" and "emDynIP" have special meaning for the client.

func (*ServerMessage) Decode

func (m *ServerMessage) Decode(data []byte) (err error)

Decode decodes the message from binary data.

func (*ServerMessage) Encode

func (m *ServerMessage) Encode() (data []byte, err error)

Encode encodes the message to binary data.

func (*ServerMessage) Protocol

func (m *ServerMessage) Protocol() uint8

func (ServerMessage) String

func (m ServerMessage) String() string

func (ServerMessage) Type

func (m ServerMessage) Type() uint8

Type is the message type.

type ServerStatusMessage

type ServerStatusMessage struct {

	// The number of users currently logged in to the server.
	UserCount uint32
	// The number of files that this server is informed about.
	FileCount uint32
	// contains filtered or unexported fields
}

ServerStatusMessage message sent from the server to the client contains information on the current number of users and files on the server. The information in this message is both stored by the client and also displayed to the user.

func (*ServerStatusMessage) Decode

func (m *ServerStatusMessage) Decode(data []byte) (err error)

Decode decodes the message from binary data.

func (*ServerStatusMessage) Encode

func (m *ServerStatusMessage) Encode() (data []byte, err error)

Encode encodes the message to binary data.

func (*ServerStatusMessage) Protocol

func (m *ServerStatusMessage) Protocol() uint8

func (ServerStatusMessage) String

func (m ServerStatusMessage) String() string

func (ServerStatusMessage) Type

func (m ServerStatusMessage) Type() uint8

Type is the message type.

type Tag

type Tag interface {
	Type() uint8
	Name() interface{}
	Value() interface{}
	Encode() ([]byte, error)
	Decode([]byte) error
	ReadFrom(r io.Reader) (n int64, err error)
	WriteTo(w io.Writer) (n int64, err error)
}

Tag is TLV-like (Type, Length, Value) structure which is used for appending optional data to eMule messages.

func BoolTag

func BoolTag(name interface{}, value bool) Tag

BoolTag is a tag with bool value. the type of name must be int or string.

func Float32Tag

func Float32Tag(name interface{}, value float32) Tag

Float32Tag is a tag with float32 value. the type of name must be int or string.

func FloatTag

func FloatTag(name interface{}, value float32) Tag

FloatTag is a tag with float32 value. the type of name must be int or string.

func Hash16Tag

func Hash16Tag(name interface{}, value [16]byte) Tag

Hash16Tag is a tag with 16-byte hash value. the type of name must be int or string.

func IntegerTag

func IntegerTag(name interface{}, v uint64) Tag

IntegerTag is a tag with integer value, the actual tag type is based on integer value v. the type of name must be int or string.

func ReadTag

func ReadTag(r io.Reader) (Tag, error)

ReadTag reads structured binary data from r and parses the data to tag.

func StringTag

func StringTag(name interface{}, value string, compress bool) Tag

StringTag is a tag with String value, it supports compressing if length is less than or equal to 16-byte. the type of name must be int or string.

func Uint16Tag

func Uint16Tag(name interface{}, value uint16) Tag

Uint16Tag is a tag with uint16 integer value. the type of name must be int or string.

func Uint32Tag

func Uint32Tag(name interface{}, value uint32) Tag

Uint32Tag is a tag with uint32 integer value. the type of name must be int or string.

func Uint64Tag

func Uint64Tag(name interface{}, value uint64) Tag

Uint64Tag is a tag with uint64 integer value. the type of name must be int or string.

func Uint8Tag

func Uint8Tag(name interface{}, value uint8) Tag

Uint8Tag is a tag with uint8 integer value. the type of name must be int or string.

type UID

type UID [16]byte

UID is user ID, it is a 128 bit (16 byte) GUID. the 6th and 15th (start from 1st) bytes values are 14 and 111 respectively.

func NewUID

func NewUID() (uid UID)

NewUID creates a UID based on GUID

func (UID) Bytes

func (uid UID) Bytes() []byte

Bytes returns a slice of 16-byte length.

func (UID) String

func (uid UID) String() string

Jump to

Keyboard shortcuts

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