MCPcopy
hub / github.com/XTLS/RealiTLScanner / main

Function main

main.go:25–117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23var url string
24
25func main() {
26 _ = os.Unsetenv("ALL_PROXY")
27 _ = os.Unsetenv("HTTP_PROXY")
28 _ = os.Unsetenv("HTTPS_PROXY")
29 _ = os.Unsetenv("NO_PROXY")
30 flag.StringVar(&addr, "addr", "", "Specify an IP, IP CIDR or domain to scan")
31 flag.StringVar(&in, "in", "", "Specify a file that contains multiple "+
32 "IPs, IP CIDRs or domains to scan, divided by line break")
33 flag.IntVar(&port, "port", 443, "Specify a HTTPS port to check")
34 flag.IntVar(&thread, "thread", 2, "Count of concurrent tasks")
35 flag.StringVar(&out, "out", "out.csv", "Output file to store the result")
36 flag.IntVar(&timeout, "timeout", 10, "Timeout for every check")
37 flag.BoolVar(&verbose, "v", false, "Verbose output")
38 flag.BoolVar(&enableIPv6, "46", false, "Enable IPv6 in additional to IPv4")
39 flag.StringVar(&url, "url", "", "Crawl the domain list from a URL, "+
40 "e.g. https://launchpad.net/ubuntu/+archivemirrors")
41 flag.Parse()
42 if verbose {
43 slog.SetDefault(slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
44 Level: slog.LevelDebug,
45 })))
46 } else {
47 slog.SetDefault(slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
48 Level: slog.LevelInfo,
49 })))
50 }
51 if !ExistOnlyOne([]string{addr, in, url}) {
52 slog.Error("You must specify and only specify one of `addr`, `in`, or `url`")
53 flag.PrintDefaults()
54 return
55 }
56 outWriter := io.Discard
57 if out != "" {
58 f, err := os.OpenFile(out, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, 0644)
59 if err != nil {
60 slog.Error("Error opening file", "path", out)
61 return
62 }
63 defer f.Close()
64 _, _ = f.WriteString("IP,ORIGIN,TLS,ALPN,CURVE,CERT_LENGTH,CERT_SIGNATURE,CERT_PUBLICKEY,CERT_DOMAIN,CERT_ISSUER,GEO_CODE\n")
65 outWriter = f
66 }
67 var hostChan <-chan Host
68 if addr != "" {
69 hostChan = IterateAddr(addr)
70 } else if in != "" {
71 f, err := os.Open(in)
72 if err != nil {
73 slog.Error("Error reading file", "path", in)
74 return
75 }
76 defer f.Close()
77 hostChan = Iterate(f)
78 } else {
79 slog.Info("Fetching url...")
80 resp, err := http.Get(url)
81 if err != nil {
82 slog.Error("Error fetching url", "err", err)

Callers

nothing calls this directly

Calls 7

ExistOnlyOneFunction · 0.85
IterateAddrFunction · 0.85
IterateFunction · 0.85
RemoveDuplicateStrFunction · 0.85
OutWriterFunction · 0.85
NewGeoFunction · 0.85
ScanTLSFunction · 0.85

Tested by

no test coverage detected