Skip to content

Commit fa310c5

Browse files
committed
Fix single domain address
1 parent d2842f1 commit fa310c5

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func main() {
108108
for i := 0; i < thread; i++ {
109109
go func() {
110110
for ip := range hostChan {
111-
s.Scan(ip, outCh, true)
111+
ip = s.Scan(ip, outCh, true)
112112
if ip.Infinity { // only one ip
113113
for i := 0; i < thread - 1; i++ {
114114
go s.Scan(ip, outCh, i%2 == 1)

scanner.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ type Scanner struct {
1717
low net.IP
1818
}
1919

20-
func (s *Scanner) Scan(host Host, out chan<- string, increment bool) {
20+
func (s *Scanner) Scan(host Host, out chan<- string, increment bool) Host {
2121
if host.Infinity && host.IP != nil {
2222
s.mu.Lock()
2323
if s.high == nil {
@@ -34,18 +34,19 @@ func (s *Scanner) Scan(host Host, out chan<- string, increment bool) {
3434
}
3535
s.mu.Unlock()
3636
}
37-
ScanTLS(host, out, increment)
37+
host = ScanTLS(host, out, increment)
3838
if host.Infinity && host.IP != nil {
3939
go s.Scan(host, out, increment)
4040
}
41+
return host
4142
}
4243

43-
func ScanTLS(host Host, out chan<- string, increment bool) {
44+
func ScanTLS(host Host, out chan<- string, increment bool) Host {
4445
if host.IP == nil {
4546
ips, err := net.LookupIP(host.Origin)
4647
if err != nil {
4748
slog.Debug("Failed to lookup", "origin", host.Origin, "err", err)
48-
return
49+
return host
4950
}
5051
var arr []net.IP
5152
for _, ip := range ips {
@@ -55,21 +56,21 @@ func ScanTLS(host Host, out chan<- string, increment bool) {
5556
}
5657
if len(arr) == 0 {
5758
slog.Debug("No IP found", "origin", host.Origin)
58-
return
59+
return host
5960
}
6061
host.IP = arr[0]
6162
}
6263
hostPort := net.JoinHostPort(host.IP.String(), strconv.Itoa(port))
6364
conn, err := net.DialTimeout("tcp", hostPort, time.Duration(timeout)*time.Second)
6465
if err != nil {
6566
slog.Debug("Cannot dial", "target", hostPort)
66-
return
67+
return host
6768
}
6869
defer conn.Close()
6970
err = conn.SetDeadline(time.Now().Add(time.Duration(timeout) * time.Second))
7071
if err != nil {
7172
slog.Error("Error setting deadline", "err", err)
72-
return
73+
return host
7374
}
7475
tlsCfg := &tls.Config{
7576
InsecureSkipVerify: true,
@@ -83,7 +84,7 @@ func ScanTLS(host Host, out chan<- string, increment bool) {
8384
err = c.Handshake()
8485
if err != nil {
8586
slog.Debug("TLS handshake failed", "target", hostPort)
86-
return
87+
return host
8788
}
8889
state := c.ConnectionState()
8990
alpn := state.NegotiatedProtocol
@@ -101,6 +102,7 @@ func ScanTLS(host Host, out chan<- string, increment bool) {
101102
log("Connected to target", "feasible", feasible, "ip", host.IP.String(),
102103
"origin", host.Origin,
103104
"tls", tls.VersionName(state.Version), "alpn", alpn, "cert-domain", domain, "cert-issuer", issuers)
105+
return host
104106
}
105107

106108
func nextIP(ip net.IP, increment bool) net.IP {

0 commit comments

Comments
 (0)