-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (35 loc) · 884 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"fmt"
"github.com/alexneamtu/goftp-server"
"os"
"path/filepath"
)
func main() {
cwd, _ := os.Getwd()
factory, _ := MyDriverFactory()
opts := &server.ServerOpts{
Factory: factory,
Port: 11990,
PassivePorts: "20000-20100",
TLS: true,
CertFile: filepath.Join(cwd, "src/ftpgo/certs/server.crt"),
KeyFile: filepath.Join(cwd, "src/ftpgo/certs/server.key"),
Auth: auth{},
}
session := server.NewServer(opts)
if err := session.ListenAndServe(); err != nil {
fmt.Printf("%v", err)
}
}
type auth struct{}
func (a auth) CheckPasswd(user string, password string) (bool, error) {
if user == "test" && password == "test" {
return true, nil
}
return false, nil
}
func MyDriverFactory() (factory server.DriverFactory, err error) {
factory = &FileDriverFactory{"/home/test", server.NewSimplePerm("root", "root")}
return
}