Skip to content

Commit

Permalink
add response for invalid music request, fixed txthinking#18
Browse files Browse the repository at this point in the history
  • Loading branch information
txthinking committed May 15, 2017
1 parent 34fb4ce commit 84ee333
Show file tree
Hide file tree
Showing 7 changed files with 2,628 additions and 2 deletions.
2 changes: 2 additions & 0 deletions bkclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"crypto/aes"
"crypto/rand"
"errors"
"fmt"
"io"
"log"
"net"
Expand Down Expand Up @@ -246,6 +247,7 @@ func (c *BKClient) handleHTTP(conn *net.TCPConn) error {
return errors.New("Invalid Request")
}
method, aoru := string(bb[0]), string(bb[1])
fmt.Print(string(b))
var addr string
if method == "CONNECT" {
addr = aoru
Expand Down
8 changes: 8 additions & 0 deletions bkserver.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package brook

import (
"bytes"
"crypto/aes"
"errors"
"io"
Expand Down Expand Up @@ -90,6 +91,13 @@ func (s *BKServer) handle(c *net.TCPConn) error {
if _, err := io.ReadFull(c, tmp); err != nil {
return err
}
if !bytes.Equal(tmp, s.Music.GetSong()) {
log.Println("Got a invalid song")
if _, err := c.Write(s.Music.GetResponse(tmp)); err != nil {
return err
}
return nil
}
}
cc, err := s.wrapCipherConn(c)
if err != nil {
Expand Down
572 changes: 571 additions & 1 deletion music/chinamobile_sdc.go

Large diffs are not rendered by default.

0 comments on commit 84ee333

Please sign in to comment.