Documentation ¶
Overview ¶
Package ftpclient implements a FTP client as described in RFC 959.
Index ¶
- Constants
- func NewTLSConfig() *tls.Config
- func NewTLSConfigWithX509KeyPair(certFile, keyFile string) (*tls.Config, error)
- type Config
- type FtpDataConn
- type FtpServerConn
- func (c *FtpServerConn) Abort() error
- func (c *FtpServerConn) Auth(param string) error
- func (c *FtpServerConn) Cdup() error
- func (c *FtpServerConn) Cwd(path string) error
- func (c *FtpServerConn) Delete(path string) error
- func (c *FtpServerConn) Dial(addr string) error
- func (c *FtpServerConn) DialTimeout(addr string, timeout time.Duration) error
- func (c *FtpServerConn) Dir(args ...string) (infos []os.FileInfo, err error)
- func (c *FtpServerConn) Eprt(host string, port int) error
- func (c *FtpServerConn) Epsv() (port int, err error)
- func (c *FtpServerConn) Feat() error
- func (c *FtpServerConn) GetResponse(expectCode int, timeout time.Duration) (int, string, error)
- func (c *FtpServerConn) List(args ...string) (lines []string, err error)
- func (c *FtpServerConn) ListRequest(args ...string) (io.ReadCloser, error)
- func (c *FtpServerConn) Login(user, password string) error
- func (c *FtpServerConn) Mkd(path string) (string, error)
- func (c *FtpServerConn) Nlst(args ...string) (lines []string, err error)
- func (c *FtpServerConn) NlstRequest(args ...string) (io.ReadCloser, error)
- func (c *FtpServerConn) Noop() error
- func (c *FtpServerConn) Opts(param string) error
- func (c *FtpServerConn) Pasv() (host string, port int, err error)
- func (c *FtpServerConn) Pbsz(param string) error
- func (c *FtpServerConn) Port(host string, port int) error
- func (c *FtpServerConn) Prot(param string) error
- func (c *FtpServerConn) Pwd() (string, error)
- func (c *FtpServerConn) Quit() error
- func (c *FtpServerConn) Rein() error
- func (c *FtpServerConn) Rename(from, to string) error
- func (c *FtpServerConn) Rest(offset uint64) error
- func (c *FtpServerConn) Retr(path string) error
- func (c *FtpServerConn) RetrFile(remote, local string) error
- func (c *FtpServerConn) RetrRequest(path string) (io.ReadCloser, error)
- func (c *FtpServerConn) Rmd(path string) error
- func (c *FtpServerConn) SendCmd(expectCode int, format string, args ...interface{}) (int, string, error)
- func (c *FtpServerConn) SetPasv(ispassive bool)
- func (c *FtpServerConn) Size(filename string) (int, error)
- func (c *FtpServerConn) Stor(path string) error
- func (c *FtpServerConn) StorFile(local, remote string) error
- func (c *FtpServerConn) StorRequest(path string) (io.WriteCloser, error)
- func (c *FtpServerConn) Syst() (string, error)
- func (c *FtpServerConn) TransferRequest(format string, args ...interface{}) (io.ReadCloser, error)
- func (c *FtpServerConn) Type(param string) error
- type Logger
Constants ¶
const ( DataConnectionAlreadyOpen = 125 FileStatusOK = 150 CommandOkay = 200 SystemStatus = 211 DirectoryStatus = 212 FileStatus = 213 ConnectionClosing = 221 SystemType = 215 ServiceReadyForNewUser = 220 ClosingDataConnection = 226 UserLoggedIn = 230 ActionOK = 250 PathCreated = 257 UserNameOK = 331 ActionPending = 350 NotLoggedIn = 530 )
FTP Status Code, defined in RFC 959
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config ...
func (*Config) WithLogger ¶
WithLogger sets a config Logger value returning a Config pointer for chaining.
func (*Config) WithReadWriteTimeout ¶
WithReadWriteTimeout sets a config ReadWriteTimeout value returning a Config pointer for chaining.
func (*Config) WithTLSConfig ¶
WithTLSConfig sets a config tlsConfig value returning a Config pointer for chaining.
func (*Config) WithTLSImplicit ¶
WithTLSImplicit sets a config tlsImplicit value returning a Config pointer for chaining.
type FtpDataConn ¶
type FtpDataConn struct {
// contains filtered or unexported fields
}
FtpDataConn represent a data-connection
func (*FtpDataConn) Close ¶
func (d *FtpDataConn) Close() error
Close implements the io.Closer interface on a FTP data connection.
type FtpServerConn ¶
type FtpServerConn struct { *Config // contains filtered or unexported fields }
FtpServerConn represents the connection to a remote FTP server.
func (*FtpServerConn) Abort ¶
func (c *FtpServerConn) Abort() error
Abort a file transfer that is in progress.
func (*FtpServerConn) Auth ¶
func (c *FtpServerConn) Auth(param string) error
Auth issues a AUTH FTP command
func (*FtpServerConn) Cdup ¶
func (c *FtpServerConn) Cdup() error
Cdup issues a CDUP FTP command, which changes the current directory to the parent directory. This is similar to a call to ChangeDir with a path set to "..".
func (*FtpServerConn) Cwd ¶
func (c *FtpServerConn) Cwd(path string) error
Cwd issues a CWD FTP command, which changes the current directory to the specified path.
func (*FtpServerConn) Delete ¶
func (c *FtpServerConn) Delete(path string) error
Delete issues a DELE FTP command to delete the specified file from the remote FTP server.
func (*FtpServerConn) DialTimeout ¶
func (c *FtpServerConn) DialTimeout(addr string, timeout time.Duration) error
DialTimeout ...
func (*FtpServerConn) Dir ¶
func (c *FtpServerConn) Dir(args ...string) (infos []os.FileInfo, err error)
Dir issues a LIST FTP command.
func (*FtpServerConn) Eprt ¶
func (c *FtpServerConn) Eprt(host string, port int) error
Eprt issues a EPRT FTP command
func (*FtpServerConn) Epsv ¶
func (c *FtpServerConn) Epsv() (port int, err error)
Epsv issues a "EPSV" command to get a port number for a data connection.
func (*FtpServerConn) GetResponse ¶
GetResponse issues a FTP command response
func (*FtpServerConn) List ¶
func (c *FtpServerConn) List(args ...string) (lines []string, err error)
List issues a LIST FTP command.
func (*FtpServerConn) ListRequest ¶
func (c *FtpServerConn) ListRequest(args ...string) (io.ReadCloser, error)
ListRequest issues a LIST FTP command.
func (*FtpServerConn) Login ¶
func (c *FtpServerConn) Login(user, password string) error
Login as the given user.
func (*FtpServerConn) Mkd ¶
func (c *FtpServerConn) Mkd(path string) (string, error)
Mkd issues a MKD FTP command to create the specified directory on the remote FTP server.
func (*FtpServerConn) Nlst ¶
func (c *FtpServerConn) Nlst(args ...string) (lines []string, err error)
Nlst issues an NLST FTP command.
func (*FtpServerConn) NlstRequest ¶
func (c *FtpServerConn) NlstRequest(args ...string) (io.ReadCloser, error)
NlstRequest issues an NLST FTP command.
func (*FtpServerConn) Noop ¶
func (c *FtpServerConn) Noop() error
Noop has no effects and is usually used to prevent the remote FTP server to close the otherwise idle connection.
func (*FtpServerConn) Opts ¶
func (c *FtpServerConn) Opts(param string) error
Opts issues a OPTS FTP command
func (*FtpServerConn) Pasv ¶
func (c *FtpServerConn) Pasv() (host string, port int, err error)
Pasv issues a "PASV" command to get a port number for a data connection.
func (*FtpServerConn) Pbsz ¶
func (c *FtpServerConn) Pbsz(param string) error
Pbsz issues a PBSZ FTP command
func (*FtpServerConn) Port ¶
func (c *FtpServerConn) Port(host string, port int) error
Port issues a PORT FTP command
func (*FtpServerConn) Prot ¶
func (c *FtpServerConn) Prot(param string) error
Prot issues a PROT FTP command
func (*FtpServerConn) Pwd ¶
func (c *FtpServerConn) Pwd() (string, error)
Pwd issues a PWD FTP command, which Returns the path of the current directory.
func (*FtpServerConn) Quit ¶
func (c *FtpServerConn) Quit() error
Quit issues a QUIT FTP command to properly close the connection from the remote FTP server.
func (*FtpServerConn) Rein ¶
func (c *FtpServerConn) Rein() error
Rein issues a REIN FTP command to logout the current user. ftp server optional command.
func (*FtpServerConn) Rename ¶
func (c *FtpServerConn) Rename(from, to string) error
Rename renames a file on the remote FTP server.
func (*FtpServerConn) Rest ¶
func (c *FtpServerConn) Rest(offset uint64) error
Rest issues a REST FTP command.
func (*FtpServerConn) Retr ¶
func (c *FtpServerConn) Retr(path string) error
Retr issues a RETR FTP command to fetch the specified file from the remote FTP server
func (*FtpServerConn) RetrFile ¶
func (c *FtpServerConn) RetrFile(remote, local string) error
RetrFile issues a RETR FTP command to fetch the specified file from the remote FTP server
func (*FtpServerConn) RetrRequest ¶
func (c *FtpServerConn) RetrRequest(path string) (io.ReadCloser, error)
RetrRequest issues a RETR FTP command to fetch the specified file from the remote FTP server The returned ReadCloser must be closed to cleanup the FTP data connection.
func (*FtpServerConn) Rmd ¶
func (c *FtpServerConn) Rmd(path string) error
Rmd issues a RMD FTP command to remove the specified directory from the remote FTP server.
func (*FtpServerConn) SendCmd ¶
func (c *FtpServerConn) SendCmd(expectCode int, format string, args ...interface{}) (int, string, error)
SendCmd Send a simple command string to the server and return the code and response string.
func (*FtpServerConn) SetPasv ¶
func (c *FtpServerConn) SetPasv(ispassive bool)
SetPasv sets the mode to passive or active for data transfers.
func (*FtpServerConn) Size ¶
func (c *FtpServerConn) Size(filename string) (int, error)
Size Request the size of the file named filename on the server. On success, the size of the file is returned as an integer. ftp server extention command.
func (*FtpServerConn) Stor ¶
func (c *FtpServerConn) Stor(path string) error
Stor issues a STOR FTP command to store a file to the remote FTP server.
func (*FtpServerConn) StorFile ¶
func (c *FtpServerConn) StorFile(local, remote string) error
StorFile issues a STOR FTP command to store a file to the remote FTP server.
func (*FtpServerConn) StorRequest ¶
func (c *FtpServerConn) StorRequest(path string) (io.WriteCloser, error)
StorRequest issues a STOR FTP command to store a file to the remote FTP server. The returned WriteCloser must be closed to cleanup the FTP data connection.
func (*FtpServerConn) Syst ¶
func (c *FtpServerConn) Syst() (string, error)
Syst issues a SYST FTP command
func (*FtpServerConn) TransferRequest ¶
func (c *FtpServerConn) TransferRequest(format string, args ...interface{}) (io.ReadCloser, error)
TransferRequest issues a FTP command to fetch the specified file from the remote FTP server The returned ReadCloser must be closed to cleanup the FTP data connection.
func (*FtpServerConn) Type ¶
func (c *FtpServerConn) Type(param string) error
Type issues a TYPE FTP command