mirror of
https://github.com/XTLS/RealiTLScanner.git
synced 2026-10-05 21:47:56 +03:00
Add back infinity mode (default for single address)
This commit is contained in:
+47
-1
@@ -3,13 +3,44 @@ package main
|
||||
import (
|
||||
"crypto/tls"
|
||||
"log/slog"
|
||||
"math/big"
|
||||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
func ScanTLS(host Host, out chan<- string) {
|
||||
type Scanner struct {
|
||||
mu *sync.Mutex
|
||||
high net.IP
|
||||
low net.IP
|
||||
}
|
||||
|
||||
func (s *Scanner) Scan(host Host, out chan<- string, increment bool) {
|
||||
if host.Infinity && host.IP != nil {
|
||||
s.mu.Lock()
|
||||
if s.high == nil {
|
||||
s.high = host.IP
|
||||
s.low = host.IP
|
||||
host.Origin = ""
|
||||
host.Type = HostTypeIP
|
||||
} else if increment {
|
||||
s.high = nextIP(s.high, increment)
|
||||
host.IP = s.high
|
||||
} else {
|
||||
s.low = nextIP(s.low, increment)
|
||||
host.IP = s.low
|
||||
}
|
||||
s.mu.Unlock()
|
||||
}
|
||||
ScanTLS(host, out, increment)
|
||||
if host.Infinity && host.IP != nil {
|
||||
go s.Scan(host, out, increment)
|
||||
}
|
||||
}
|
||||
|
||||
func ScanTLS(host Host, out chan<- string, increment bool) {
|
||||
if host.IP == nil {
|
||||
ips, err := net.LookupIP(host.Origin)
|
||||
if err != nil {
|
||||
@@ -71,3 +102,18 @@ func ScanTLS(host Host, out chan<- string) {
|
||||
"origin", host.Origin,
|
||||
"tls", tls.VersionName(state.Version), "alpn", alpn, "cert-domain", domain, "cert-issuer", issuers)
|
||||
}
|
||||
|
||||
func nextIP(ip net.IP, increment bool) net.IP {
|
||||
// Convert to big.Int and increment
|
||||
ipb := big.NewInt(0).SetBytes([]byte(ip))
|
||||
if increment {
|
||||
ipb.Add(ipb, big.NewInt(1))
|
||||
} else {
|
||||
ipb.Sub(ipb, big.NewInt(1))
|
||||
}
|
||||
|
||||
// Add leading zeros
|
||||
b := ipb.Bytes()
|
||||
b = append(make([]byte, len(ip)-len(b)), b...)
|
||||
return net.IP(b)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user