Documentation
¶
Index ¶
- Constants
- Variables
- type CallbackFailedMessage
- type CallbackRequestMessage
- type CallbackRequestedMessage
- type ClientID
- type File
- type FileHash
- type FileSearcher
- type FoundSourcesMessage
- type GetServerListMessage
- type GetSourcesMessage
- type Header
- type HelloAnswerMessage
- type HelloMessage
- type IDChangeMessage
- type LoginMessage
- type Message
- type NullMessage
- type OfferFilesMessage
- type RejectedMessage
- type SearchRequestMessage
- type SearchResultMessage
- type ServerIdentMessage
- type ServerListMessage
- type ServerMessage
- type ServerStatusMessage
- type Tag
- func BoolTag(name interface{}, value bool) Tag
- func Float32Tag(name interface{}, value float32) Tag
- func FloatTag(name interface{}, value float32) Tag
- func Hash16Tag(name interface{}, value [16]byte) Tag
- func IntegerTag(name interface{}, v uint64) Tag
- func ReadTag(r io.Reader) (Tag, error)
- func StringTag(name interface{}, value string, compress bool) Tag
- func Uint16Tag(name interface{}, value uint16) Tag
- func Uint32Tag(name interface{}, value uint32) Tag
- func Uint64Tag(name interface{}, value uint64) Tag
- func Uint8Tag(name interface{}, value uint8) Tag
- type UID
Constants ¶
const ( // FileChunkSize is the size of file chunk. FileChunkSize = 9728000 // MaxFileSize is the maximum file size in byte (2^38 = 256GB). MaxFileSize = 2 << 37 )
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.
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.
const ( SearchAND = iota SearchOR SearchNOT )
Search operators.
const ( SearchBoolean = 0x00 SearchName = 0x01 SearchMetadata = 0x02 SearchLimit = 0x3 )
file search types.
const ( LimitMin = 0x01 LimitMax = 0x02 )
Limit types
const ( ProtoEDonkey = 0xE3 ProtoEMule = 0xC5 ProtoPacked = 0xD4 )
protocol ID
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.
const ( MessageHello = 0x01 MessageHelloAnswer = 0x02 )
Client-Client TCP messages.
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.
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
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
const ( TagStringName = 0 TagIntName = 1 )
tag name type
const ( CapZlib = 0x0001 CapIPInLogin = 0x0002 CapAuxPort = 0x0004 CapNewTag = 0x0008 CapUnicode = 0x0010 CapLargeFiles = 0x0100 CapSupportCrypt = 0x0200 CapRequestCrypt = 0x0400 CapRequireCrypt = 0x0800 )
Server capabilities, values for flags
const ( ClientEMule = 0 ClientCDonkey = 1 ClientLXMule = 2 ClientAMule = 3 ClientEMulePlus = 5 ClientHydraNode = 6 ClientMLDonkeyNew2 = 0x0a ClientLPhant = 0x14 ClientEDonkeyHybrid = 0x32 ClientEDonkey = 0x33 ClientMLDonkey = 0x34 ClientEMuleOld = 0x35 ClientUnknown = 0x36 ClientMLDonkeyNew = 0x98 ClientCompat = 0xFF )
EMule clients
const ( MajorVersion = 2 MinorVersion = 4 UpdateVersion = 0 )
client version
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 )
const ( // HeaderLength is the length of message header. // 1-byte protocol + 4-byte data size HeaderLength = 5 )
Variables ¶
var ( ErrShortBuffer = io.ErrShortBuffer ErrWrongMessageType = errors.New("wrong message type") )
errors
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) 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) 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) String ¶
func (m CallbackRequestedMessage) String() string
func (CallbackRequestedMessage) Type ¶
func (m CallbackRequestedMessage) Type() uint8
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).
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.
type FileHash ¶
FileHash is a 128 bit GUID hash calculated by the client and based on the file's contents.
type FileSearcher ¶
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) 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) 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) String ¶
func (m GetSourcesMessage) String() string
type Header ¶
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.
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) String ¶
func (m HelloAnswerMessage) String() string
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) String ¶
func (m HelloMessage) String() string
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) String ¶
func (m IDChangeMessage) String() string
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) String ¶
func (m LoginMessage) String() string
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.
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) String ¶
func (m NullMessage) String() string
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) String ¶
func (m OfferFilesMessage) String() string
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) String ¶
func (m RejectedMessage) String() string
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) 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) 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) String ¶
func (m ServerIdentMessage) String() string
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) String ¶
func (m ServerListMessage) String() string
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) String ¶
func (m ServerMessage) String() string
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) 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 Float32Tag ¶
Float32Tag is a tag with float32 value. the type of name must be int or string.
func Hash16Tag ¶
Hash16Tag is a tag with 16-byte hash value. the type of name must be int or string.
func IntegerTag ¶
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 StringTag ¶
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 ¶
Uint16Tag is a tag with uint16 integer value. the type of name must be int or string.
func Uint32Tag ¶
Uint32Tag is a tag with uint32 integer value. the type of name must be int or string.