Created
September 13, 2020 12:38
-
-
Save HirbodBehnam/362ba9490aca6b8e10d87558dc7528f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
tls "github.com/refraction-networking/utls" | |
"net" | |
"time" | |
) | |
var requestHostname = "cloudfront.com" | |
var requestAddr = "1.1.1.1:443" | |
var dialTimeout = time.Duration(5) * time.Second | |
func HttpGetDefault(hostname string, addr string) error { | |
config := tls.Config{ServerName: hostname, InsecureSkipVerify: true} | |
dialConn, err := net.DialTimeout("tcp", addr, dialTimeout) | |
if err != nil { | |
return fmt.Errorf("net.DialTimeout error: %+v", err) | |
} | |
tlsConn := tls.Client(dialConn, &config) | |
defer tlsConn.Close() | |
return nil | |
} | |
func HttpGetByHelloID(hostname string, addr string, helloID tls.ClientHelloID) error { | |
config := tls.Config{ServerName: hostname, InsecureSkipVerify: true} | |
dialConn, err := net.DialTimeout("tcp", addr, dialTimeout) | |
if err != nil { | |
return fmt.Errorf("net.DialTimeout error: %+v", err) | |
} | |
uTlsConn := tls.UClient(dialConn, &config, helloID) | |
defer uTlsConn.Close() | |
err = uTlsConn.Handshake() | |
if err != nil { | |
return fmt.Errorf("uTlsConn.Handshake() error: %+v", err) | |
} | |
return nil | |
} | |
func main(){ | |
err := HttpGetDefault(requestHostname, requestAddr) | |
if err != nil{ | |
fmt.Println("Normal: ERROR:", err.Error()) | |
}else{ | |
fmt.Println("Normal: OK") | |
} | |
ids := []tls.ClientHelloID{tls.HelloChrome_58,tls.HelloChrome_62,tls.HelloChrome_70,tls.HelloChrome_72,tls.HelloChrome_83,tls.HelloIOS_11_1,tls.HelloIOS_12_1,tls.HelloFirefox_55,tls.HelloFirefox_56,tls.HelloFirefox_63,tls.HelloFirefox_65,tls.HelloGolang} | |
for _, id := range ids{ | |
err = HttpGetByHelloID(requestHostname, requestAddr, id) | |
if err != nil{ | |
fmt.Println(id.Str() + ": ERROR:", err.Error()) | |
}else{ | |
fmt.Println(id.Str() + ": OK") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment