Documentation ¶
Overview ¶
from https://raw.githubusercontent.com/ma6174/mgosniff/cf913f17c2f681392231629e4c29d90b990a6d2d/utils.go
Index ¶
- Constants
- func MustReadInt32(r io.Reader) (n int32)
- func MustReadInt64(r io.Reader) (n int64)
- func MustReadUInt32(r io.Reader) (n uint32)
- func MustReadUInt8(r io.Reader) (n uint8)
- func ReadBytes(r io.Reader, n int) []byte
- func ReadCString(r io.Reader) string
- func ReadDocument(r io.Reader) (m bson.D)
- func ReadDocuments(r io.Reader) (ms []bson.D)
- func ReadInt32(r io.Reader) (n int32, err error)
- func ReadInt64(r io.Reader) *int64
- func ReadOne(r io.Reader) []byte
- func ToJson(v interface{}, l int) string
- type CountingReader
- type Crc32c
- type MSGSection
- type MSGSection_Body
- type MSGSection_DocumentSequence
- type MessageHeader
- type OP_COMPRESSED
- type OP_GETMORE
- type OP_KILL_CURSORS
- type OP_MSG
- type OP_MSG_Flags
- type OP_QUERY
- type OP_QUERY_Flags
- type OP_REPLY
- type OpCode
- type Request
- type WireSerializer
Constants ¶
const ( OpReply = OpCode(1) OpMessage = OpCode(1000) OpUpdate = OpCode(2001) OpInsert = OpCode(2002) Reserved = OpCode(2003) OpQuery = OpCode(2004) OpGetMore = OpCode(2005) OpDelete = OpCode(2006) OpKillCursors = OpCode(2007) OpCompressed = OpCode(2012) OpMsg = OpCode(2013) )
The full set of known request op codes: http://docs.mongodb.org/meta-driver/latest/legacy/mongodb-wire-protocol/#request-opcodes
const HeaderLen = 16
Variables ¶
This section is empty.
Functions ¶
func MustReadInt32 ¶
func MustReadInt64 ¶
func MustReadUInt32 ¶
func MustReadUInt8 ¶
func ReadCString ¶
Types ¶
type CountingReader ¶
type CountingReader struct { BytesRead int // contains filtered or unexported fields }
type MSGSection ¶
type MSGSection interface {
MSGSection()
}
type MSGSection_Body ¶
func (MSGSection_Body) MSGSection ¶
func (MSGSection_Body) MSGSection()
type MSGSection_DocumentSequence ¶
func (MSGSection_DocumentSequence) MSGSection ¶
func (MSGSection_DocumentSequence) MSGSection()
type MessageHeader ¶
type MessageHeader struct { // MessageLength is the total message size, including this header MessageLength int32 // RequestID is the identifier for this miessage RequestID int32 // ResponseTo is the RequestID of the message being responded to. used in DB responses ResponseTo int32 // OpCode is the request type, see consts above. OpCode OpCode }
MessageHeader is the mongo MessageHeader
func ReadHeader ¶
func ReadHeader(r io.Reader) (*MessageHeader, error)
func (*MessageHeader) FromWire ¶
func (m *MessageHeader) FromWire(b []byte)
FromWire reads the wirebytes into this object
func (*MessageHeader) String ¶
func (m *MessageHeader) String() string
String returns a string representation of the message header. Useful for debugging.
func (MessageHeader) ToWire ¶
func (m MessageHeader) ToWire() ([]byte, error)
ToWire converts the MessageHeader to the wire protocol
type OP_COMPRESSED ¶
type OP_COMPRESSED struct { Header MessageHeader OriginalOpcode OpCode UncompressedSize int32 CompressorID wiremessage.CompressorID CompressedMessage []byte }
func (*OP_COMPRESSED) GetHeader ¶
func (m *OP_COMPRESSED) GetHeader() MessageHeader
func (*OP_COMPRESSED) ToWire ¶
func (o *OP_COMPRESSED) ToWire() ([]byte, error)
type OP_GETMORE ¶
type OP_GETMORE struct { Header MessageHeader Flags int32 FullCollectionName string NumberToReturn int32 CursorID int64 }
func (*OP_GETMORE) FromWire ¶
func (m *OP_GETMORE) FromWire(r io.Reader)
func (*OP_GETMORE) GetHeader ¶
func (m *OP_GETMORE) GetHeader() MessageHeader
type OP_KILL_CURSORS ¶
type OP_KILL_CURSORS struct { Header MessageHeader ZERO int32 NumberOfCursorIDs int32 CursorIDs []int64 }
func (*OP_KILL_CURSORS) FromWire ¶
func (m *OP_KILL_CURSORS) FromWire(r io.Reader)
func (*OP_KILL_CURSORS) GetHeader ¶
func (m *OP_KILL_CURSORS) GetHeader() MessageHeader
type OP_MSG ¶
type OP_MSG struct { Header MessageHeader Flags OP_MSG_Flags Sections []MSGSection Checksum uint32 }
func (*OP_MSG) GetHeader ¶
func (m *OP_MSG) GetHeader() MessageHeader
type OP_MSG_Flags ¶
type OP_MSG_Flags int32
func (OP_MSG_Flags) ChecksumPresent ¶
func (f OP_MSG_Flags) ChecksumPresent() bool
func (OP_MSG_Flags) MoreToCome ¶
func (f OP_MSG_Flags) MoreToCome() bool
type OP_QUERY ¶
type OP_QUERY struct { Header MessageHeader Flags OP_QUERY_Flags FullCollectionName string NumberToSkip int32 NumberToReturn int32 Query bson.D ReturnFieldsSelector bson.D }
func (*OP_QUERY) GetHeader ¶
func (m *OP_QUERY) GetHeader() MessageHeader
type OP_QUERY_Flags ¶
type OP_QUERY_Flags int32
func (OP_QUERY_Flags) AwaitData ¶
func (f OP_QUERY_Flags) AwaitData() bool
func (OP_QUERY_Flags) Exhaust ¶
func (f OP_QUERY_Flags) Exhaust() bool
func (OP_QUERY_Flags) NoCursorTimeout ¶
func (f OP_QUERY_Flags) NoCursorTimeout() bool
func (OP_QUERY_Flags) OplogReplay ¶
func (f OP_QUERY_Flags) OplogReplay() bool
func (OP_QUERY_Flags) Partial ¶
func (f OP_QUERY_Flags) Partial() bool
func (OP_QUERY_Flags) SlaveOk ¶
func (f OP_QUERY_Flags) SlaveOk() bool
func (OP_QUERY_Flags) TailableCursor ¶
func (f OP_QUERY_Flags) TailableCursor() bool
type OP_REPLY ¶
type OP_REPLY struct { Header MessageHeader Flags int32 CursorID int64 StartingFrom int32 NumberReturned int32 Documents []bson.D // interface? }
func (*OP_REPLY) GetHeader ¶
func (m *OP_REPLY) GetHeader() MessageHeader
type OpCode ¶
type OpCode int32
OpCode allow identifying the type of operation:
http://docs.mongodb.org/meta-driver/latest/legacy/mongodb-wire-protocol/#request-opcodes
func (OpCode) HasResponse ¶
HasResponse tells us if the operation will have a response from the server.
func (OpCode) IsMutation ¶
IsMutation tells us if the operation will mutate data. These operations can be followed up by a getLastErr operation.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func NewRequestWithHeader ¶
func NewRequestWithHeader(h MessageHeader, c io.Reader) *Request
func (*Request) GetHeader ¶
func (req *Request) GetHeader() *MessageHeader
func (*Request) GetOpCompressed ¶
func (req *Request) GetOpCompressed() *OP_COMPRESSED
func (*Request) GetOpKillCursors ¶
func (req *Request) GetOpKillCursors() *OP_KILL_CURSORS
func (*Request) GetOpMore ¶
func (req *Request) GetOpMore() *OP_GETMORE
func (*Request) GetOpQuery ¶
type WireSerializer ¶
type WireSerializer interface { GetHeader() MessageHeader //ToWire() []byte WriteTo(io.Writer) error }