diff --git a/cmd/clientFunc.go b/cmd/clientFunc.go index 770233f..8e50de0 100644 --- a/cmd/clientFunc.go +++ b/cmd/clientFunc.go @@ -7,6 +7,7 @@ package cmd import ( "bufio" "fmt" + "io" "log" "net" "os" @@ -53,7 +54,28 @@ func Client() { log.Fatalf("Error occurred reading from server while requesting name: %v\n", err) } fmt.Print(nameRequest) - sendName(conn) + test := make([]byte, 2048) + copy(test, "Password: ") + + if nameRequest == string(test) { + pass, err := scanLine() + if err != nil { + log.Fatal(err) + } + conn.Write([]byte(pass)) + + nameRequest, err := receiveMessage(conn) + if err != nil { + if err != io.EOF { + log.Fatalf("Error occurred reading from server while requesting name: %v\n", err) + } + os.Exit(1) + } + fmt.Print(nameRequest) + sendName(conn) + } else { + sendName(conn) + } GUI() }