Advertisement
Pug_coder

lab2.1_2

Sep 24th, 2021
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 1.15 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "github.com/goftp/file-driver"
  6.     "github.com/goftp/server"
  7. )
  8.  
  9. func log() (string, int, string, string){
  10.     var rootPath, login, password string
  11.     var port int
  12.     fmt.Print("Введите путь до корневой директории FTP-сервера: ")
  13.     fmt.Scan(&rootPath)
  14.     fmt.Print("Укажите порт: ")
  15.     fmt.Scan(&port)
  16.     fmt.Print("Укажите запрашиваемое имя пользователя:")
  17.     fmt.Scan(&login)
  18.     fmt.Print("Укажите запрашиваемый пароль:")
  19.     fmt.Scan(&password)
  20.     return rootPath, port, login, password
  21. }
  22. func main() {
  23.     rootPath, port, login, password := log()
  24.  
  25.     factory := &filedriver.FileDriverFactory{
  26.         RootPath: rootPath,
  27.         Perm: server.NewSimplePerm("root", "root"), // ???
  28.     }
  29.  
  30.     ftpServer := server.NewServer(&server.ServerOpts{
  31.         Factory: factory,
  32.         Hostname: "127.0.0.1",
  33.         Port:     port,
  34.         Auth: &server.SimpleAuth{
  35.             Name: login, Password: password,
  36.         },
  37.     })
  38.  
  39.     err := ftpServer.ListenAndServe()
  40.  
  41.     if err != nil {
  42.         fmt.Println("Произошла ошибка во время запуска сервера:", err)
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement