From 0a4f0e201a203d124e3ad43c18fc158099b809c8 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Thu, 28 Apr 2016 17:45:02 +0700 Subject: [PATCH] add command line option for certificate path --- example/main.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/example/main.go b/example/main.go index aa2fe6234..828fc5ff8 100644 --- a/example/main.go +++ b/example/main.go @@ -22,9 +22,12 @@ var supportedVersions = map[protocol.VersionNumber]bool{ } func main() { - path := os.Getenv("GOPATH") + "/src/github.com/lucas-clemente/quic-go/example/" + bindTo := *flag.String("bind", "localhost", "bind to") + certPathDefault := os.Getenv("GOPATH") + "/src/github.com/lucas-clemente/quic-go/example/" + certPath := *flag.String("certpath", certPathDefault, "certificate directory") + flag.Parse() - server, err := quic.NewServer(path+"cert.der", path+"key.der", handleStream) + server, err := quic.NewServer(certPath+"cert.der", certPath+"key.der", handleStream) if err != nil { panic(err) } @@ -32,10 +35,8 @@ func main() { http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Write([]byte("Hello world!")) }) - bindTo := flag.String("bind", "localhost", "bind to") - flag.Parse() - err = server.ListenAndServe(*bindTo + ":6121") + err = server.ListenAndServe(bindTo + ":6121") if err != nil { panic(err) }