smbserver

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: 10 Imported by: 0

Documentation

Overview

Package smbserver provides an SMB version 2 and 3 server implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(l smb.Listener, id smbid.ID, handler Handler) error

Serve starts serving connections on l with the given handler.

Types

type Conn

type Conn struct {
	smb.Conn
	Sequencer
	ConnState
	GlobalState
}

Conn represents the server's view of an SMB connection. It holds connection-specific state.

https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/0055d1e1-18fa-4c1c-8941-df7203d440c7

func (*Conn) Marshal

func (c *Conn) Marshal(messageID uint64, credits uint16, r Response) error

Marshal marshals a response and sends it to the client.

type ConnState

type ConnState struct {
	ClientCapabilities smbcap.Flags
	Dialect            smbdialect.State
	CreationTime       time.Time
	ClientSecurity     smbsecmode.Flags
	SupportMultiCredit bool
	MaxTransactSize    uint32
	MaxReadSize        uint32
	MaxWriteSize       uint32
}

ConnState stores information about a connection on the server.

type GlobalState

type GlobalState struct {
	Server                smbid.ID
	RequireMessageSigning bool
	EncryptionSupported   bool
	CompressionSupported  bool
}

GlobalState stores global information about the server.

type Handler

type Handler interface {
	ServeSMB(Conn)
}

A Handler handles SMB connections.

type HandlerFunc

type HandlerFunc func(c Conn)

HandlerFunc is a function that can act as a Handler.

func (HandlerFunc) ServeSMB

func (h HandlerFunc) ServeSMB(c Conn)

ServeSMB handles the given SMB connection.

type Response

type Response interface {
	Command() smbcommand.Code
	Status() uint32 // TODO: Make this strongly typed
	Size() int
	Marshal([]byte)
}

Response can be marshaled into a message.

type Sequencer

type Sequencer interface {
	// Credits returns the current number of credits allocated to the
	// connection. This is the number of outstanding sequence numbers.
	Credits() int

	// Expand increases the number of outstanding sequence numbers for the
	// connection by credits.
	//
	// If the expansion would cause the sequence numbers to wrap or a limit
	// to be exceeded it returns false.
	Expand(credits int) (ok bool)

	// Consume removes the given sequence number from the list of outstanding
	// sequence numbers.
	//
	// If the sequence number has already been consumed or is not outstanding
	// it returns false.
	Consume(n smb.SeqNum) (ok bool)
}

A Sequencer keeps track of message sequence numbers for a connection.

https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/dec8e905-9477-4c3f-bc64-b18d97c9f905

type Server

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

Server responds to SMB connection requests.

func New

func New(id smbid.ID, h Handler) *Server

New returns a new SMB server with message handler h.

func (Server) Serve

func (s Server) Serve(l smb.Listener) error

Serve causes s to start serving connections on l.

Jump to

Keyboard shortcuts

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