2017-10-20 15:08:25 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2017-10-28 20:40:24 +00:00
|
|
|
"log"
|
|
|
|
"net"
|
2017-11-08 13:11:37 +00:00
|
|
|
|
|
|
|
"github.com/metonimie/simpleFTP/server/server"
|
2017-11-16 09:19:01 +00:00
|
|
|
"github.com/spf13/viper"
|
2017-10-20 15:08:25 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2017-11-16 09:19:01 +00:00
|
|
|
server.InitializedConfiguration()
|
|
|
|
|
|
|
|
Addr := viper.GetString("Address")
|
|
|
|
Port := viper.GetString("Port")
|
|
|
|
DirDepth := viper.GetInt("MaxDirDepth")
|
|
|
|
|
|
|
|
// Start the server
|
|
|
|
listener, err := net.Listen("tcp", Addr+":"+Port)
|
2017-10-20 15:08:25 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Println("Hello world!")
|
2017-11-16 09:19:01 +00:00
|
|
|
log.Println("Running on:", Addr, "port", Port)
|
2017-10-20 15:08:25 +00:00
|
|
|
|
|
|
|
for {
|
2017-11-08 13:11:37 +00:00
|
|
|
|
2017-10-20 15:08:25 +00:00
|
|
|
conn, err := listener.Accept()
|
|
|
|
if err != nil {
|
|
|
|
log.Print(err)
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2017-11-08 13:11:37 +00:00
|
|
|
client := server.FTPClient{}
|
2017-11-16 09:19:01 +00:00
|
|
|
client.SetStack(server.MakeStringStack(DirDepth))
|
2017-11-08 13:11:37 +00:00
|
|
|
client.SetConnection(conn)
|
|
|
|
|
|
|
|
go server.HandleConnection(&client)
|
2017-10-20 15:08:25 +00:00
|
|
|
}
|
|
|
|
}
|