Documentation
¶
Overview ¶
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 NAME HERE <EMAIL ADDRESS>
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Copyright © 2020 Ulrich Wisser ¶
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
Index ¶
Constants ¶
const TIMEOUT = 5
Variables ¶
var AAAACmd = &cobra.Command{ Use: "AAAA", Short: "Statistics on domains with IPv6 web reachability", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: Cobra is a CLI library for Go that empowers applications. This application is a tool to generate the needed files to quickly create a Cobra application.`, Run: func(cmd *cobra.Command, args []string) { fmt.Println("AAAA called") }, }
AAAACmd represents the AAAA command
var MXCmd = &cobra.Command{ Use: "MX", Short: "Statistics on domains with IPv6 enabled email", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: Cobra is a CLI library for Go that empowers applications. This application is a tool to generate the needed files to quickly create a Cobra application.`, Run: func(cmd *cobra.Command, args []string) { fmt.Println("MX called") }, }
MXCmd represents the MX command
var NSCmd = &cobra.Command{ Use: "NS", Short: "Statistics about hosts and domain with IPv6", Long: `Extracts NS records from zone file and tries to resolve all hosts. Computes number of hosts with IPv6 and number of domains with IPv6 DNS. `, Run: func(cmd *cobra.Command, args []string) { if len(args) == 0 || args[0] == "" { log.Fatal("Zone file must be given") } rrlist := GetZone(args[0], "") if verbose > 0 { log.Printf("Starting resolving zone file %s\n", args[0]) log.Printf("Using resolvers: %v\n", resolvers) } // handle concurrency var wg sync.WaitGroup var threads = make(chan string, concurrent) defer close(threads) resolver := 0 for rr := range rrlist { RRinZonefile++ if rr.Header().Rrtype == dns.TypeNS { NSinZonefile++ domain := rr.Header().Name host := rr.(*dns.NS).Ns if verbose > 2 { log.Printf("%s NS %s", domain, host) } addNS(domain, host) if setHostIfUndefined(host) { if verbose > 2 { log.Printf("Start resolving host %s", host) } wg.Add(1) threads <- "x" go resolv(host, resolvers[resolver], &wg, threads) resolver = (resolver + 1) % len(resolvers) } } } wg.Wait() log.Println("") log.Println("") log.Printf("RR processed %7d", RRinZonefile) log.Printf("NS processed %7d", NSinZonefile) log.Printf("Reslove errors %7d", ResolvErrors) log.Printf("Domains found %7d", len(domain2host)) log.Printf("Hosts found %7d", len(hostIPv6)) log.Println("") // host stats var hasV6 int = 0 for host := range hostIPv6 { if hostIPv6[host] { hasV6++ } } log.Printf("Hosts with IPv6 %7d", hasV6) log.Printf("Host without IPv6 %7d", len(hostIPv6)-hasV6) log.Println("") // statistics counter var stats map[int]int = make(map[int]int) const ( hasAllV6 = iota hasSomeV6 hasNoV6 ) for domain := range domain2host { c := 0 for _, host := range domain2host[domain] { if hostIPv6[host] { c++ } } switch { case c == len(domain2host[domain]): stats[hasAllV6]++ case c > 0: stats[hasSomeV6]++ case c == 0: stats[hasNoV6]++ default: log.Fatal("How did we get here???") } } log.Printf("Domains with all IPv6 %7d", stats[hasAllV6]) log.Printf("Domains with some IPv6 %7d", stats[hasSomeV6]) log.Printf("Domains without IPv6 %7d", stats[hasNoV6]) }, }
NSCmd represents the NS command
var NSinZonefile int = 0
var RRinZonefile int = 0
keep processing stats
var ResolvErrors int = 0
Functions ¶
Types ¶
This section is empty.