Documentation
¶
Overview ¶
Package sftptest is an SSH server with an SFTP subsystem for tests.
It does not implement permissions, quotas, symlink creation limits, fsync, rename, bandwidth shaping beyond SlowData, or SSH rekeying. The file store for ordinary paths is in memory. GenFile and paths under /sink/ are not stored.
Index ¶
- func GenByte(off int64) byte
- type Config
- type Server
- func (s *Server) AddRSA() error
- func (s *Server) Addr() string
- func (s *Server) Apply(cfg Config)
- func (s *Server) AuthAttempts() []string
- func (s *Server) AuthDelay(d time.Duration)
- func (s *Server) ClearFaults()
- func (s *Server) Close()
- func (s *Server) ConnCount() int
- func (s *Server) CorruptByte(offset int64)
- func (s *Server) Delay(d time.Duration)
- func (s *Server) DropOn(op string)
- func (s *Server) File(p string) ([]byte, bool)
- func (s *Server) Files() map[string][]byte
- func (s *Server) GenFile(p string, size int64)
- func (s *Server) HandshakeDelay(d time.Duration)
- func (s *Server) HostKeyFingerprint() string
- func (s *Server) IdleTimeout(d time.Duration)
- func (s *Server) MaxConnections(n int)
- func (s *Server) Mkdir(p string) error
- func (s *Server) OpenConns() int
- func (s *Server) Ops() []string
- func (s *Server) RSAFingerprint() string
- func (s *Server) RefuseConnections(on bool)
- func (s *Server) ReplyOn(op string, code uint32, text string)
- func (s *Server) Requests() []string
- func (s *Server) SinkHash(p string) (n int64, sum string, ok bool)
- func (s *Server) SlowData(bytesPerSecond int)
- func (s *Server) StallAfter(op string, n int)
- func (s *Server) StallOn(op string)
- func (s *Server) Symlink(target, link string) error
- func (s *Server) TruncateReadAfter(n int64)
- func (s *Server) URL() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
Users map[string]string
AuthorizedKeys map[string][]ssh.PublicKey
Files map[string][]byte
NoPassword bool
NoPublicKey bool
NoSubsystem bool
}
Config is the starting state of a server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a fake SFTP server.
func Start ¶
Start listens on 127.0.0.1 and serves SFTP. The default user is load with password secret.
func (*Server) AuthAttempts ¶
AuthAttempts lists the methods the client tried, in order.
func (*Server) ClearFaults ¶
func (s *Server) ClearFaults()
ClearFaults releases stalls and turns the knobs off.
func (*Server) CorruptByte ¶
CorruptByte flips one byte of a read at offset.
func (*Server) Files ¶
Files returns the ordinary files in the store. Sink and generated files are not included.
func (*Server) HandshakeDelay ¶
HandshakeDelay waits before the SSH handshake.
func (*Server) HostKeyFingerprint ¶
HostKeyFingerprint is the SHA256 fingerprint of the Ed25519 host key.
func (*Server) IdleTimeout ¶
IdleTimeout closes a connection that has been idle for d.
func (*Server) MaxConnections ¶
MaxConnections closes the connection after n, during the handshake.
func (*Server) RSAFingerprint ¶
RSAFingerprint is the SHA256 fingerprint of the RSA host key.
func (*Server) RefuseConnections ¶
RefuseConnections closes each new TCP connection at once.
func (*Server) SinkHash ¶
SinkHash reports how many bytes were written to a /sink/ path and their SHA-256. ok is false when the path was not a sink.
func (*Server) StallAfter ¶
StallAfter lets n operations of op succeed, then stalls.
func (*Server) Symlink ¶
Symlink creates a symlink. target is the existing path. link is the new name.
func (*Server) TruncateReadAfter ¶
TruncateReadAfter fails a read once n bytes have been returned.