Skip to content

Latest commit

 

History

History
49 lines (40 loc) · 901 Bytes

README.md

File metadata and controls

49 lines (40 loc) · 901 Bytes

Build Status

pftp

pluggable ftp proxy server

example

func main() {
	confFile := "./example.toml"

	ftpServer, err := pftp.NewFtpServer(confFile)
	if err != nil {
		logrus.Fatal(err)
	}

	if err := ftpServer.Start(); err != nil {
		logrus.Fatal(err)
	}
}

middleware

In pftp, you can hook into the ftp command and execute arbitrary processing.

USER command example

An example of changing the connection destination according to the user name.

func main() {
...
	ftpServer.Use("user", User)
...
}

func User(c *pftp.Context, param string) error {
        if param == "foo" {
	    c.RemoteAddr = "127.0.0.1:10021"
        } else if param == "bar" {
	    c.RemoteAddr = "127.0.0.1:20021"
        }
	return nil
}

Require

  • Go 1.15 or later

author

  • @pyama86
  • @heat1024