12 func testSni(ip
string, config
*ScanConfig
, record
*ScanRecord
) bool {
13 tlscfg
:= &tls
.Config
{
14 InsecureSkipVerify
: true,
17 if len(config
.HTTPVerifyHosts
) == 0 {
20 Host
= config
.HTTPVerifyHosts
[rand
.Intn(len(config
.HTTPVerifyHosts
))]
22 for _
, serverName
:= range config
.ServerName
{
24 conn
, err
:= net
.DialTimeout("tcp", net
.JoinHostPort(ip
, "443"), config
.ScanMaxRTT
)
29 tlscfg
.ServerName
= serverName
30 tlsconn
:= tls
.Client(conn
, tlscfg
)
31 tlsconn
.SetDeadline(time
.Now().Add(config
.HandshakeTimeout
))
32 if err
= tlsconn
.Handshake(); err
!= nil {
37 pcs
:= tlsconn
.ConnectionState().PeerCertificates
38 if len(pcs
) == 0 || pcs
[0].Subject
.CommonName
!= serverName
{
44 req
, err
:= http
.NewRequest(http
.MethodHead
, "https://"+serverName
, nil)
45 req
.Header
.Add("Host", Host
)
50 tlsconn
.SetDeadline(time
.Now().Add(config
.ScanMaxRTT
- time
.Since(start
)))
51 resp
, err
:= httputil
.NewClientConn(tlsconn
, nil).Do(req
)
56 // io.Copy(os.Stdout, resp.Body)
57 // if resp.Body != nil {
58 // io.Copy(ioutil.Discard, resp.Body)
61 if resp
.StatusCode
!= 404 {
69 rtt
:= time
.Since(start
)
70 if rtt
< config
.ScanMinRTT
{