ftp

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NeedAccount             = "332 Need account for login.\r\n"
	PasswordPlease          = "331 password please - version check\r\n"
	PasswordError           = "331 please specify the password\r\n"
	UserLogged              = "230 User logged in\r\n"
	NoSuchFile              = "550 %s: No such file or directory.\r\n"
	CommandNotFound         = "500 '%s': command not understood.\r\n"
	EnteringPassiveMode     = "227 Entering Passive Mode (%s,%v,%d)\r\n"
	OpeningBinaryMode       = "150 Opening BINARY mode data connection for '%s' (%d bytes).\r\n"
	OpeningBinaryModeUpload = "150 Opening BINARY mode data connection for '%s'.\r\n"
	TransferComplete        = "226 Transfer complete.\r\n"
	Goodbye                 = "221 Goodbye.\r\n"
	DirectoryChanged        = "250 Directory successfully changed.\r\n"
	CurrentDirectory        = "257 \"%s\" is the current directory\r\n"
)

Variables

This section is empty.

Functions

func DeleteRules

func DeleteRules(c *gin.Context)

DeleteRules deletes ftp rule from user submit

func ListRules

func ListRules(c *gin.Context)

ListRules lists all ftp rules those satisfy the filter

func Records added in v0.2.1

func Records(c *gin.Context)

func UpsertRules

func UpsertRules(c *gin.Context)

UpsertRules creates or updates ftp rule from user submit

Types

type Config

type Config struct {
	Enable   bool
	Addr     string
	PasvPort int `yaml:"pasv_port"`
}

type Method

type Method = string
const (
	DOWNLOAD Method = "DOWNLOAD"
	UPLOAD   Method = "UPLOAD"
)

type Record

type Record struct {
	record.BaseRecord
	User     string        `form:"user" json:"user"`
	Password string        `form:"password" json:"password"`
	Path     string        `form:"path" json:"path"`
	Method   Method        `form:"method" json:"method"`
	Status   Status        `form:"status" json:"status"`
	File     *file.FTPFile `gorm:"foreignKey:RecordID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" form:"file" json:"file" notice:"-"`
	Rule     Rule          `gorm:"foreignKey:RuleName;references:Name;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;" form:"-" json:"-" notice:"-"`
}

func NewRecord

func NewRecord(rule *Rule, flag, user, password, method, path, ip, area string, file *file.FTPFile, status Status) (r *Record, err error)

func (Record) Notice

func (r Record) Notice()

func (Record) TableName

func (Record) TableName() string

type Rule

type Rule struct {
	rule.BaseRule `yaml:",inline"`
	PasvAddress   string `gorm:"pasv_address" json:"pasv_address" form:"pasv_address" yaml:"pasv_address"`
	Data          []byte `json:"data" form:"data"`
}

Rule FTP rule struct

func NewRule

func NewRule(name, flagFormat, pasvAddress string, pushToClient, notice bool) *Rule

NewRule creates a new ftp rule struct

func (*Rule) CreateOrUpdate

func (r *Rule) CreateOrUpdate() (err error)

CreateOrUpdate creates or updates the ftp rule in database and ruleSet

func (*Rule) Delete

func (r *Rule) Delete() (err error)

Delete deletes the ftp rule in database and ruleSet

func (Rule) TableName

func (Rule) TableName() string

type Server

type Server struct {
	Config
	// contains filtered or unexported fields
}

func GetServer

func GetServer() *Server

func (*Server) Restart

func (s *Server) Restart()

func (*Server) Run

func (s *Server) Run()

func (*Server) SetPasvIP

func (s *Server) SetPasvIP(ip string) *Server

func (*Server) Stop

func (s *Server) Stop()

func (*Server) UpdateRules

func (s *Server) UpdateRules() error

type Status

type Status string
const (
	CRASHED  Status = "CRASHED"
	FINISHED Status = "FINISHED"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL