package smb2

Import Path
	github.com/hirochachacha/go-smb2 (on go.dev)

Dependency Relation
	imports 36 packages, and imported by one package

Involved Source Files all.go client.go client_fs.go conn.go credit.go deprecated.go errors.go feature.go filepath.go initiator.go kdf.go path.go session.go Package smb2 implements the SMB2/3 client in [MS-SMB2]. https://msdn.microsoft.com/en-us/library/cc246482.aspx This package doesn't support CAP_UNIX extension. Symlink is supported by FSCTL_SET_REPARSE_POINT and FSCTL_GET_REPARSE_POINT. The symlink-following algorithm is explained in 2.2.2.2.1 and 2.2.2.2.1.1. https://msdn.microsoft.com/en-us/library/cc246542.aspx Supported features and protocol versions are declared in feature.go. spnego.go transport.go tree_conn.go
Code Examples { conn, err := net.Dial("tcp", "localhost:445") if err != nil { panic(err) } defer conn.Close() d := &smb2.Dialer{ Initiator: &smb2.NTLMInitiator{ User: "Guest", Password: "", Domain: "MicrosoftAccount", }, } c, err := d.Dial(conn) if err != nil { panic(err) } defer c.Logoff() fs, err := c.Mount(`\\localhost\share`) if err != nil { panic(err) } defer fs.Umount() f, err := fs.Create("hello.txt") if err != nil { panic(err) } defer fs.Remove("hello.txt") defer f.Close() _, err = f.Write([]byte("Hello world!")) if err != nil { panic(err) } _, err = f.Seek(0, io.SeekStart) if err != nil { panic(err) } bs, err := ioutil.ReadAll(f) if err != nil { panic(err) } fmt.Println(string(bs)) }
Package-Level Type Names (total 18)
/* sort by: | */
type Client = Session (struct)
ContextError wraps a context error to support os.IsTimeout function. Err error (*ContextError) Error() string (*ContextError) Timeout() bool *ContextError : error
Dialer contains options for func (*Dialer) Dial. Initiator Initiator // if it's zero, clientMaxCreditBalance is used. (See feature.go for more details) Negotiator Negotiator Dial performs negotiation and authentication. It returns a session. It doesn't support NetBIOS transport. This implementation doesn't support multi-session on the same TCP connection. If you want to use another session, you need to prepare another TCP connection at first. DialContext performs negotiation and authentication using the provided context. Note that returned session doesn't inherit context. If you want to use the same context, call Session.WithContext manually. This implementation doesn't support multi-session on the same TCP connection. If you want to use another session, you need to prepare another TCP connection at first.
(*File) Chmod(mode os.FileMode) error (*File) Close() error (*File) Name() string (*File) Read(b []byte) (n int, err error) ReadAt implements io.ReaderAt. ReadFrom implements io.ReadFrom. If r is *File on the same *Share as f, it invokes server-side copy. (*File) Readdir(n int) (fi []os.FileInfo, err error) (*File) Readdirnames(n int) (names []string, err error) Seek implements io.Seeker. (*File) Stat() (os.FileInfo, error) (*File) Statfs() (FileFsInfo, error) (*File) Sync() (err error) (*File) Truncate(size int64) error (*File) Write(b []byte) (n int, err error) WriteAt implements io.WriterAt. (*File) WriteString(s string) (n int, err error) WriteTo implements io.WriteTo. If w is *File on the same *Share as f, it invokes server-side copy. *File : github.com/pkg/sftp.WriterAtReaderAt *File : go.uber.org/zap.Sink *File : go.uber.org/zap/zapcore.WriteSyncer *File : internal/bisect.Writer *File : io.Closer *File : io.ReadCloser *File : io.Reader *File : io.ReaderAt *File : io.ReaderFrom *File : io.ReadSeekCloser *File : io.ReadSeeker *File : io.ReadWriteCloser *File : io.ReadWriter *File : io.ReadWriteSeeker *File : io.Seeker *File : io.StringWriter *File : io.WriteCloser *File : io.Writer *File : io.WriterAt *File : io.WriterTo *File : io.WriteSeeker *File : io/fs.File *File : mime/multipart.File *File : net/http.File func (*Share).Create(name string) (*File, error) func (*Share).Open(name string) (*File, error) func (*Share).OpenFile(name string, flag int, perm os.FileMode) (*File, error)
( FileFsInfo) AvailableBlockCount() uint64 ( FileFsInfo) BlockSize() uint64 ( FileFsInfo) FragmentSize() uint64 ( FileFsInfo) FreeBlockCount() uint64 ( FileFsInfo) TotalBlockCount() uint64 func (*File).Statfs() (FileFsInfo, error) func (*Share).Statfs(name string) (FileFsInfo, error)
AllocationSize int64 ChangeTime time.Time CreationTime time.Time EndOfFile int64 FileAttributes uint32 FileName string LastAccessTime time.Time LastWriteTime time.Time (*FileStat) IsDir() bool (*FileStat) ModTime() time.Time (*FileStat) Mode() os.FileMode (*FileStat) Name() string (*FileStat) Size() int64 (*FileStat) Sys() interface{} *FileStat : io/fs.FileInfo
*NTLMInitiator
InternalError represents internal error. Message string (*InternalError) Error() string *InternalError : error
InvalidResponseError represents a data sent by the server is corrupted or unexpected. Message string (*InvalidResponseError) Error() string *InvalidResponseError : error
Negotiator contains options for func (*Dialer) Dial. // if it's zero, generated by crypto/rand. // enforce signing? // if it's zero, clientDialects is used. (See feature.go for more details)
NTLMInitiator implements session-setup through NTLMv2. It doesn't support NTLMv1. You can use Hash instead of Password. Domain string Hash []byte Password string TargetSPN string User string Workstation string *NTLMInitiator : Initiator
type RemoteFile = File (struct)
type RemoteFileStat = FileStat (struct)
type RemoteFileSystem = Share (struct)
ResponseError represents a error with a nt status code sent by the server. The NTSTATUS is defined in [MS-ERREF]. https://msdn.microsoft.com/en-au/library/cc704588.aspx // NTSTATUS (*ResponseError) Error() string *ResponseError : error
Session represents a SMB session. (*Session) ListSharenames() ([]string, error) Logoff invalidates the current SMB session. Mount mounts the SMB share. sharename must follow format like `<share>` or `\\<server>\<share>`. Note that the mounted share doesn't inherit session's context. If you want to use the same context, call Share.WithContext manually. (*Session) WithContext(ctx context.Context) *Session func (*Dialer).Dial(tcpConn net.Conn) (*Session, error) func (*Dialer).DialContext(ctx context.Context, tcpConn net.Conn) (*Session, error) func (*Session).WithContext(ctx context.Context) *Session func github.com/limanmys/render-engine/internal/bridge.OpenSmbConnection(host, username, password string) (*Session, error)
Share represents a SMB tree connection with VFS interface. (*Share) Chmod(name string, mode os.FileMode) error (*Share) Chtimes(name string, atime time.Time, mtime time.Time) error (*Share) Create(name string) (*File, error) (*Share) DirFS(dirname string) fs.FS Glob should work like filepath.Glob. (*Share) Lstat(name string) (os.FileInfo, error) (*Share) Mkdir(name string, perm os.FileMode) error MkdirAll mimics os.MkdirAll (*Share) Open(name string) (*File, error) (*Share) OpenFile(name string, flag int, perm os.FileMode) (*File, error) (*Share) ReadDir(dirname string) ([]os.FileInfo, error) (*Share) ReadFile(filename string) ([]byte, error) (*Share) Readlink(name string) (string, error) (*Share) Remove(name string) error RemoveAll removes path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, RemoveAll returns nil (no error). (*Share) Rename(oldpath, newpath string) error (*Share) Stat(name string) (os.FileInfo, error) (*Share) Statfs(name string) (FileFsInfo, error) Symlink mimics os.Symlink. This API should work on latest Windows and latest MacOS. However it may not work on Linux because Samba doesn't support reparse point well. Also there is a restriction on target pathname. Generally, a pathname begins with leading backslash (e.g `\dir\name`) can be interpreted as two ways. On windows, it is evaluated as a relative path, on other systems, it is evaluated as an absolute path. This implementation always assumes that format is absolute path. So, if you know the target server is Windows, you should avoid that format. If you want to use an absolute target path on windows, you can use // `C:\dir\name` format instead. (*Share) Truncate(name string, size int64) error Umount disconects the current SMB tree. (*Share) WithContext(ctx context.Context) *Share (*Share) WriteFile(filename string, data []byte, perm os.FileMode) error func (*Session).Mount(sharename string) (*Share, error) func (*Share).WithContext(ctx context.Context) *Share
TransportError represents a error come from net.Conn layer. Err error (*TransportError) Error() string *TransportError : error
Package-Level Functions (total 2)
Match reports whether name matches the shell file name pattern. The pattern syntax is: pattern: { term } term: '*' matches any sequence of non-Separator characters '?' matches any single non-Separator character '[' [ '^' ] { character-range } ']' character class (must be non-empty) c matches character c (c != '*', '?', '[') character-range: c matches character c (c != '-', ']') lo '-' hi matches character c for lo <= c <= hi Match requires pattern to match all of name, not just a substring. The only possible returned error is ErrBadPattern, when pattern is malformed.
Package-Level Variables (total 2)
ErrBadPattern indicates a pattern was malformed.
var NORMALIZE_PATH bool // normalize path arguments automatically
Package-Level Constants (total 2)
const MaxReadSizeLimit = 1048576 // deprecated constant
const PathSeparator = 92