Documentation
¶
Overview ¶
Package ftptest is a small FTP server for tests. It speaks enough of the protocol for the client library: login, features, passive mode, list, retrieve, store, delete, size and time. It does not do active mode, REST, APPE, rename, MKD, RMD, permissions, quotas, ASCII mode or bandwidth accounting beyond the SlowData knob.
Index ¶
- type Config
- type Server
- func (s *Server) Addr() string
- func (s *Server) Apply(cfg Config)
- func (s *Server) ClearFaults()
- func (s *Server) Close()
- func (s *Server) Commands() []string
- func (s *Server) ConnCount() int
- func (s *Server) DataConnCount() int
- func (s *Server) DataTLS(cfg *tls.Config)
- func (s *Server) Delay(d time.Duration)
- func (s *Server) DropOn(cmd string)
- func (s *Server) File(path string) ([]byte, bool)
- func (s *Server) Files() map[string][]byte
- func (s *Server) Generate(path string, n int64)
- func (s *Server) IdleTimeout(d time.Duration)
- func (s *Server) MaxConnections(n int)
- func (s *Server) OpenConns() int
- func (s *Server) RefuseConnections(v bool)
- func (s *Server) ReplyOn(cmd string, code int, text string)
- func (s *Server) SlowData(bytesPerSecond int)
- func (s *Server) StallDataAfter(n int)
- func (s *Server) StallOn(cmd string)
- func (s *Server) TruncateDataAfter(n int)
- func (s *Server) URL() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Users map[string]string
Files map[string][]byte
AnnounceHost string
NoMLST bool
DOSList bool
RequireTLSSessionReuse bool
NoSIZE bool
CorruptDownloads bool
}
Config is the server's files, users and fault knobs. Apply replaces the parts that are set. A nil map leaves that part as it was.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is one FTP server on 127.0.0.1.
func StartImplicitTLS ¶
StartImplicitTLS listens with TLS from the first byte.
func StartTLSConfig ¶ added in v0.8.0
StartTLSConfig is StartTLS with the given server config, including a client certificate check when the config asks for one.
func (*Server) Apply ¶
Apply changes users, files and knobs. A nil Users or Files map is left unchanged. AnnounceHost, when non-empty, replaces the PASV address.
func (*Server) ClearFaults ¶
func (s *Server) ClearFaults()
ClearFaults removes stall, drop and truncate knobs.
func (*Server) Commands ¶
Commands is the log of control commands. A password is stored as PASS ****.
func (*Server) DataConnCount ¶
DataConnCount is how many data connections were accepted.
func (*Server) DataTLS ¶ added in v0.9.0
DataTLS makes data connections present this certificate instead of the control connection's certificate.
func (*Server) IdleTimeout ¶
IdleTimeout closes a control connection that is quiet for d, with 421.
func (*Server) MaxConnections ¶
MaxConnections makes the n+1th control connection receive 421.
func (*Server) RefuseConnections ¶
RefuseConnections closes new control connections at once.
func (*Server) StallDataAfter ¶
StallDataAfter stops a transfer after n bytes and waits.
func (*Server) TruncateDataAfter ¶
TruncateDataAfter closes the data connection after n bytes and replies 426.