Skip to content

Instantly share code, notes, and snippets.

@HirbodBehnam
Created September 29, 2022 06:08
Show Gist options
  • Save HirbodBehnam/50151410f07c62dc12e37c0d18d4d377 to your computer and use it in GitHub Desktop.
Save HirbodBehnam/50151410f07c62dc12e37c0d18d4d377 to your computer and use it in GitHub Desktop.
Check if SNI is blocked with Golang
package main
import (
"crypto/tls"
"log"
"net"
)
const hostname = "www.google.com"
const request = "GET / HTTP/1.1\r\nHost: " + hostname + "\r\nConnection: close\r\n\r\n"
func main() {
dialConn, err := net.Dial("tcp", "172.217.13.132:443") // google ip
if err != nil {
log.Fatalf("cannot dial: %s", err)
}
config := tls.Config{ServerName: hostname}
tlsConn := tls.Client(dialConn, &config)
_, err = tlsConn.Write([]byte(request))
if err != nil {
log.Fatalf("cannot write: %s", err)
}
buffer := make([]byte, 1024)
_, err = tlsConn.Read(buffer)
if err != nil {
log.Fatalf("cannot read: %s", err)
}
log.Println(string(buffer))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment