From 345869608e2e71347548b5a5c026123f6ccaa2d3 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Fri, 26 May 2023 17:25:36 +0400 Subject: [PATCH] ParseAddrPort replaced with ParseAddr. Removed !ap.IsValid() since it is already done in ParseAddr. Also there is no need to additionally check if an address is IPv6. If address is neither v4 or v6, then ParseAddr will return an error. --- cmd/dwelling-upload/main.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cmd/dwelling-upload/main.go b/cmd/dwelling-upload/main.go index 600aaac..fec2933 100644 --- a/cmd/dwelling-upload/main.go +++ b/cmd/dwelling-upload/main.go @@ -45,16 +45,14 @@ func main() { network = "unix" defer os.Remove(*listenAddress) } else { - ap, err := netip.ParseAddrPort(*listenAddress) + ap, err := netip.ParseAddr(*listenAddress) if err != nil { log.Fatalln(err) - } else if !ap.IsValid() { - log.Fatalln(*listenAddress, "is not valid") } - if ap.Addr().Is4() { + if ap.Is4() { network = "tcp4" - } else if ap.Addr().Is6() { + } else { network = "tcp6" } } @@ -90,7 +88,7 @@ func main() { log.Fatalf("failed to get initial size of %s: %s", *uploadDir, err) } - watcha.WatchForMask(uploadDirNotify, watcher.CrDelMask) + go watcha.WatchForMask(uploadDirNotify, watcher.CrDelMask) hand := http.NewUploadHandlers(logFile, *uploadDir, &uploadDirSize, string(hashSalt), *keepForHours, *storageSize, *fileSizeLimit)