X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=fifos%2Fspies.go;h=19d3c5e096e3110ec68621cd2e720c6978fbed43;hb=aca0f719ffa95e51420a625813f2f4cbf1d5397c;hp=2428ba8978a5a8351b1bd6514d4bee0ab9a32f1d;hpb=80f011b4e856b5598d17abb172687b228fac9641;p=tofuproxy.git diff --git a/fifos/spies.go b/fifos/spies.go index 2428ba8..19d3c5e 100644 --- a/fifos/spies.go +++ b/fifos/spies.go @@ -1,6 +1,6 @@ /* -tofuproxy -- flexible HTTP proxy, TLS terminator, X.509 certificates - manager, WARC/Gemini browser +tofuproxy -- flexible HTTP/HTTPS proxy, TLS terminator, X.509 TOFU + manager, WARC/geminispace browser Copyright (C) 2021 Sergey Matveev This program is free software: you can redistribute it and/or modify @@ -19,7 +19,6 @@ along with this program. If not, see . package fifos import ( - "bufio" "log" "os" @@ -45,19 +44,10 @@ func listSpies(p string) { func addSpy(p string) { for { - fd, err := os.OpenFile(p, os.O_RDONLY, os.FileMode(0666)) - if err != nil { - log.Fatalln(err) - } hosts := make(map[string]struct{}) - scanner := bufio.NewScanner(fd) - for scanner.Scan() { - t := scanner.Text() - if len(t) > 0 { - hosts[t] = struct{}{} - } + for _, line := range readLinesFromFIFO(p) { + hosts[line] = struct{}{} } - fd.Close() for host := range hosts { log.Printf("%s: adding host %s\n", p, host) }