From 1331e5769fdbada82de08966eafe4940f858f49d Mon Sep 17 00:00:00 2001 From: Niko Storni Date: Sat, 13 Jul 2019 11:33:40 +0200 Subject: [PATCH] actually use the functions I create... --- ipManager/throttle.go | 3 ++- sources/youtubeVideo.go | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/ipManager/throttle.go b/ipManager/throttle.go index 34d0d41..3d3ccc2 100644 --- a/ipManager/throttle.go +++ b/ipManager/throttle.go @@ -66,12 +66,13 @@ func GetNextIP(ipv6 bool) (string, error) { return nextIP, nil } -func releaseIP(ip string) { +func ReleaseIP(ip string) { ipMutex.Lock() defer ipMutex.Unlock() ipLastUsed[ip] = time.Now() ipInUse[ip] = false } + func getLeastUsedIP(ipPool []string) string { nextIP := "" veryLastUse := time.Now() diff --git a/sources/youtubeVideo.go b/sources/youtubeVideo.go index ac25c9c..5141ae2 100644 --- a/sources/youtubeVideo.go +++ b/sources/youtubeVideo.go @@ -221,6 +221,7 @@ func (v *YoutubeVideo) download(useIPv6 bool) error { return errors.Err(err) } } + defer ipManager.ReleaseIP(sourceAddress) if useIPv6 { log.Infof("using IPv6: %s", sourceAddress) ytdlArgs = append(ytdlArgs,