nmdc

package
v0.10.7 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2020 License: BSD-3-Clause Imports: 20 Imported by: 6

Documentation

Index

Constants

View Source
const (
	SchemeNMDC  = "dchub" // URL scheme for NMDC protocol
	SchemeNMDCS = "nmdcs" // URL scheme for NMDC-over-TLS protocol
	DefaultPort = 411     // default port for client-hub connections
)
View Source
const (
	ExtNoHello          = "NoHello"
	ExtNoGetINFO        = "NoGetINFO"
	ExtUserCommand      = "UserCommand"
	ExtUserIP2          = "UserIP2"
	ExtTTHSearch        = "TTHSearch"
	ExtZPipe0           = "ZPipe0"
	ExtTLS              = "TLS"
	ExtADCGet           = "ADCGet"
	ExtBotINFO          = "BotINFO"
	ExtHubINFO          = "HubINFO"
	ExtHubTopic         = "HubTopic"
	ExtBotList          = "BotList"
	ExtIN               = "IN"
	ExtMCTo             = "MCTo"
	ExtNickChange       = "NickChange"
	ExtClientNick       = "ClientNick"
	ExtFeaturedNetworks = "FeaturedNetworks"
	ExtGetZBlock        = "GetZBlock"
	ExtClientID         = "ClientID"
	ExtXmlBZList        = "XmlBZList"
	ExtMinislots        = "Minislots"
	ExtTTHL             = "TTHL"
	ExtTTHF             = "TTHF"
	ExtTTHS             = "TTHS"
	ExtZLIG             = "ZLIG"
	ExtACTM             = "ACTM"
	ExtBZList           = "BZList"
	ExtSaltPass         = "SaltPass"
	ExtDHT0             = "DHT0"
	ExtFailOver         = "FailOver"
	ExtOpPlus           = "OpPlus"
	ExtQuickList        = "QuickList"
	ExtBanMsg           = "BanMsg"
	ExtNickRule         = "NickRule"
	ExtSearchRule       = "SearchRule"
	ExtExtJSON2         = "ExtJSON2"
)

list of known extensions

View Source
const (
	TypeSeparator      = UCmdType(0)
	TypeRaw            = UCmdType(1)
	TypeRawNickLimited = UCmdType(2)
	TypeErase          = UCmdType(255)
)
View Source
const (
	ContextHub      = UCmdContext(1)
	ContextUser     = UCmdContext(2)
	ContextSearch   = UCmdContext(4)
	ContextFileList = UCmdContext(8)
)
View Source
const (
	CTMActive = CTMKind(iota)
	CTMPassiveReq
	CTMPassiveResp
)
View Source
const (
	DataTypeAny        = DataType(1)
	DataTypeAudio      = DataType(2)
	DataTypeCompressed = DataType(3)
	DataTypeDocument   = DataType(4)
	DataTypeExecutable = DataType(5)
	DataTypePicture    = DataType(6)
	DataTypeVideo      = DataType(7)
	DataTypeFolders    = DataType(8)
	DataTypeTTH        = DataType(9)
	DataTypeDiskImage  = DataType(10)
	DataTypeComics     = DataType(11)
	DataTypeBook       = DataType(12)
	DataTypeMagnet     = DataType(13)
)
View Source
const (
	UserModeUnknown = UserMode(0)
	UserModeActive  = UserMode('A')
	UserModePassive = UserMode('P')
	UserModeSOCKS5  = UserMode('5')
)
View Source
const (
	FlagStatusNormal   = UserFlag(0x01)
	FlagStatusAway     = UserFlag(0x02)
	FlagStatusServer   = UserFlag(0x04)
	FlagStatusFireball = UserFlag(0x08)
	FlagTLSDownload    = UserFlag(0x10)
	FlagTLSUpload      = UserFlag(0x20)
	FlagIPv4           = UserFlag(0x40)
	FlagIPv6           = UserFlag(0x80)

	FlagTLS = FlagTLSUpload | FlagTLSDownload
)
View Source
const (
	ConnSpeedModem  = "1"
	ConnSpeedServer = "1000"
)

Used by some clients to set a different icon.

View Source
const DefaultKeyMagic = 5

DefaultKeyMagic is a magic byte used in the C-H and C-C handshakes.

View Source
const Delimiter = '|'

Delimiter of the NMDC protocol.

View Source
const (
	ExtLocale = "Locale"
)

proposals

Variables

This section is empty.

Functions

func IsRegistered added in v0.6.4

func IsRegistered(typ string) bool

IsRegistered check if a message type is registered.

func IsRegisteredBytes added in v0.10.0

func IsRegisteredBytes(typ []byte) bool

IsRegisteredBytes is like IsRegistered but accepts a byte slice.

func Marshal

func Marshal(enc *TextEncoder, m Message) ([]byte, error)

Marshal encodes NMDC message. The resulting slice will contain a command name, a payload and '|' delimiter.

func MarshalTo

func MarshalTo(enc *TextEncoder, buf *bytes.Buffer, m Message) error

MarshalTo encodes NMDC message into a buffer. It will write a command name, a payload and '|' delimiter.

func NormalizeAddr added in v0.2.0

func NormalizeAddr(addr string) (string, error)

NormalizeAddr parses and normalizes the address to scheme://host[:port] format.

func ParseAddr added in v0.2.0

func ParseAddr(addr string) (*url.URL, error)

ParseAddr parses an NMDC address as a URL. It will assume a dchub:// scheme if none is set.

func RegisterMessage

func RegisterMessage(m Message)

RegisterMessage registers a new protocol message type. It will be associated with a name returned by Type method. Messages registered this way will be automatically decoded by the Reader.

func RegisteredTypes added in v0.6.4

func RegisteredTypes() []string

RegisteredTypes list all registered message types.

func UnescapeBytes added in v0.3.0

func UnescapeBytes(b []byte) []byte

Types

type ADCGet added in v0.10.0

type ADCGet struct {
	ContentType     String
	Identifier      String
	Start           uint64
	Length          int64
	Compressed      bool
	DownloadedBytes *uint64
}

func (*ADCGet) MarshalNMDC added in v0.10.0

func (m *ADCGet) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*ADCGet) Type added in v0.10.0

func (*ADCGet) Type() string

func (*ADCGet) UnmarshalNMDC added in v0.10.0

func (m *ADCGet) UnmarshalNMDC(dec *TextDecoder, data []byte) error

type ADCSnd added in v0.10.0

type ADCSnd struct {
	ContentType String
	Identifier  String
	Start       uint64
	Length      uint64
	Compressed  bool
}

func (*ADCSnd) MarshalNMDC added in v0.10.0

func (m *ADCSnd) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*ADCSnd) Type added in v0.10.0

func (*ADCSnd) Type() string

func (*ADCSnd) UnmarshalNMDC added in v0.10.0

func (m *ADCSnd) UnmarshalNMDC(dec *TextDecoder, data []byte) error

type BadPass

type BadPass struct {
	NoArgs
}

func (*BadPass) Type

func (*BadPass) Type() string

type BotINFO

type BotINFO struct {
	String
}

BotINFO is sent by the pinger to the hub to get a HubINFO.

func (*BotINFO) Type

func (*BotINFO) Type() string

type BotList

type BotList struct {
	Names
}

BotList is a list of bots on the hub. Requires 'BotList' extension.

http://nmdc.sourceforge.net/NMDC.html#_botlist

func (*BotList) Type

func (*BotList) Type() string

type CTMKind added in v0.5.2

type CTMKind int

type ChatMessage

type ChatMessage struct {
	Name string
	Text string
}

func (*ChatMessage) MarshalNMDC

func (m *ChatMessage) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*ChatMessage) String

func (m *ChatMessage) String() string

func (*ChatMessage) Type

func (m *ChatMessage) Type() string

func (*ChatMessage) UnmarshalNMDC

func (m *ChatMessage) UnmarshalNMDC(dec *TextDecoder, data []byte) error

type Close added in v0.10.0

type Close struct {
	Name
}

func (*Close) Type added in v0.10.0

func (*Close) Type() string

type ConnectToMe

type ConnectToMe struct {
	Targ    string
	Src     string
	Address string
	Kind    CTMKind
	Secure  bool
}

func (*ConnectToMe) MarshalNMDC

func (m *ConnectToMe) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*ConnectToMe) Type

func (m *ConnectToMe) Type() string

func (*ConnectToMe) UnmarshalNMDC

func (m *ConnectToMe) UnmarshalNMDC(dec *TextDecoder, data []byte) error

type DataType

type DataType uint

type Direction added in v0.10.0

type Direction struct {
	Upload bool
	Number uint
}

func (*Direction) MarshalNMDC added in v0.10.0

func (m *Direction) MarshalNMDC(_ *TextEncoder, buf *bytes.Buffer) error

func (*Direction) Type added in v0.10.0

func (*Direction) Type() string

func (*Direction) UnmarshalNMDC added in v0.10.0

func (m *Direction) UnmarshalNMDC(_ *TextDecoder, data []byte) error

type ErrProtocolViolation

type ErrProtocolViolation = lineproto.ErrProtocolViolation

type ErrUnexpectedCommand

type ErrUnexpectedCommand struct {
	Expected string
	Received *RawMessage
}

func (*ErrUnexpectedCommand) Error

func (e *ErrUnexpectedCommand) Error() string

type Error

type Error struct {
	Err error
}

func (*Error) MarshalNMDC

func (m *Error) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*Error) Type

func (m *Error) Type() string

func (*Error) UnmarshalNMDC

func (m *Error) UnmarshalNMDC(dec *TextDecoder, text []byte) error

type Extensions

type Extensions map[string]struct{}

Extensions is an unordered set of protocol extensions.

func (Extensions) Clone

func (f Extensions) Clone() Extensions

func (Extensions) Has

func (f Extensions) Has(name string) bool

func (Extensions) Intersect

func (f Extensions) Intersect(f2 Extensions) Extensions

func (Extensions) IntersectList

func (f Extensions) IntersectList(f2 []string) Extensions

func (Extensions) List

func (f Extensions) List() []string

func (Extensions) Set

func (f Extensions) Set(name string)

type FailOver

type FailOver struct {
	Host []string
}

func (*FailOver) MarshalNMDC

func (m *FailOver) MarshalNMDC(_ *TextEncoder, buf *bytes.Buffer) error

func (*FailOver) Type

func (*FailOver) Type() string

func (*FailOver) UnmarshalNMDC

func (m *FailOver) UnmarshalNMDC(_ *TextDecoder, data []byte) error

type Failed

type Failed struct {
	Err error
}

func (*Failed) MarshalNMDC

func (m *Failed) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*Failed) Type

func (m *Failed) Type() string

func (*Failed) UnmarshalNMDC

func (m *Failed) UnmarshalNMDC(dec *TextDecoder, text []byte) error

type ForceMove added in v0.7.4

type ForceMove struct {
	Address string
}

func (*ForceMove) MarshalNMDC added in v0.7.4

func (m *ForceMove) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*ForceMove) Type added in v0.7.4

func (*ForceMove) Type() string

func (*ForceMove) UnmarshalNMDC added in v0.7.4

func (m *ForceMove) UnmarshalNMDC(dec *TextDecoder, data []byte) error

type GetNickList

type GetNickList struct {
	NoArgs
}

GetNickList is sent by the client to the hub to retrieve a list of online users.

http://nmdc.sourceforge.net/NMDC.html#_getnicklist

func (*GetNickList) Type

func (*GetNickList) Type() string

type GetPass

type GetPass struct {
	NoArgs
}

func (*GetPass) Type

func (*GetPass) Type() string

type GetTopic added in v0.10.0

type GetTopic struct {
	NoArgs
}

func (*GetTopic) Type added in v0.10.0

func (*GetTopic) Type() string

type Hello

type Hello struct {
	Name
}

func (*Hello) Type

func (*Hello) Type() string

type HubINFO

type HubINFO struct {
	Name     string
	Host     string
	Desc     string
	I1       int // TODO
	I2       int // TODO
	I3       int // TODO
	I4       int // TODO
	Soft     types.Software
	Owner    string
	State    string // TODO
	Encoding string
}

HubINFO is a detailed hub information exposed only after receiving BotINFO.

func (*HubINFO) MarshalNMDC

func (m *HubINFO) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*HubINFO) Type

func (*HubINFO) Type() string

func (*HubINFO) UnmarshalNMDC

func (m *HubINFO) UnmarshalNMDC(dec *TextDecoder, data []byte) error

type HubIsFull added in v0.9.1

type HubIsFull struct {
	NoArgs
}

func (*HubIsFull) Type added in v0.9.1

func (*HubIsFull) Type() string

type HubName

type HubName struct {
	String
}

func (*HubName) Type

func (*HubName) Type() string

type HubTopic

type HubTopic struct {
	Text string
}

func (*HubTopic) MarshalNMDC

func (m *HubTopic) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*HubTopic) Type

func (*HubTopic) Type() string

func (*HubTopic) UnmarshalNMDC

func (m *HubTopic) UnmarshalNMDC(dec *TextDecoder, data []byte) error

type Key

type Key struct {
	Key string
}

Key is a response to a pseudo-cryptographic challenge represented by Lock.

http://nmdc.sourceforge.net/NMDC.html#_key

func (*Key) MarshalNMDC

func (m *Key) MarshalNMDC(_ *TextEncoder, buf *bytes.Buffer) error

func (*Key) Type

func (*Key) Type() string

func (*Key) UnmarshalNMDC

func (m *Key) UnmarshalNMDC(_ *TextDecoder, data []byte) error

type Kick added in v0.10.0

type Kick struct {
	Name
}

func (*Kick) Type added in v0.10.0

func (*Kick) Type() string

type Lock

type Lock struct {
	NoExt bool
	Lock  string
	PK    string
	Ref   string
}

Lock is a pseudo-cryptographic challenge sent by the server to the client.

http://nmdc.sourceforge.net/NMDC.html#_lock

func (*Lock) CustomKey

func (m *Lock) CustomKey(magic byte, full bool) *Key

CustomKey calculates a response to the challenge and allows to specify additional parameters.

func (*Lock) Key

func (m *Lock) Key() *Key

Key calculates a response to the challenge.

func (*Lock) LockString

func (m *Lock) LockString(full bool) string

func (*Lock) MarshalNMDC

func (m *Lock) MarshalNMDC(_ *TextEncoder, buf *bytes.Buffer) error

func (*Lock) Type

func (*Lock) Type() string

func (*Lock) UnmarshalNMDC

func (m *Lock) UnmarshalNMDC(_ *TextDecoder, data []byte) error

type LogedIn added in v0.10.0

type LogedIn struct {
	Name
}

func (*LogedIn) Type added in v0.10.0

func (*LogedIn) Type() string

type MCTo

type MCTo struct {
	To, From string
	Text     string
}

func (*MCTo) MarshalNMDC

func (m *MCTo) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*MCTo) Type

func (*MCTo) Type() string

func (*MCTo) UnmarshalNMDC

func (m *MCTo) UnmarshalNMDC(dec *TextDecoder, data []byte) error

type MaxedOut added in v0.10.0

type MaxedOut struct {
	NoArgs
}

func (*MaxedOut) Type added in v0.10.0

func (*MaxedOut) Type() string

type Message

type Message interface {
	// Type returns a NMDC command type name without '$' prefix.
	// Chat messages are a special case and returns empty type name.
	Type() string
	// MarshalNMDC encodes NMDC protocol message using provided text encoding into a buffer.
	// Message should only encode it's payload without a command name or '|' delimiter.
	// If encoder is nil, UTF-8 encoding is assumed.
	MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error
	// UnmarshalNMDC decodes NMDC protocol message using provided text encoding.
	// Buffer will only contain message payload without a command name or '|' delimiter.
	// If decoder is nil, UTF-8 encoding is assumed.
	UnmarshalNMDC(dec *TextDecoder, data []byte) error
}

Message is an interface for all NMDC protocol messages.

func NewMessage

func NewMessage(typ string) Message

NewMessage creates a new message by type name. If a command type is unknown, RawMessage will be returned.

See RegisterMessage for more details.

func Unmarshal

func Unmarshal(dec *TextDecoder, data []byte) (Message, error)

Unmarshal decodes a single NMDC message from the buffer.

type MyINFO

type MyINFO struct {
	Name           string
	Desc           string
	Client         types.Software
	Mode           UserMode
	HubsNormal     int
	HubsRegistered int
	HubsOperator   int
	Slots          int
	Extra          map[string]string
	Conn           string
	Flag           UserFlag
	Email          string
	ShareSize      uint64
}

func (*MyINFO) MarshalNMDC

func (m *MyINFO) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*MyINFO) Type

func (*MyINFO) Type() string

func (*MyINFO) UnmarshalNMDC

func (m *MyINFO) UnmarshalNMDC(dec *TextDecoder, data []byte) error

type MyNick

type MyNick struct {
	Name
}

MyNick is sent in C-C connections for clients to be able to identify each other.

func (*MyNick) Type

func (*MyNick) Type() string

type MyPass

type MyPass struct {
	String
}

func (*MyPass) Type

func (*MyPass) Type() string

type Name

type Name string

Name is a string encoded and decoded as a NMDC user name. It has more restrictions than a String type.

func (Name) MarshalNMDC

func (s Name) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*Name) UnmarshalNMDC

func (s *Name) UnmarshalNMDC(dec *TextDecoder, data []byte) error

type Names

type Names []string

Names is a list of user names separated by '$$'.

See OpList and BotList.

func (Names) MarshalNMDC

func (m Names) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*Names) UnmarshalNMDC

func (m *Names) UnmarshalNMDC(dec *TextDecoder, data []byte) error

type NoArgs

type NoArgs struct{}

NoArgs is an embeddable type for protocol commands with no arguments.

func (*NoArgs) MarshalNMDC

func (*NoArgs) MarshalNMDC(_ *TextEncoder, _ *bytes.Buffer) error

func (*NoArgs) UnmarshalNMDC

func (*NoArgs) UnmarshalNMDC(_ *TextDecoder, data []byte) error

type OpList

type OpList struct {
	Names
}

OpList is a list of hub operators.

http://nmdc.sourceforge.net/NMDC.html#_oplist

func (*OpList) Type

func (*OpList) Type() string

type PrivateMessage

type PrivateMessage struct {
	To, From string
	Name     string
	Text     string
}

func (*PrivateMessage) MarshalNMDC

func (m *PrivateMessage) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*PrivateMessage) Type

func (m *PrivateMessage) Type() string

func (*PrivateMessage) UnmarshalNMDC

func (m *PrivateMessage) UnmarshalNMDC(dec *TextDecoder, data []byte) error

type Quit

type Quit struct {
	Name
}

Quit is a notification about user quiting the hub.

func (*Quit) Type

func (*Quit) Type() string

type RawMessage

type RawMessage struct {
	Typ  string
	Data []byte
}

RawMessage is a raw NMDC message in the connection encoding.

func (*RawMessage) MarshalNMDC

func (m *RawMessage) MarshalNMDC(_ *TextEncoder, buf *bytes.Buffer) error

Type implements Message.

func (*RawMessage) Type

func (m *RawMessage) Type() string

Type implements Message.

func (*RawMessage) UnmarshalNMDC

func (m *RawMessage) UnmarshalNMDC(_ *TextDecoder, data []byte) error

Type implements Message.

type Reader

type Reader struct {
	*lineproto.Reader

	// OnKeepAlive is called when an empty (keep-alive) message is received.
	OnKeepAlive func() error

	// OnUnknownEncoding is called when a text with non-UTF8 encoding is received.
	// It may either return a new decoder or return an error to fail the decoding.
	OnUnknownEncoding func(text []byte) (*TextDecoder, error)

	// OnUnmarshalError is called when a message cannot be parsed.
	// It may either return false, nil to skip the message or true, err to return an error.
	OnUnmarshalError func(text []byte, err error) (bool, error)
	// contains filtered or unexported fields
}

Reader is not safe for concurrent use.

func NewReader

func NewReader(r io.Reader) *Reader

func (*Reader) Decoder added in v0.6.3

func (r *Reader) Decoder() *TextDecoder

Decoder returns current text decoder.

func (*Reader) OnMessage

func (r *Reader) OnMessage(fnc func(m Message) (bool, error))

OnMessage registers a hook that is called each time a protocol message is decoded. The function may return (false, nil) to ignore the message.

This method is not concurrent-safe.

func (*Reader) OnRawMessage

func (r *Reader) OnRawMessage(fnc func(cmd, args []byte) (bool, error))

OnRawCommand registers a hook that is called each time a message is received. Protocol commands will have a non-nil name, while chat messages will have a nil name. The function may return (false, nil) to ignore the message.

This method is not concurrent-safe.

func (*Reader) ReadMsg

func (r *Reader) ReadMsg() (Message, error)

ReadMsg reads a single message.

func (*Reader) ReadMsgTo

func (r *Reader) ReadMsgTo(m Message) error

ReadMsgTo will read a message to a pointer passed to the function. If the message read has a different type, an error will be returned.

func (*Reader) ReadMsgToAny added in v0.5.4

func (r *Reader) ReadMsgToAny(arr ...Message) (Message, error)

ReadMsgToAny will read a message to one of the pointers passed to the function. If the message read doesn't match any of the types, an error will be returned. The method returns a message that was decoded.

func (*Reader) SetDecoder

func (r *Reader) SetDecoder(dec *TextDecoder)

SetDecoder sets a text decoder for the connection.

func (*Reader) SetMaxCmdName

func (r *Reader) SetMaxCmdName(n int)

SetMaxCmdName sets a maximal length of the protocol command name in bytes.

type RevConnectToMe

type RevConnectToMe struct {
	From, To string
}

func (*RevConnectToMe) MarshalNMDC

func (m *RevConnectToMe) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*RevConnectToMe) Type

func (m *RevConnectToMe) Type() string

func (*RevConnectToMe) UnmarshalNMDC

func (m *RevConnectToMe) UnmarshalNMDC(dec *TextDecoder, data []byte) error

type SR

type SR struct {
	From       string
	Path       []string
	IsDir      bool
	Size       uint64 // only set for files
	FreeSlots  int
	TotalSlots int
	HubName    string
	TTH        *TTH
	HubAddress string
	To         string
}

func (*SR) MarshalNMDC

func (m *SR) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*SR) Type

func (*SR) Type() string

func (*SR) UnmarshalNMDC

func (m *SR) UnmarshalNMDC(dec *TextDecoder, data []byte) error
type Search struct {
	Address string
	User    string

	SizeRestricted bool
	IsMaxSize      bool
	Size           uint64
	DataType       DataType

	Pattern string
	TTH     *TTH
}

func (*Search) MarshalNMDC

func (m *Search) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*Search) Type

func (*Search) Type() string

func (*Search) UnmarshalNMDC

func (m *Search) UnmarshalNMDC(dec *TextDecoder, data []byte) error

type SetIcon added in v0.10.5

type SetIcon struct {
	String
}

func (*SetIcon) Type added in v0.10.5

func (*SetIcon) Type() string
type SetLogo struct {
	String
}

func (*SetLogo) Type added in v0.10.5

func (*SetLogo) Type() string

type SetTopic added in v0.10.0

type SetTopic struct {
	String
}

func (*SetTopic) Type added in v0.10.0

func (*SetTopic) Type() string

type String

type String string

String is a value type encoded and decoded as a NMDC string value.

func (String) MarshalNMDC

func (s String) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*String) UnmarshalNMDC

func (s *String) UnmarshalNMDC(dec *TextDecoder, data []byte) error

type Supports

type Supports struct {
	Ext []string
}

Supports command lists extensions supported by the peer.

http://nmdc.sourceforge.net/NMDC.html#_supports

func (*Supports) Intersect

func (m *Supports) Intersect(m2 *Supports) Supports

Intersect two sets of extensions and return a new set as a result.

func (*Supports) MarshalNMDC

func (m *Supports) MarshalNMDC(_ *TextEncoder, buf *bytes.Buffer) error

func (*Supports) Type

func (*Supports) Type() string

func (*Supports) UnmarshalNMDC

func (m *Supports) UnmarshalNMDC(_ *TextDecoder, data []byte) error

type TTH

type TTH = tiger.Hash

type TTHSearchActive added in v0.5.2

type TTHSearchActive struct {
	TTH     TTH
	Address string
}

TTHSearchActive is added by TTHS extension.

func (*TTHSearchActive) MarshalNMDC added in v0.5.2

func (m *TTHSearchActive) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*TTHSearchActive) Type added in v0.5.2

func (*TTHSearchActive) Type() string

func (*TTHSearchActive) UnmarshalNMDC added in v0.5.2

func (m *TTHSearchActive) UnmarshalNMDC(_ *TextDecoder, data []byte) error

type TTHSearchPassive added in v0.5.2

type TTHSearchPassive struct {
	TTH  TTH
	User string
}

TTHSearchPassive is added by TTHS extension.

func (*TTHSearchPassive) MarshalNMDC added in v0.5.2

func (m *TTHSearchPassive) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*TTHSearchPassive) Type added in v0.5.2

func (*TTHSearchPassive) Type() string

func (*TTHSearchPassive) UnmarshalNMDC added in v0.5.2

func (m *TTHSearchPassive) UnmarshalNMDC(dec *TextDecoder, data []byte) error

type TextDecoder

type TextDecoder = encoding.Decoder

these two aliases allows package users to omit x/text import

type TextEncoder

type TextEncoder = encoding.Encoder

these two aliases allows package users to omit x/text import

type UCmdContext

type UCmdContext int

type UCmdType

type UCmdType int

type UserAddress added in v0.8.0

type UserAddress struct {
	Name string
	IP   string
}

type UserCommand

type UserCommand struct {
	Typ     UCmdType
	Context UCmdContext
	Path    []string
	Command string
}

func (*UserCommand) MarshalNMDC

func (m *UserCommand) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*UserCommand) Type

func (*UserCommand) Type() string

func (*UserCommand) UnmarshalNMDC

func (m *UserCommand) UnmarshalNMDC(dec *TextDecoder, data []byte) error

type UserFlag

type UserFlag byte

func (UserFlag) IsSet

func (f UserFlag) IsSet(f2 UserFlag) bool

type UserIP

type UserIP struct {
	List []UserAddress
}

func (*UserIP) MarshalNMDC

func (m *UserIP) MarshalNMDC(enc *TextEncoder, buf *bytes.Buffer) error

func (*UserIP) Type

func (*UserIP) Type() string

func (*UserIP) UnmarshalNMDC

func (m *UserIP) UnmarshalNMDC(dec *TextDecoder, data []byte) error

type UserMode

type UserMode byte

type ValidateDenide

type ValidateDenide struct {
	Name
}

func (*ValidateDenide) Type

func (*ValidateDenide) Type() string

type ValidateNick

type ValidateNick struct {
	Name
}

ValidateNick is sent from the client to the hub as a request to enter with a specific user name.

The hub will send Hello in case of success or ValidateDenide in case of an error.

func (*ValidateNick) Type

func (*ValidateNick) Type() string

type Version

type Version struct {
	Vers string
}

func (*Version) MarshalNMDC

func (m *Version) MarshalNMDC(_ *TextEncoder, buf *bytes.Buffer) error

func (*Version) Type

func (*Version) Type() string

func (*Version) UnmarshalNMDC

func (m *Version) UnmarshalNMDC(_ *TextDecoder, data []byte) error

type Writer added in v0.2.0

type Writer struct {
	*lineproto.Writer
	// contains filtered or unexported fields
}

Writer is protocol message writer for NMDC protocol. It's not safe for a concurrent use.

func NewWriter added in v0.2.0

func NewWriter(w io.Writer) *Writer

NewWriter creates a new NMDC protocol writer with a default buffer size.

func NewWriterSize added in v0.7.3

func NewWriterSize(w io.Writer, buf int) *Writer

NewWriterSize creates a new NMDC protocol writer with a specified buffer size.

func (*Writer) Encoder added in v0.2.0

func (w *Writer) Encoder() *TextEncoder

Encoder returns current text encoder.

func (*Writer) OnMessage added in v0.2.1

func (w *Writer) OnMessage(fnc func(m Message) (bool, error))

OnMessage registers a hook that is called each time a NMDC protocol message is written. The function may return (false, nil) to skip writing the message.

This method is not concurrent-safe.

func (*Writer) SetEncoder added in v0.2.0

func (w *Writer) SetEncoder(enc *TextEncoder)

SetEncoder sets a text encoding used to write messages.

func (*Writer) WriteKeepAlive added in v0.10.0

func (w *Writer) WriteKeepAlive() error

WriteKeepAlive writes an empty (keep alive) message. It is caller's responsibility to flush the writer.

func (*Writer) WriteMsg added in v0.2.0

func (w *Writer) WriteMsg(msg ...Message) error

WriteMsg encodes and writes a NMDC protocol message.

func (*Writer) ZOn added in v0.8.1

func (w *Writer) ZOn() error

ZOn enables compression on this writer.

func (*Writer) ZOnLevel added in v0.8.1

func (w *Writer) ZOnLevel(lvl int) error

ZOnLevel enables compression with a given level on this writer.

type ZOn added in v0.8.0

type ZOn struct {
	NoArgs
}

func (*ZOn) Type added in v0.8.0

func (*ZOn) Type() string

Jump to

Keyboard shortcuts

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