From 12e774a3b42c866e3f88603d408dc82ead098d5e Mon Sep 17 00:00:00 2001 From: Justin Reichardt Date: Thu, 9 Dec 2021 15:36:45 -0600 Subject: [PATCH] Pass lists of downloads and sites Main is now passed 2 arrays or strings: downloads and sites --- src/rhosts.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/rhosts.go b/src/rhosts.go index 7b139e5..fdbc29d 100644 --- a/src/rhosts.go +++ b/src/rhosts.go @@ -35,7 +35,9 @@ func main() { sysdetect (&tmpdir, &hostsloc, &cfgloc) - cfgparse(cfgloc) + sites, downloads := cfgparse(cfgloc) + log.Print("Sites:\n",sites) + log.Print("Downloads:\n",downloads) } @@ -57,7 +59,9 @@ func sysdetect (tmpdir, hostsloc, cfgloc *string) { } } -func cfgparse (cfgloc string){ +func cfgparse (cfgloc string) ([]string, []string){ + var downloads []string + var sites []string log.Print("Opening: ", cfgloc) file, err := os.Open(cfgloc) defer file.Close() @@ -68,12 +72,18 @@ func cfgparse (cfgloc string){ filebuf.Split(bufio.ScanLines) for res := filebuf.Scan();res;res = filebuf.Scan() { state, body := cfgparseline(filebuf.Text()) - log.Print(state, body) + switch state { + case 3: + sites =append(sites,body) + case 4: + downloads = append(downloads,body) + } } err = filebuf.Err() if err != nil { log.Fatal(err) } + return sites,downloads } func cfgparseline(buf string) (uint8, string){ // State options