smbcore

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 14 Imported by: 0

README

smb-core

Standalone SMB protocol core library for host applications.

Module

  • Repository: https://github.com/lteawoo/smb-core.git
  • Go module: github.com/lteawoo/smb-core

Scope

This repository contains protocol-runtime core only. Domain-specific integration (account/space/config wiring) belongs to host adapters outside this repository.

Quality Gates

Run before creating release candidate tags:

./scripts/check-smb-publication-gates.sh

This gate includes native SMB2/3 handshake baseline checks (NEGOTIATE -> SESSION_SETUP -> TREE_CONNECT) in addition to boundary/compat/integration smoke checks.

Versioning

  • RC: v1.0.0-rc.N
  • Stable: v1.0.0
  • Later patch/minor follow SemVer.

Releases

  • Tag push (v*) automatically runs release workflow and publishes GitHub Release.
  • Existing tags can be published with Actions Release workflow via workflow_dispatch.
  • Release note categories follow .github/release.yml.

See docs/release-policy.md and docs/releases/evidence-template.md.

Documentation

Index

Constants

View Source
const (
	DenyReasonReadonlyPhaseDenied = "readonly_phase_denied"
	DenyReasonPermissionDenied    = "permission_denied"
	DenyReasonPathBoundary        = "path_boundary_violation"
)

Variables

View Source
var (
	ErrPermissionDenied    = errors.New(DenyReasonPermissionDenied)
	ErrPathBoundary        = errors.New(DenyReasonPathBoundary)
	ErrReadonlyPhaseDenied = errors.New(DenyReasonReadonlyPhaseDenied)
)
View Source
var (
	ErrRuntimeNotImplemented      = errors.New("smbcore runtime not implemented")
	ErrRuntimeDependenciesMissing = errors.New("smbcore runtime dependencies missing")
	ErrInvalidDialectBounds       = errors.New("invalid smb dialect bounds")
)

Functions

This section is empty.

Types

type Authenticator

type Authenticator interface {
	Authenticate(ctx context.Context, username, password string) (principal string, err error)
	ResolveSMBPassword(ctx context.Context, username string) (password string, err error)
}

type Authorizer

type Authorizer interface {
	CanAccessSpace(ctx context.Context, principal, spaceName string, required Permission) (bool, error)
}

type Config

type Config struct {
	MinDialect   Dialect
	MaxDialect   Dialect
	RolloutPhase RolloutPhase
}

func (Config) Validate

func (c Config) Validate() error

type Dialect

type Dialect string
const (
	Dialect210 Dialect = "2.1"
	Dialect300 Dialect = "3.0"
	Dialect302 Dialect = "3.0.2"
	Dialect311 Dialect = "3.1.1"
)

type DirEntry

type DirEntry struct {
	Name  string
	IsDir bool
	Size  int64
}

type Engine

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

func NewEngine

func NewEngine(cfg Config, auth Authenticator, authz Authorizer, fs FileSystem, telemetry Telemetry) (*Engine, error)

func (*Engine) CheckUsability

func (e *Engine) CheckUsability(ctx context.Context) error

func (*Engine) HandleConn

func (e *Engine) HandleConn(ctx context.Context, conn net.Conn) error

func (*Engine) IsReadOnly

func (e *Engine) IsReadOnly() bool

func (*Engine) Phase

func (e *Engine) Phase() RolloutPhase

func (*Engine) Supports

func (e *Engine) Supports(dialect Dialect) bool

type Event

type Event struct {
	Stage  string
	Reason string
	Err    error
}

type FileSystem

type FileSystem interface {
	Stat(ctx context.Context, principal, virtualPath string) (DirEntry, error)
	List(ctx context.Context, principal, virtualPath string) ([]DirEntry, error)
	Read(ctx context.Context, principal, virtualPath string, offset, limit int64) ([]byte, error)
	CreateOrTruncate(ctx context.Context, principal, virtualPath string) (DirEntry, error)
	Write(ctx context.Context, principal, virtualPath string, offset int64, data []byte) (int64, error)
	Mkdir(ctx context.Context, principal, virtualPath string) (DirEntry, error)
	Rename(ctx context.Context, principal, fromPath, toPath string) error
	Delete(ctx context.Context, principal, virtualPath string, isDir bool) error
}

type Permission

type Permission string
const (
	PermissionRead   Permission = "read"
	PermissionWrite  Permission = "write"
	PermissionManage Permission = "manage"
)

type RolloutPhase

type RolloutPhase string
const (
	RolloutPhaseReadOnly  RolloutPhase = "readonly"
	RolloutPhaseWriteSafe RolloutPhase = "write-safe"
	RolloutPhaseWriteFull RolloutPhase = "write-full"
)

type Runtime

type Runtime interface {
	HandleConn(ctx context.Context, conn net.Conn) error
	Supports(dialect Dialect) bool
	IsReadOnly() bool
	Phase() RolloutPhase
}

type Telemetry

type Telemetry interface {
	OnEvent(event Event)
}

Jump to

Keyboard shortcuts

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