smb

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2026 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRemoteHostnameSRVSVC

func GetRemoteHostnameSRVSVC(session *smb2.Session, host string) (string, error)

GetRemoteHostnameSRVSVC faz uma chamada NetServerGetInfo via SRVSVC para obter o NetBIOS name real do host

func NetbiosNameFromNBNS

func NetbiosNameFromNBNS(ip string) (string, error)

NetbiosNameFromNBNS tenta obter o NetBIOS name de um host via NBNS (porta 137 UDP)

Types

type Chunk

type Chunk struct {
	Offset int64
	Size   int64
	Data   []byte
}

Chunk represents a piece of a file

type ChunkConfig

type ChunkConfig struct {
	ChunkSize  int64 // Size of each chunk in bytes
	MaxChunks  int   // Maximum number of chunks processed simultaneously
	UseMMap    bool  // Use memory-mapped files for reading
	BufferSize int   // Buffer size for non-mmap operations
}

ChunkConfig configures the chunking behavior

func DefaultChunkConfig

func DefaultChunkConfig() *ChunkConfig

DefaultChunkConfig returns a default configuration for chunking

type ChunkProcessor

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

ChunkProcessor manages the processing of file chunks

func NewChunkProcessor

func NewChunkProcessor(config *Config, processor func([]byte) error) *ChunkProcessor

NewChunkProcessor creates a new chunk processor

func (*ChunkProcessor) ProcessFile

func (p *ChunkProcessor) ProcessFile(file *os.File) error

ProcessFile processes a file in chunks

type Config

type Config struct {
	ChunkSize   int
	MaxChunks   int
	UseMemMap   bool
	ReadTimeout time.Duration
}

Config defines the configuration for chunk processing

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a default configuration

type ConnectionPool

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

ConnectionPool gerencia um pool de conexões SMB

func NewConnectionPool

func NewConnectionPool(config *PoolConfig) *ConnectionPool

NewConnectionPool cria um novo pool de conexões

func (*ConnectionPool) Close

func (p *ConnectionPool) Close()

Close fecha todas as conexões no pool

func (*ConnectionPool) GetConnection

func (p *ConnectionPool) GetConnection(ctx context.Context, config *SMBConfig) (*SMBConnection, error)

GetConnection obtém uma conexão do pool ou cria uma nova

func (*ConnectionPool) GetShare

func (p *ConnectionPool) GetShare(conn *SMBConnection, shareName string) (*smb2.Share, error)

GetShare obtém um share do pool ou cria um novo

func (*ConnectionPool) ReleaseConnection

func (p *ConnectionPool) ReleaseConnection(config *SMBConfig)

ReleaseConnection libera uma conexão de volta para o pool

type Operation

type Operation struct {
	Type     string      // Tipo da operação (read, write, list)
	Data     interface{} // Dados da operação
	Size     int64       // Tamanho estimado da operação
	Callback func() error
}

Operation representa uma operação SMB genérica

type PoolConfig

type PoolConfig struct {
	MaxConnsPerHost int           // Máximo de conexões por host
	IdleTimeout     time.Duration // Tempo máximo que uma conexão pode ficar ociosa
	MaxRetries      int           // Número máximo de tentativas de reconexão
}

PoolConfig configura o comportamento do pool

func DefaultPoolConfig

func DefaultPoolConfig() *PoolConfig

DefaultPoolConfig retorna uma configuração padrão para o pool

type SMBConfig

type SMBConfig struct {
	Host     string
	Port     int
	Domain   string
	Username string
	Password string
	Timeout  time.Duration

	// Novos campos para compatibilidade
	Dialect uint16 // Dialeto SMB a ser forçado
	Signing *bool  // Se deve forçar signing obrigatório

	// New authentication fields
	AuthMethod auth.AuthMethod
	NTLMHash   string
	UseNTLM    bool
}

SMBConfig holds the configuration for SMB connections

type SMBConnection

type SMBConnection struct {
	Config      *SMBConfig
	Connection  *smb2.Session
	IsConnected bool
	// contains filtered or unexported fields
}

SMBConnection represents an SMB connection

func NewSMBConnection

func NewSMBConnection(config *SMBConfig) *SMBConnection

NewSMBConnection creates a new SMB connection

func (*SMBConnection) Connect

func (c *SMBConnection) Connect() error

Connect establishes a connection to the SMB server

func (*SMBConnection) CopyFile

func (c *SMBConnection) CopyFile(share *smb2.Share, remotePath, localPath string) (int64, error)

CopyFile copies a file from the SMB share to the local file system

func (*SMBConnection) Disconnect

func (c *SMBConnection) Disconnect()

Disconnect closes the SMB connection

func (*SMBConnection) IsShareReadable

func (c *SMBConnection) IsShareReadable(shareName string) (bool, error)

IsShareReadable checks if a share is readable

func (*SMBConnection) ListShares

func (c *SMBConnection) ListShares() ([]string, error)

ListShares lists available shares on the SMB server

func (*SMBConnection) MountShare

func (c *SMBConnection) MountShare(shareName string) (*smb2.Share, error)

MountShare mounts a share and returns a file system object

type ThrottleConfig

type ThrottleConfig struct {
	MaxBandwidth  int64         // Bandwidth limit in bytes per second
	MaxConcurrent int           // Maximum concurrent operations
	BatchSize     int           // Size of operation batches
	BatchTimeout  time.Duration // Maximum time to wait for batch completion
}

ThrottleConfig configura o comportamento do throttling

func DefaultThrottleConfig

func DefaultThrottleConfig() *ThrottleConfig

DefaultThrottleConfig retorna uma configuração padrão para throttling

type Throttler

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

Throttler gerencia o throttling de operações SMB

func NewThrottler

func NewThrottler(config *ThrottleConfig) *Throttler

NewThrottler cria um novo throttler

func (*Throttler) Acquire

func (t *Throttler) Acquire()

Acquire adquire uma vaga no semáforo de operações concorrentes

func (*Throttler) AddOperation

func (t *Throttler) AddOperation(op Operation)

AddOperation adiciona uma operação ao batch

func (*Throttler) Allow

func (t *Throttler) Allow() bool

Allow verifica se uma operação pode ser executada imediatamente

func (*Throttler) ProcessBatch

func (t *Throttler) ProcessBatch()

ProcessBatch processa um lote de operações

func (*Throttler) Release

func (t *Throttler) Release()

Release libera uma vaga no semáforo de operações concorrentes

func (*Throttler) StartBatchProcessor

func (t *Throttler) StartBatchProcessor(ctx context.Context)

StartBatchProcessor inicia o processador de batches em background

func (*Throttler) WaitN

func (t *Throttler) WaitN(ctx context.Context, n int) error

WaitN espera pela permissão para transferir n bytes

Jump to

Keyboard shortcuts

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