From 239db674a341ca777c4ed8e8de3c089ab9039eeb Mon Sep 17 00:00:00 2001 From: Saxon Date: Mon, 14 Oct 2019 16:07:15 +1030 Subject: [PATCH] input/gvctrl: using log-in rather than log in in comments --- input/gvctrl/gvctrl.go | 8 ++++---- input/gvctrl/request.go | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/input/gvctrl/gvctrl.go b/input/gvctrl/gvctrl.go index 51fbfae1..79d260f1 100644 --- a/input/gvctrl/gvctrl.go +++ b/input/gvctrl/gvctrl.go @@ -46,7 +46,7 @@ import ( // Option describes a function that will apply an option to the passed s. type Option func(s settings) (settings, error) -// Set will log in to the camera at host and submit a form of settings. The +// Set will log-in to the camera at host and submit a form of settings. The // settings form is populated with values influenced by the optional options // passed. Available options are defined below this function. // @@ -80,13 +80,13 @@ func Set(host string, options ...Option) error { Jar: jar, } - // Get the request body required for log in. + // Get the request body required for log-in. body, err := getLogin(client, id, host) if err != nil { - return fmt.Errorf("could not generate log in request data: %v", err) + return fmt.Errorf("could not generate log-in request data: %v", err) } - // Log in using generated log in request body. + // Log in using generated log-in request body. err = login(client, id, host, body) if err != nil { return fmt.Errorf("could not login: %v", err) diff --git a/input/gvctrl/request.go b/input/gvctrl/request.go index 662cff32..3dd72b93 100644 --- a/input/gvctrl/request.go +++ b/input/gvctrl/request.go @@ -37,8 +37,8 @@ import ( // Relevant sub directories. const ( - loginSubDir = "/ssi.cgi/login.htm" // Used to get log in page. - loggedInSubDir = "/LoginPC.cgi" // Used to submit log in. + loginSubDir = "/ssi.cgi/login.htm" // Used to get log-in page. + loggedInSubDir = "/LoginPC.cgi" // Used to submit log-in. settingsSubDir = "/VideoSetting.cgi" // Used to submit settings. ) @@ -48,13 +48,13 @@ const ( pass = "admin" ) -// getLogin gets the log in page and extracts the randomly generated cc values +// getLogin gets the log-in page and extracts the randomly generated cc values // from which (as well as username and password) two hashes are generated. // The generated hex is encoded into a url encoded form and returned as a string. func getLogin(c *http.Client, id, host string) (string, error) { req, err := http.NewRequest("GET", "https://"+host+loginSubDir, nil) if err != nil { - return "", fmt.Errorf("can't create GET request for log in page: %v", err) + return "", fmt.Errorf("can't create GET request for log-in page: %v", err) } req.Header.Set("Connection", "keep-alive") @@ -68,18 +68,18 @@ func getLogin(c *http.Client, id, host string) (string, error) { resp, err := c.Do(req) if err != nil { - return "", fmt.Errorf("could not do GET request for log in page: %v", err) + return "", fmt.Errorf("could not do GET request for log-in page: %v", err) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { - return "", fmt.Errorf("could not read response of GET request for log in page: %v", err) + return "", fmt.Errorf("could not read response of GET request for log-in page: %v", err) } // Find the CC values in the source of the response. // These are used in calculation of the md5 hashes for the form submitted at - // log in. + // log-in. var cc [2]string for i := range cc { regStr := "cc" + strconv.Itoa(i+1) + "=\".{4}\"" @@ -104,7 +104,7 @@ func getLogin(c *http.Client, id, host string) (string, error) { func login(c *http.Client, id, host, b string) error { req, err := http.NewRequest("POST", "http://"+host+loggedInSubDir, bytes.NewBuffer([]byte(b))) if err != nil { - return fmt.Errorf("could not create log in request: %v", err) + return fmt.Errorf("could not create log-in request: %v", err) } req.Header.Set("Connection", "keep-alive") @@ -122,7 +122,7 @@ func login(c *http.Client, id, host, b string) error { _, err = c.Do(req) if err != nil { - return fmt.Errorf("could not do log in request: %v", err) + return fmt.Errorf("could not do log-in request: %v", err) } return nil