diff --git a/cmd/calls/main.go b/cmd/calls/main.go index 5b01d45..7133418 100644 --- a/cmd/calls/main.go +++ b/cmd/calls/main.go @@ -28,12 +28,21 @@ var ( addr = flag.String("addr", "localhost:8080", "http service address") username = flag.String("user", "", "username") password = flag.String("password", "", "password") + secure = flag.Bool("s", false, "secure (https/wss)") ) func main() { flag.Parse() log.SetFlags(0) + secureSuffix := func() string { + if *secure { + return "s" + } + + return "" + } + interrupt := make(chan os.Signal, 1) signal.Notify(interrupt, os.Interrupt) play := NewPlayer() @@ -42,7 +51,7 @@ func main() { loginForm.Add("username", *username) loginForm.Add("password", *password) - loginReq, err := http.NewRequest("POST", "http://"+*addr+"/login", strings.NewReader(loginForm.Encode())) + loginReq, err := http.NewRequest("POST", "http"+secureSuffix()+"://"+*addr+"/login", strings.NewReader(loginForm.Encode())) if err != nil { log.Fatal(err) } @@ -72,7 +81,7 @@ func main() { log.Fatal(err) } - u := url.URL{Scheme: "ws", Host: *addr, Path: "/ws"} + u := url.URL{Scheme: "ws"+secureSuffix(), Host: *addr, Path: "/ws"} log.Printf("connecting to %s", u.String()) dialer := websocket.Dialer{