1
0
Fork 0

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.

This commit is contained in:
Alexander Andreev 2023-05-26 17:25:36 +04:00
parent d94030a4e8
commit 345869608e
Signed by: Arav
GPG Key ID: D22A817D95815393
1 changed files with 4 additions and 6 deletions

View File

@ -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)