Example #1
0
func main() {
	// files := map[string]*s3driver.MemoryFile{
	// 	"/": &s3driver.MemoryFile{graval.NewDirItem(""), nil},
	// }

	credentialsProvider := aws.Creds(awsAccessKeyID, awsSecretAccessKey, "")

	factory := &s3driver.S3DriverFactory{
		Username:               username,
		Password:               password,
		AWSRegion:              awsRegion,
		AWSCredentialsProvider: credentialsProvider,
		AWSBucketName:          awsBucketName,
	}

	server := graval.NewFTPServer(&graval.FTPServerOpts{
		ServerName: serverName,
		Factory:    factory,
		Hostname:   host,
		Port:       port,
		PassiveOpts: &graval.PassiveOpts{
			ListenAddress: host,
			NatAddress:    host,
			PassivePorts: &graval.PassivePorts{
				Low:  42000,
				High: 45000,
			},
		},
	})

	log.Printf("FTP2S3 server listening on %s:%d", host, port)
	log.Printf("Access: ftp://%s:%s@%s:%d/", username, password, host, port)

	err := server.ListenAndServe()

	if err != nil {
		log.Fatal(err)
	}
}
Example #2
0
func main() {
	host := "127.0.0.1"
	port := 8021
	username := "******"
	password := "******"

	files := map[string]*memory.MemoryFile{
		"/": &memory.MemoryFile{graval.NewDirItem(""), nil},
	}

	factory := &memory.MemoryDriverFactory{files, username, password}

	server := graval.NewFTPServer(&graval.FTPServerOpts{
		ServerName: "Example FTP server",
		Factory:    factory,
		Hostname:   host,
		Port:       port,
		PassiveOpts: &graval.PassiveOpts{
			ListenAddress: host,
			NatAddress:    host,
			PassivePorts: &graval.PassivePorts{
				Low:  42000,
				High: 45000,
			},
		},
	})

	log.Printf("Example FTP server listening on %s:%d", host, port)
	log.Printf("Access: ftp://%s:%s@%s:%d/", username, password, host, port)

	err := server.ListenAndServe()

	if err != nil {
		log.Fatal(err)
	}
}