From a0df2d5dd45e66035624b54993e5d65b6a00f32d Mon Sep 17 00:00:00 2001 From: Steven Black Date: Mon, 26 Apr 2021 00:13:33 -0400 Subject: [PATCH] =?UTF-8?q?Issue=20#17:=20fix=20=E2=80=94=20introduce=20th?= =?UTF-8?q?e=20shortcuts=20hashmap,=20and=20assign=20the=20.value=20to=20m?= =?UTF-8?q?ainHosts=20if=20we=20have=20a=20shortcut.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 504a401..b562be8 100644 --- a/main.go +++ b/main.go @@ -377,14 +377,14 @@ func reverse(a []string) []string { } func FlagSet() { - defaultMainHosts := "base" + defaultMainHosts := "base" flag.StringVar(&compareHosts, "c", "", "Hosts list to compare. A full URL, or a local file.\nUse the -m option for the main comparison list.\nUse the -clip option to use what is on the system clipboard.") flag.BoolVar(&sysclipboard, "clip", false, "The comparison hosts are in the system clipboard") flag.BoolVar(&addDefaults, "d", false, "Include default hosts at the top of file.") flag.BoolVar(&intersectionList, "intersection", false, "Return the list of intersection hosts? (default false)") flag.BoolVar(&uniquelist, "unique", false, "List the unique domains in the comparison list") flag.StringVar(&ipLocalhost, "ip", "0.0.0.0", "Localhost IP address") - flag.StringVar(&mainHosts, "m", defaultMainHosts, "The main list of hosts to analyze, or serve as a basis for comparison.\nA full URL, or a local file.\n") + flag.StringVar(&mainHosts, "m", defaultMainHosts, "The main list of hosts to analyze, or serve as a basis for comparison.\nA full URL, or a local file.\n") flag.BoolVar(&noheader, "noheader", false, "Remove the file header from output? (default false)") flag.BoolVar(&output, "o", false, "Return the list of hosts? (default false)") flag.BoolVar(&plainOutput, "p", false, "Return a plain output list of hosts, with no IP address prefix? (default false)") @@ -399,6 +399,31 @@ func main() { FlagSet() hf1 := Hosts{} + mainHostsShortcuts := map[string]string{ + "b": "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts", + "base": "https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts", + "f": "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews/hosts", + "fg": "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling/hosts", + "fgp": "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn/hosts", + "fgps": "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-porn-social/hosts", + "fgs": "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-gambling-social/hosts", + "fp": "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-porn/hosts", + "fps": "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-porn-social/hosts", + "fs": "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/fakenews-social/hosts", + "g": "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/gambling/hosts", + "gp": "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/gambling-porn/hosts", + "gps": "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/gambling-porn-social/hosts", + "gs": "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/gambling-social/hosts", + "p": "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/porn/hosts", + "ps": "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/porn-social/hosts", + "s": "https://raw.githubusercontent.com/StevenBlack/hosts/master/alternates/social/hosts", + } + + _, shortCode := mainHostsShortcuts[mainHosts] + if shortCode { + mainHosts = mainHostsShortcuts[mainHosts] + } + hf1.Load(mainHosts) if stats && !output {