Documentation
¶
Overview ¶
Package sftpd is sftp (SSH File Transfer Protocol) server library.
windows 无 syscall.Stat_t
Index ¶
- Constants
- Variables
- func IsSftpRequest(req *ssh.Request) bool
- func NewSftpFs(client *sftp.Client) *sftpFs
- func NewSshClientConfig(sshUser, sshPassword, sshType, sshKey, sshKeyPassword string, ...) (config *ssh.ClientConfig, err error)
- func NewSshUpstream(host, username, password string, timeout time.Duration) (*ssh.Client, *ssh.Session, error)
- func ServeChannel(c ssh.Channel, fs FileSystem, sysType int) error
- type Attr
- type Config
- type Dir
- type EmptyDir
- type EmptyFS
- func (EmptyFS) CreateLink(p string, t string, f uint32) error
- func (EmptyFS) Mkdir(string, *Attr) error
- func (EmptyFS) OpenDir(string) (Dir, error)
- func (EmptyFS) OpenFile(string, uint32, *Attr) (File, error)
- func (EmptyFS) ReadLink(p string) (string, error)
- func (EmptyFS) RealPath(p string) (string, error)
- func (EmptyFS) Remove(string) error
- func (EmptyFS) Rename(string, string, uint32) error
- func (EmptyFS) Rmdir(string) error
- func (EmptyFS) SetStat(string, *Attr) error
- func (EmptyFS) Stat(string, bool) (*Attr, error)
- type EmptyFile
- type File
- type FileSystem
- type Handles
- func (h *Handles) CloseAll()
- func (h *Handles) CloseHandle(k string)
- func (h *Handles) GetDir(n string) Dir
- func (h *Handles) GetFile(n string) File
- func (h *Handles) Init()
- func (h *Handles) Ndir() int
- func (h *Handles) NewDir(f Dir) string
- func (h *Handles) NewFile(f File) string
- func (h *Handles) Nfiles() int
- type LocalDir
- type LocalFile
- type LocalFs
- func (fs *LocalFs) CreateLink(path string, target string, flags uint32) error
- func (fs *LocalFs) Mkdir(path string, attr *Attr) error
- func (fs *LocalFs) OpenDir(path string) (Dir, error)
- func (fs *LocalFs) OpenFile(path string, mode uint32, a *Attr) (File, error)
- func (fs *LocalFs) ReadLink(path string) (string, error)
- func (fs *LocalFs) RealPath(pathX string) (string, error)
- func (fs *LocalFs) Remove(path string) error
- func (fs *LocalFs) Rename(oldName, newName string, flag uint32) error
- func (fs *LocalFs) Rmdir(path string) error
- func (fs *LocalFs) SetStat(path string, attr *Attr) error
- func (fs *LocalFs) Stat(path string, isLstat bool) (*Attr, error)
- type NamedAttr
- type SSH_FX
- type SSH_FXP
- type SftpDir
- type SftpFile
Constants ¶
View Source
const ( SSH_FXP_INIT = 1 SSH_FXP_VERSION = 2 SSH_FXP_OPEN = 3 SSH_FXP_CLOSE = 4 SSH_FXP_READ = 5 SSH_FXP_WRITE = 6 SSH_FXP_LSTAT = 7 SSH_FXP_FSTAT = 8 SSH_FXP_SETSTAT = 9 SSH_FXP_FSETSTAT = 10 SSH_FXP_OPENDIR = 11 SSH_FXP_READDIR = 12 SSH_FXP_REMOVE = 13 SSH_FXP_MKDIR = 14 SSH_FXP_RMDIR = 15 SSH_FXP_REALPATH = 16 SSH_FXP_STAT = 17 SSH_FXP_RENAME = 18 SSH_FXP_READLINK = 19 SSH_FXP_SYMLINK = 20 SSH_FXP_STATUS = 101 SSH_FXP_HANDLE = 102 SSH_FXP_DATA = 103 SSH_FXP_NAME = 104 SSH_FXP_ATTRS = 105 SSH_FXP_EXTENDED = 200 SSH_FXP_EXTENDED_REPLY = 201 )
View Source
const ( SSH_FX_OK = 0 SSH_FX_EOF = 1 SSH_FX_NO_SUCH_FILE = 2 SSH_FX_PERMISSION_DENIED = 3 SSH_FX_FAILURE = 4 SSH_FX_BAD_MESSAGE = 5 SSH_FX_NO_CONNECTION = 6 SSH_FX_CONNECTION_LOST = 7 SSH_FX_OP_UNSUPPORTED = 8 )
View Source
const ( SSH_FILEXFER_ATTR_SIZE = 0x00000001 SSH_FILEXFER_ATTR_UIDGID = 0x00000002 SSH_FILEXFER_ATTR_PERMISSIONS = 0x00000004 SSH_FILEXFER_ATTR_ACMODTIME = 0x00000008 SSH_FILEXFER_ATTR_EXTENDED = 0x80000000 )
View Source
const ( SSH_FXF_READ = 0x00000001 SSH_FXF_WRITE = 0x00000002 SSH_FXF_APPEND = 0x00000004 SSH_FXF_CREAT = 0x00000008 SSH_FXF_TRUNC = 0x00000010 SSH_FXF_EXCL = 0x00000020 )
sftp 协议中规定文件读写模式
View Source
const ( ATTR_SIZE = SSH_FILEXFER_ATTR_SIZE ATTR_UIDGID = SSH_FILEXFER_ATTR_UIDGID ATTR_MODE = SSH_FILEXFER_ATTR_PERMISSIONS ATTR_TIME = SSH_FILEXFER_ATTR_ACMODTIME MODE_REGULAR = os.FileMode(0) MODE_DIR = os.ModeDir )
View Source
const S_IFMT = 0xf000
Variables ¶
View Source
var Failure = errors.New("Failure")
View Source
var SSH_FXP_MAP = map[SSH_FXP]string{ SSH_FXP_INIT: `SSH_FXP_INIT`, SSH_FXP_VERSION: `SSH_FXP_VERSION`, SSH_FXP_OPEN: `SSH_FXP_OPEN`, SSH_FXP_CLOSE: `SSH_FXP_CLOSE`, SSH_FXP_READ: `SSH_FXP_READ`, SSH_FXP_WRITE: `SSH_FXP_WRITE`, SSH_FXP_LSTAT: `SSH_FXP_LSTAT`, SSH_FXP_FSTAT: `SSH_FXP_FSTAT`, SSH_FXP_SETSTAT: `SSH_FXP_SETSTAT`, SSH_FXP_FSETSTAT: `SSH_FXP_FSETSTAT`, SSH_FXP_OPENDIR: `SSH_FXP_OPENDIR`, SSH_FXP_READDIR: `SSH_FXP_READDIR`, SSH_FXP_REMOVE: `SSH_FXP_REMOVE`, SSH_FXP_MKDIR: `SSH_FXP_MKDIR`, SSH_FXP_RMDIR: `SSH_FXP_RMDIR`, SSH_FXP_REALPATH: `SSH_FXP_REALPATH`, SSH_FXP_STAT: `SSH_FXP_STAT`, SSH_FXP_RENAME: `SSH_FXP_RENAME`, SSH_FXP_READLINK: `SSH_FXP_READLINK`, SSH_FXP_SYMLINK: `SSH_FXP_SYMLINK`, SSH_FXP_STATUS: `SSH_FXP_STATUS`, SSH_FXP_HANDLE: `SSH_FXP_HANDLE`, SSH_FXP_DATA: `SSH_FXP_DATA`, SSH_FXP_NAME: `SSH_FXP_NAME`, SSH_FXP_ATTRS: `SSH_FXP_ATTRS`, SSH_FXP_EXTENDED: `SSH_FXP_EXTENDED`, SSH_FXP_EXTENDED_REPLY: `SSH_FXP_EXTENDED_REPLY`, }
View Source
var SSH_FX_MAP = map[SSH_FX]string{ SSH_FX_OK: `SSH_FX_OK`, SSH_FX_EOF: `SSH_FX_EOF`, SSH_FX_NO_SUCH_FILE: `SSH_FX_NO_SUCH_FILE`, SSH_FX_PERMISSION_DENIED: `SSH_FX_PERMISSION_DENIED`, SSH_FX_FAILURE: `SSH_FX_FAILURE`, SSH_FX_BAD_MESSAGE: `SSH_FX_BAD_MESSAGE`, SSH_FX_NO_CONNECTION: `SSH_FX_NO_CONNECTION`, SSH_FX_CONNECTION_LOST: `SSH_FX_CONNECTION_LOST`, SSH_FX_OP_UNSUPPORTED: `SSH_FX_OP_UNSUPPORTED`, }
Functions ¶
func IsSftpRequest ¶
IsSftpRequest checks whether a given ssh.Request is for sftp.
func NewSshClientConfig ¶
func NewSshUpstream ¶
func ServeChannel ¶
func ServeChannel(c ssh.Channel, fs FileSystem, sysType int) error
ServeChannel serves a ssh.Channel with the given FileSystem.
Types ¶
type Attr ¶
type Config ¶
type Config struct { // ServerConfig should be initialized properly with // e.g. PasswordCallback and AddHostKey ssh.ServerConfig // HostPort specifies specifies [host]:port to listen on. // e.g. ":2022" or "127.0.0.1:2023". HostPort string // LogFunction is used to log errors. // e.g. log.Println has the right type. LogFunc func(v ...interface{}) // FileSystem contains the FileSystem used for this server. FileSystem FileSystem // contains filtered or unexported fields }
Config is the configuration struct for the high level API.
func (*Config) BlockTillReady ¶
BlockTillReady will block till the Config is ready to accept connections. Returns an error if listening failed. Can be called in a concurrent fashion. This is new API - make sure Init is called on the Config before using it.
type FileSystem ¶
type FileSystem interface { OpenFile(name string, flags uint32, attr *Attr) (File, error) OpenDir(name string) (Dir, error) Remove(name string) error Rename(old string, new string, flags uint32) error Mkdir(name string, attr *Attr) error Rmdir(name string) error Stat(name string, islstat bool) (*Attr, error) SetStat(name string, attr *Attr) error ReadLink(path string) (string, error) CreateLink(path string, target string, flags uint32) error RealPath(path string) (string, error) }
type Handles ¶
type Handles struct {
// contains filtered or unexported fields
}
func (*Handles) CloseHandle ¶
type LocalDir ¶
type LocalDir struct {
// contains filtered or unexported fields
}
func NewLocalDir ¶
type LocalFile ¶
type LocalFile struct {
// contains filtered or unexported fields
}
func NewLocalFile ¶
type LocalFs ¶
type LocalFs struct {
// contains filtered or unexported fields
}
func NewLocalFs ¶
func (*LocalFs) CreateLink ¶
type SftpFile ¶
type SftpFile struct {
// contains filtered or unexported fields
}
func NewSftpFile ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.