Documentation
¶
Index ¶
- Constants
- func Abs(root string, workingDir string, arg string) string
- func GetServerPublicIP() (string, error)
- type FTPServerTransferType
- type Server
- func (s *Server) Close(err error)
- func (s *Server) Listen() (err error)
- func (s *Server) ListenAndServe() (err error)
- func (s *Server) ListenAndServeTLS(certFile, keyFile string) (err error)
- func (s *Server) ListenAndServeTLSe(certFile, keyFile string) (err error)
- func (s *Server) Logger() *slog.Logger
- func (s *Server) Serve()
- func (s *Server) ServeTLS(certFile, keyFile string) (err error)
- func (s *Server) ServeTLSe(certFile, keyFile string) (err error)
- func (s *Server) SetLogger(l *slog.Logger)
- func (s *Server) SetPublicServerIPv4(publicServerIP string) error
- func (s *Server) TryListenAndServe(d time.Duration) (err error)
- func (s *Server) TryListenAndServeTLS(certFile, keyFile string, d time.Duration) (err error)
- func (s *Server) TryListenAndServeTLSe(certFile, keyFile string, d time.Duration) (err error)
- func (s *Server) Wait() error
- func (s *Server) WithContext(ctx context.Context) *Server
- type Session
- func (s *Session) AbortCommand(cmd, arg string) error
- func (s *Session) ActiveModeCommand(cmd, args string) error
- func (s *Session) AuthCommand(cmd, arg string) error
- func (s *Session) ChangeDirectoryCommand(cmd, arg string) error
- func (s *Session) ChangeDirectoryToParentCommand(cmd, arg string) error
- func (s *Session) CloseCommand(cmd, arg string) error
- func (s *Session) CloseDataCaller()
- func (s *Session) CloseDataConnection()
- func (s *Session) ExtendedActiveModeCommand(cmd, arg string) error
- func (s *Session) ExtendedPassiveModeCommand(cmd, arg string) error
- func (s *Session) FeaturesCommand(cmd, arg string) error
- func (s *Session) GetDirInfoCommand(cmd, arg string) error
- func (s *Session) GetFileInfoCommand(cmd, arg string) error
- func (s *Session) HelpCommand(cmd, arg string) error
- func (s *Session) MakeDirectoryCommand(cmd, arg string) error
- func (s *Session) ModeCommand(cmd, args string) error
- func (s *Session) ModifyTimeCommand(cmd, arg string) error
- func (s *Session) NoopCommand(cmd, arg string) error
- func (s *Session) OptsCommand(cmd, arg string) error
- func (s *Session) PROTCommand(cmd, args string) error
- func (s *Session) ParseCommand() (cmd, arg string, err error)
- func (s *Session) PassCommand(cmd, arg string) (err error)
- func (s *Session) PassiveModeCommand(cmd, arg string) error
- func (s *Session) PassiveOrActiveModeConn() (net.Conn, error)
- func (s *Session) PasvEpsvCommand(arg string) (port int, err error)
- func (s *Session) PbszCommand(cmd string, arg string) error
- func (s *Session) PortErptCommand(addr string) (err error)
- func (s *Session) PrintWorkingDirectoryCommand(cmd, arg string) error
- func (s *Session) RemoveCommand(cmd, arg string) error
- func (s *Session) RenameFromCommand(cmd, arg string) error
- func (s *Session) RenameToCommand(cmd, arg string) error
- func (s *Session) RessetCommand(cmd, arg string) error
- func (s *Session) RetrieveCommand(cmd, arg string) error
- func (s *Session) SaveCommand(cmd, arg string) error
- func (s *Session) SiteCommand(cmd, arg string) error
- func (s *Session) SizeCommand(cmd, arg string) error
- func (s *Session) StatusCommand(cmd, arg string) error
- func (s *Session) StruCommand(cmd, args string) error
- func (s *Session) SystemCommand(cmd, arg string) error
- func (s *Session) TypeCommand(cmd, arg string) error
- func (s *Session) UnAuthenticatedCommand(cmd, arg string) error
- func (s *Session) UnknownCommand(cmd, arg string) error
- func (s *Session) UserCommand(cmd, arg string) (err error)
- type SessionManager
- type Users
Constants ¶
const PublicIpUrl = "https://api.ipify.org"
PublicIpUrl is the url to get the public ip of the server
Variables ¶
This section is empty.
Functions ¶
func GetServerPublicIP ¶
Types ¶
type FTPServerTransferType ¶
type FTPServerTransferType string
type Server ¶
type Server struct { // Addr is the server address Addr string // supportsTLS is a flag to indicate if the server supports TLS FsHandler filesystem.FS // Root is the server root directory Root string // WelcomeMessage is the server welcome message WelcomeMessage string // PublicServerIPv4 is the server public IPv4 address for passive mode PublicServerIPv4 [4]byte // Type is the server transfer type Type FTPServerTransferType // PasvMaxPort is the server passive mode max port PasvMaxPort int // PasvMinPort is the server passive mode min port PasvMinPort int // TLS is the server TLS configuration TLS *tls.Config // TLSe is the server TLS configuration for upgrade existing FTP connection TLSe *tls.Config // Closer is the server closer channel on close the channel will return the error Closer chan error // contains filtered or unexported fields }
func (*Server) ListenAndServe ¶
ListenAndServe starts the FTP server
func (*Server) ListenAndServeTLS ¶
ListenAndServeTLS starts the FTP server
func (*Server) ListenAndServeTLSe ¶
ListenAndServeTLSe and allow upgrade to TLS
func (*Server) SetPublicServerIPv4 ¶
SetPublicServerIPv4 sets the server public IPv4 address
func (*Server) TryListenAndServe ¶
TryListenAndServe strives to starts the FTP server if there isn't an error after a certain time it returns nil
func (*Server) TryListenAndServeTLS ¶
TryListenAndServeTLS tries to start the FTP server if there isn't an error after a certain time it returns nil
func (*Server) TryListenAndServeTLSe ¶
TryListenAndServeTLSe strives to starts the FTP server if there isn't an error after a certain time it returns nil
type Session ¶
type Session struct { HelpCommands string CTX context.Context // contains filtered or unexported fields }
Session represents an individual client FTP session.
func (*Session) AbortCommand ¶
AbortCommand handles the ABOR command from the client.
func (*Session) ActiveModeCommand ¶
ActiveModeCommand handles the PORT command from the client.
func (*Session) AuthCommand ¶
AuthCommand handles the AUTH command from the client.
func (*Session) ChangeDirectoryCommand ¶
ChangeDirectoryCommand handles the CWD command from the client. The CWD command is used to change the working directory on the server.
func (*Session) ChangeDirectoryToParentCommand ¶
ChangeDirectoryToParentCommand handles the CDUP command from the client. The CDUP command is used to change the working directory to the parent directory.
func (*Session) CloseCommand ¶
func (*Session) CloseDataCaller ¶
func (s *Session) CloseDataCaller()
CloseDataCaller closes the data connection.
func (*Session) CloseDataConnection ¶
func (s *Session) CloseDataConnection()
CloseDataConnection closes the data connection.
func (*Session) ExtendedActiveModeCommand ¶
ExtendedActiveModeCommand handles the EPRT command from the client.
func (*Session) ExtendedPassiveModeCommand ¶
ExtendedPassiveModeCommand handles the EPSV command from the client. The EPSV command is used to enter extended passive mode.
func (*Session) FeaturesCommand ¶
func (*Session) GetDirInfoCommand ¶
GetDirInfoCommand handles the MLSD command from the client. The MLSD command is used to list the contents of a directory in a machine-readable format.
func (*Session) GetFileInfoCommand ¶
GetFileInfoCommand handles the MLST command from the client.
func (*Session) HelpCommand ¶
HelpCommand handles the HELP command from the client.
func (*Session) MakeDirectoryCommand ¶
func (*Session) ModeCommand ¶
ModeCommand handles the MODE command from the client.
func (*Session) ModifyTimeCommand ¶
ModifyTimeCommand handles the MDTM command from the client. The MDTM command is used to modify the modification time of a file on the server.
func (*Session) NoopCommand ¶
NoopCommand handles the NOOP command from the client. The NOOP command is used to keep the connection alive.
func (*Session) OptsCommand ¶
OptsCommand handles the OPTS command from the client. The OPTS command is used to specify options for the server.
func (*Session) PROTCommand ¶
PROTCommand handles the PROT command from the client.
func (*Session) ParseCommand ¶
ParseCommand parses the command from the client and returns the command and argument.
func (*Session) PassCommand ¶
PassCommand handles the PASS command from the client.
func (*Session) PassiveModeCommand ¶
PassiveModeCommand handles the PASV command from the client. The PASV command is used to enter passive mode.
func (*Session) PassiveOrActiveModeConn ¶
PassiveOrActiveModeConn returns the data connection. if passive mode is enabled, it returns the listener. if active mode is enabled, it returns the caller.
func (*Session) PasvEpsvCommand ¶
PasvEpsvCommand handles the PASV command from the client. The PASV command is used to enter passive mode.
func (*Session) PortErptCommand ¶
func (*Session) PrintWorkingDirectoryCommand ¶
PrintWorkingDirectoryCommand handles the PWD command from the client. The PWD command is used to print the current working directory on the server.
func (*Session) RemoveCommand ¶
func (*Session) RenameFromCommand ¶
func (*Session) RenameToCommand ¶
func (*Session) RessetCommand ¶
func (*Session) RetrieveCommand ¶
RetrieveCommand handles the RETR command from the client.
func (*Session) SaveCommand ¶
SaveCommand handles the STOR command from the client. The STOR command is used to store a file on the server.
func (*Session) SiteCommand ¶
func (*Session) SizeCommand ¶
SizeCommand handles the SIZE command from the client.
func (*Session) StatusCommand ¶
StatusCommand handles the MLST command from the client.
func (*Session) StruCommand ¶
StruCommand handles the STRU command from the client.
func (*Session) SystemCommand ¶
SystemCommand returns the system type.
func (*Session) TypeCommand ¶
TypeCommand handles the TYPE command from the client. The TYPE command is used to specify the type of file being transferred. The two types are ASCII (A) and binary (I).
func (*Session) UnAuthenticatedCommand ¶
UnAuthenticatedCommand handles the commands that are not allowed when the user is not authenticated.
func (*Session) UnknownCommand ¶
func (*Session) UserCommand ¶
UserCommand handles the USER command from the client.
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager manages all active sessions.
func NewSessionManager ¶
func NewSessionManager() *SessionManager
func (*SessionManager) Add ¶
func (manager *SessionManager) Add(id string, session *Session)
Add adds a new session for the client.
func (*SessionManager) Get ¶
func (manager *SessionManager) Get(id string) (*Session, bool)
Get retrieves a session by its ID.
func (*SessionManager) Remove ¶
func (manager *SessionManager) Remove(id string)
Remove removes a session by its ID.