auth handling improvements

master
Jordan Orelli 11 years ago
parent e90e1ec3ea
commit 61947ead11

@ -48,6 +48,15 @@ func main() {
if options.password != "" { if options.password != "" {
fmt.Fprintf(conn, "*2\r\n$4\r\nauth\r\n$%d\r\n%s\r\n", len(options.password), options.password) fmt.Fprintf(conn, "*2\r\n$4\r\nauth\r\n$%d\r\n%s\r\n", len(options.password), options.password)
v, err := readValue(conn)
if err != nil {
fmt.Printf("unable to auth: %v\n", err)
os.Exit(1)
}
if !isOK(v) {
fmt.Printf("not OK: %v\n", v)
os.Exit(1)
}
} }
infile, err := os.Open(fname) infile, err := os.Open(fname)

@ -19,6 +19,14 @@ type value interface {
Write(io.Writer) (int, error) Write(io.Writer) (int, error)
} }
func isOK(v value) bool {
vv, ok := v.(String)
if !ok {
return false
}
return vv == "OK"
}
func streamValues(r io.Reader, c chan value, e chan error) { func streamValues(r io.Reader, c chan value, e chan error) {
defer close(c) defer close(c)
defer close(e) defer close(e)

Loading…
Cancel
Save