Skip to content

Commit 275b6b8

Browse files
committed
Adds dialer and timeout tweaks; gofmt run
1 parent 0b9bce2 commit 275b6b8

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
domains
22
hosts
33
httprobe
4+
*.tgz
5+
*.zip
6+
*.exe

main.go

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"crypto/tls"
66
"flag"
77
"fmt"
8+
"net"
89
"net/http"
910
"os"
1011
"strings"
@@ -51,9 +52,14 @@ func main() {
5152
timeout := time.Duration(to * 1000000)
5253

5354
var tr = &http.Transport{
54-
MaxIdleConns: 30,
55-
IdleConnTimeout: time.Second,
56-
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
55+
MaxIdleConns: 30,
56+
IdleConnTimeout: time.Second,
57+
DisableKeepAlives: true,
58+
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
59+
DialContext: (&net.Dialer{
60+
Timeout: timeout,
61+
KeepAlive: time.Second,
62+
}).DialContext,
5763
}
5864

5965
re := func(req *http.Request, via []*http.Request) error {
@@ -105,29 +111,29 @@ func main() {
105111

106112
// Adding port templates
107113
xlarge := []string{"81", "300", "591", "593", "832", "981", "1010", "1311", "2082", "2087", "2095", "2096", "2480", "3000", "3128", "3333", "4243", "4567", "4711", "4712", "4993", "5000", "5104", "5108", "5800", "6543", "7000", "7396", "7474", "8000", "8001", "8008", "8014", "8042", "8069", "8080", "8081", "8088", "8090", "8091", "8118", "8123", "8172", "8222", "8243", "8280", "8281", "8333", "8443", "8500", "8834", "8880", "8888", "8983", "9000", "9043", "9060", "9080", "9090", "9091", "9200", "9443", "9800", "9981", "12443", "16080", "18091", "18092", "20720", "28017"}
108-
large := []string{"81","591","2082","2087","2095","2096","3000","8000","8001","8008","8080","8083","8443","8834","8888"}
109-
114+
large := []string{"81", "591", "2082", "2087", "2095", "2096", "3000", "8000", "8001", "8008", "8080", "8083", "8443", "8834", "8888"}
115+
110116
// submit any additional proto:port probes
111117
for _, p := range probes {
112118
switch p {
113119
case "xlarge":
114120
for _, port := range xlarge {
115-
urls <- fmt.Sprintf("http://%s:%s", domain, port)
116-
urls <- fmt.Sprintf("https://%s:%s", domain, port)
117-
}
121+
urls <- fmt.Sprintf("http://%s:%s", domain, port)
122+
urls <- fmt.Sprintf("https://%s:%s", domain, port)
123+
}
118124
case "large":
119125
for _, port := range large {
120-
urls <- fmt.Sprintf("http://%s:%s", domain, port)
121-
urls <- fmt.Sprintf("https://%s:%s", domain, port)
122-
}
126+
urls <- fmt.Sprintf("http://%s:%s", domain, port)
127+
urls <- fmt.Sprintf("https://%s:%s", domain, port)
128+
}
123129
default:
124130
pair := strings.SplitN(p, ":", 2)
125-
if len(pair) != 2 {
126-
continue
127-
}
131+
if len(pair) != 2 {
132+
continue
133+
}
128134
urls <- fmt.Sprintf("%s://%s:%s", pair[0], domain, pair[1])
129135
}
130-
}
136+
}
131137
}
132138

133139
// once we've sent all the URLs off we can close the

0 commit comments

Comments
 (0)