smbtcp

package
v0.0.0-...-c8c792b Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package smbtcp implements SMB 2 and 3 connections over TCP.

Index

Constants

View Source
const MaxLength = 16777215

MaxLength is the maximum message length when using direct TCP transport.

Variables

View Source
var ErrBadHeader = errors.New("bad smb2 tcp header")

ErrBadHeader is returned when an invalid transport packet header is received from a connection.

Functions

func Listen

func Listen(address string) (smb.Listener, error)

Listen starts listening for SMB messages over TCP at the given address.

Types

type Conn

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

Conn is an SMB connection over TCP.

func (Conn) Close

func (c Conn) Close() error

Close closes the connection. Any blocked Receive or Send operations will be unblocked and return errors.

func (Conn) Create

func (c Conn) Create(length int) smb.Message

Create returns a new message of the requested length.

func (Conn) LocalAddr

func (c Conn) LocalAddr() smb.Addr

LocalAddr returns the local address of the connection.

func (Conn) MaxLength

func (c Conn) MaxLength() int

MaxLength returns the maximum message size for the connection.

func (Conn) Receive

func (c Conn) Receive() (smb.Message, error)

Receive receives a message from the connection.

TODO: Support deadlines and/or cancellation.

func (Conn) RemoteAddr

func (c Conn) RemoteAddr() smb.Addr

RemoteAddr returns the remote address of the connection.

func (Conn) Send

func (c Conn) Send(msg smb.Message) error

Send sends a message to the connection.

TODO: Support deadlines and/or cancellation.

type Header []byte

Header interprets the bytes of a transport packet header for messages sent over TCP.

https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/1dfacde4-b5c7-4494-8a14-a09d3ab4cc83

func (Header) Length

func (h Header) Length() int

Length returns the stream protocol length of h. If h is not valid it may panic.

func (Header) Valid

func (h Header) Valid() bool

Valid returns true if h is valid. It tests the length of h and the value of its zero byte.

type Listener

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

Listener listens for SMB connections over TCP.

func NewListener

func NewListener(l net.Listener, pool MsgPool) Listener

NewListener returns an SMB listener that listens on l. Messages will be allocated from pool.

func (Listener) Accept

func (l Listener) Accept() (smb.Conn, error)

Accept waits for and returns the next SMB connection to the listener.

func (Listener) Addr

func (l Listener) Addr() smb.Addr

Addr returns the local address of the listener.

func (Listener) Close

func (l Listener) Close() error

Close closes the listener. Any blocked Accept operations will be unblocked and return errors.

type MsgPool

type MsgPool interface {
	Get(length int) smb.Message
}

MsgPool is a reusable pool of messages.

Jump to

Keyboard shortcuts

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