Created
May 9, 2014 17:05
-
-
Save yorkie/3113e6e83b91d173d847 to your computer and use it in GitHub Desktop.
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 ( | |
"flag" | |
"net/http" | |
"crypto/tls" | |
"crypto/x509" | |
"io/ioutil" | |
"log" | |
) | |
var addr = flag.String("addr", ":1718", "http service address") | |
func QR(w http.ResponseWriter, req *http.Request) { | |
} | |
func main() { | |
cert2_b, _ := ioutil.ReadFile("cert2.pem") | |
priv2_b, _ := ioutil.ReadFile("cert2.key") | |
priv2, _ := x509.ParsePKCS1PrivateKey(priv2_b) | |
cert := tls.Certificate{ | |
Certificate: [][]byte{ cert2_b }, | |
PrivateKey: priv2, | |
} | |
config := tls.Config{Certificates: []tls.Certificate{cert}, InsecureSkipVerify: true} | |
for i := 0; i < 40000; i++ { | |
go func() { | |
conn, err := tls.Dial("tcp", "imap.gmail.com:993", &config) | |
if err != nil { | |
log.Println("client: dial: %s", err) | |
} else { | |
log.Println("client: connected to: ", conn.RemoteAddr()) | |
} | |
}() | |
} | |
flag.Parse() | |
http.Handle("/", http.HandlerFunc(QR)) | |
err := http.ListenAndServe(*addr, nil) | |
if err != nil { | |
log.Fatal("ListenAndServe:", err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment