41 lines
714 B
Go
41 lines
714 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"net"
|
|
|
|
"github.com/metonimie/simpleFTP/server/server"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
func main() {
|
|
server.InitializedConfiguration()
|
|
|
|
Addr := viper.GetString("address")
|
|
Port := viper.GetString("port")
|
|
DirDepth := viper.GetInt("maxDirDepth")
|
|
|
|
// Start the server
|
|
listener, err := net.Listen("tcp", Addr+":"+Port)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
log.Println("Hello world!")
|
|
log.Println("Running on:", Addr, "port", Port)
|
|
|
|
for {
|
|
|
|
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)
|
|
}
|
|
}
|