|
|
@ -47,8 +47,7 @@ func main() {
|
|
|
|
defer conn.Close()
|
|
|
|
defer conn.Close()
|
|
|
|
|
|
|
|
|
|
|
|
if options.password != "" {
|
|
|
|
if options.password != "" {
|
|
|
|
auth(options.password).Write(conn)
|
|
|
|
auth(options.password).Write(conn)
|
|
|
|
// 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)
|
|
|
|
v, err := readValue(conn)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("unable to auth: %v\n", err)
|
|
|
|
fmt.Printf("unable to auth: %v\n", err)
|
|
|
@ -67,49 +66,30 @@ func main() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defer infile.Close()
|
|
|
|
defer infile.Close()
|
|
|
|
|
|
|
|
|
|
|
|
c, e := make(chan value), make(chan error)
|
|
|
|
c := make(chan maybe)
|
|
|
|
sent := make(chan value)
|
|
|
|
sent := make(chan value)
|
|
|
|
go streamValues(infile, c, e)
|
|
|
|
go streamValues(infile, c)
|
|
|
|
go func() {
|
|
|
|
go func() {
|
|
|
|
for {
|
|
|
|
defer close(sent)
|
|
|
|
select {
|
|
|
|
for r := range c {
|
|
|
|
case v, ok := <-c:
|
|
|
|
if r.ok() {
|
|
|
|
if !ok {
|
|
|
|
r.val().Write(conn)
|
|
|
|
return
|
|
|
|
sent <- r.val()
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
v.Write(conn)
|
|
|
|
// this bad
|
|
|
|
sent <- v
|
|
|
|
fmt.Println(r.err())
|
|
|
|
case err, ok := <-e:
|
|
|
|
|
|
|
|
if !ok {
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println(err)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
|
|
|
|
|
|
|
|
type pair struct {
|
|
|
|
responses := make(chan maybe)
|
|
|
|
request value
|
|
|
|
go streamValues(conn, responses)
|
|
|
|
response value
|
|
|
|
for request := range sent {
|
|
|
|
}
|
|
|
|
response := <-responses
|
|
|
|
|
|
|
|
if response.ok() {
|
|
|
|
cc, ee := make(chan value), make(chan error)
|
|
|
|
fmt.Fprintf(os.Stdout, "%v +> %v\n", request, response.val())
|
|
|
|
go streamValues(conn, cc, ee)
|
|
|
|
} else {
|
|
|
|
ReadResponses:
|
|
|
|
fmt.Fprintf(os.Stderr, "%v -> %v\n", request, response.val())
|
|
|
|
for {
|
|
|
|
|
|
|
|
select {
|
|
|
|
|
|
|
|
case response, ok := <-cc:
|
|
|
|
|
|
|
|
if !ok {
|
|
|
|
|
|
|
|
break ReadResponses
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
request := <-sent
|
|
|
|
|
|
|
|
fmt.Println(pair{request, response})
|
|
|
|
|
|
|
|
case err, ok := <-ee:
|
|
|
|
|
|
|
|
if !ok {
|
|
|
|
|
|
|
|
break ReadResponses
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
request := <-sent
|
|
|
|
|
|
|
|
fmt.Printf("fuck %v %v\n", request, err)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|