diff --git a/cmd/httpsocket/main.go b/cmd/httpsocket/main.go index b4db14e..7def4b5 100644 --- a/cmd/httpsocket/main.go +++ b/cmd/httpsocket/main.go @@ -18,7 +18,7 @@ type ConfigTOML struct { } func main() { - + log.Println("Program started") cfg, err := configs.GetConfigTOML() if err != nil { log.Fatal(err) @@ -31,6 +31,6 @@ func main() { fs := http.FileServer(http.Dir(cfg.Config.Cache_d)) http.Handle("/", fs) - log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", cfg.Config.HttpPort), nil)) + log.Printf("Listening and serving on port %d\n", cfg.Config.HttpPort) } diff --git a/cmd/udpsocket/main.go b/cmd/udpsocket/main.go index 328bd68..5e1bd0e 100644 --- a/cmd/udpsocket/main.go +++ b/cmd/udpsocket/main.go @@ -23,6 +23,7 @@ func CheckDownloaded(filename string) bool { } func main() { + log.Println("Program started") pid := os.Getpid() if err := os.WriteFile(filepath.Join(consts.DefaultLinux_d, "udp.pid"), []byte(fmt.Sprint(pid)), 0664); err != nil { fmt.Println("error saving subprocess pid", err) @@ -37,6 +38,7 @@ func main() { if err != nil { log.Fatal(err) } + log.Println("Started connection listener") defer conn.Close() buf := make([]byte, 1500) @@ -46,12 +48,15 @@ func main() { log.Println("error creating udp socket", err) } msg := string(buf[:n]) + log.Printf("Received message : %s\n", msg) if !strings.HasPrefix(msg, "Q:") { + log.Println("error: invalid message, this message don't follow the protocol") continue } filename := strings.TrimPrefix(msg, "Q:") if CheckDownloaded(filename) { reply := fmt.Sprintf("H:%s:%d", filename, cfg.Config.HttpPort) + log.Printf("Package founded in cache dir, answering with: '%s'\n", reply) conn.WriteToUDP([]byte(reply), remote) } }