tordam

A library for peer discovery inside the Tor network
git clone https://git.parazyd.org/tordam
Log | Files | Refs | README | LICENSE

commit bbad7869cabc96604d8ababb595b21461d6e3f69
parent 90ec84166a4843ff854ca032abc5c4054679ef2c
Author: parazyd <parazyd@dyne.org>
Date:   Fri, 26 Oct 2018 17:56:32 +0200

dam-client: Remove duplicates from final slice in fetchDirlist.

This avoids possible race conditions (confirmed).

Diffstat:
Mcmd/dam-client/main.go | 11+++++++++++
1 file changed, 11 insertions(+), 0 deletions(-)

diff --git a/cmd/dam-client/main.go b/cmd/dam-client/main.go @@ -179,6 +179,17 @@ func fetchDirlist(locations []string) ([]string, error) { } } + // Remove possible duplicats. Dupes can cause race conditions and are + // redundant to the whole logic. + encounter := map[string]bool{} + for j := range dirSlice { + encounter[dirSlice[j]] = true + } + dirSlice = []string{} + for key := range encounter { + dirSlice = append(dirSlice, key) + } + if len(dirSlice) < 1 { log.Fatalln("Couldn't get any directories. Exiting.") } else if len(dirSlice) <= 6 {