fix: Remove trailing newlines from input
This commit is contained in:
parent
393cff4847
commit
4a85116b4a
1 changed files with 5 additions and 6 deletions
11
main.go
11
main.go
|
@ -34,8 +34,8 @@ func main() {
|
||||||
fmt.Fprintf(os.Stderr, "Could not read credentials: %v\n", err)
|
fmt.Fprintf(os.Stderr, "Could not read credentials: %v\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Requesting challenge from %s as user %s\n", host, *username)
|
fmt.Println("Requesting challenge from %s as user %s\n", host, username)
|
||||||
challenge, err := triggerChallengeResponse(&host, username, password)
|
challenge, err := triggerChallengeResponse(&host, &username, &password)
|
||||||
|
|
||||||
if err != nil || challenge.LogonStatus != 4 {
|
if err != nil || challenge.LogonStatus != 4 {
|
||||||
fmt.Fprintln(os.Stderr, "Did not receive challenge from server")
|
fmt.Fprintln(os.Stderr, "Did not receive challenge from server")
|
||||||
|
@ -54,17 +54,16 @@ func main() {
|
||||||
fmt.Printf("Login succeeded, you may now (quickly) authenticate OpenVPN with %d as your password\n", token)
|
fmt.Printf("Login succeeded, you may now (quickly) authenticate OpenVPN with %d as your password\n", token)
|
||||||
}
|
}
|
||||||
|
|
||||||
func readCredentials() (*string, *string, error) {
|
func readCredentials() (string, string, error) {
|
||||||
fmt.Printf("Username: ")
|
fmt.Printf("Username: ")
|
||||||
reader := bufio.NewReader(os.Stdin)
|
reader := bufio.NewReader(os.Stdin)
|
||||||
username, err := reader.ReadString('\n')
|
username, err := reader.ReadString('\n')
|
||||||
|
|
||||||
fmt.Printf("Password: ")
|
fmt.Printf("Password: ")
|
||||||
passwordBytes, err := terminal.ReadPassword(1)
|
password, err := terminal.ReadPassword(1)
|
||||||
password := string(passwordBytes)
|
|
||||||
|
|
||||||
// If an error occured, I don't care about which one it is.
|
// If an error occured, I don't care about which one it is.
|
||||||
return &username, &password, err
|
return strings.TrimSpace(username), strings.TrimSpace(string(password)), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func triggerChallengeResponse(host *string, username *string, password *string) (r Resp, err error) {
|
func triggerChallengeResponse(host *string, username *string, password *string) (r Resp, err error) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue