Created
          September 29, 2022 06:08 
        
      - 
      
 - 
        
Save HirbodBehnam/50151410f07c62dc12e37c0d18d4d377 to your computer and use it in GitHub Desktop.  
    Check if SNI is blocked with Golang
  
        
  
    
      This file contains hidden or 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 ( | |
| "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