simplFT/server/simplFTP.go

42 lines
714 B
Go
Raw Normal View History

2017-10-20 15:08:25 +00:00
package main
import (
2017-10-28 20:40:24 +00:00
"log"
"net"
"github.com/metonimie/simpleFTP/server/server"
"github.com/spf13/viper"
2017-10-20 15:08:25 +00:00
)
func main() {
server.InitializedConfiguration()
2017-11-24 20:37:09 +00:00
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!")
log.Println("Running on:", Addr, "port", Port)
2017-10-20 15:08:25 +00:00
for {
2017-10-20 15:08:25 +00:00
conn, err := listener.Accept()
if err != nil {
log.Print(err)
continue
}
client := server.FTPClient{}
client.SetStack(server.MakeStringStack(DirDepth))
client.SetConnection(conn)
go server.HandleConnection(&client)
2017-10-20 15:08:25 +00:00
}
}