Skip to content

Commit

Permalink
Merge branch 'mainnet' into bug/apps-create-multiple-transports-248
Browse files Browse the repository at this point in the history
  • Loading branch information
ayuryshev committed Apr 8, 2019
2 parents f7f1059 + 3a6411a commit 64edf77
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 20 deletions.
1 change: 0 additions & 1 deletion pkg/router/route_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func (rm *routeManager) Serve(rw io.ReadWriter) error {
fmt.Println("err:", err)
return err
}
fmt.Println("read packet!")
rm.Logger.Infof("Got new Setup request with type %s", t)

var respBody interface{}
Expand Down
6 changes: 0 additions & 6 deletions pkg/router/route_manager_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package router

import (
"fmt"
"net"
"testing"
"time"
Expand Down Expand Up @@ -59,16 +58,13 @@ func TestRouteManagerRemoveLoopRule(t *testing.T) {
}

func TestRouteManagerAddRemoveRule(t *testing.T) {
fmt.Println("start!")
done := make(chan struct{})
expired := time.NewTimer(time.Second * 5)
go func() {
select {
case <-done:
fmt.Println("done!")
return
case <-expired.C:
fmt.Println("expired!")
}
}()
defer func() {
Expand All @@ -80,9 +76,7 @@ func TestRouteManagerAddRemoveRule(t *testing.T) {
in, out := net.Pipe()
errCh := make(chan error)
go func() {
fmt.Println("watiting serve...")
errCh <- rm.Serve(out)
fmt.Println("DONE!")
}()

proto := setup.NewSetupProtocol(in)
Expand Down
13 changes: 0 additions & 13 deletions pkg/setup/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,11 @@ func (p *Protocol) ReadPacket() (PacketType, []byte, error) {
if _, err := io.ReadFull(p.rw, rawLen); err != nil {
return 0, nil, err
}
fmt.Println("ReadPacket: rawLen:", rawLen)
rawBody := make([]byte, binary.BigEndian.Uint16(rawLen))
_, err := io.ReadFull(p.rw, rawBody)
if err != nil {
return 0, nil, err
}
fmt.Println("ReadPacket: rawBody:", rawBody)
if len(rawBody) == 0 {
return 0, nil, errors.New("empty packet")
}
Expand All @@ -98,28 +96,17 @@ func (p *Protocol) WritePacket(t PacketType, body interface{}) error {
if err != nil {
return err
}
fmt.Printf("WritePacket: raw(%d): %v\n", len(raw), raw)

var buf bytes.Buffer
buf.Grow(3 + len(raw))
fmt.Printf("WritePacket: buf(len:%d,cap:%d)\n", buf.Len(), buf.Cap())

if err := binary.Write(&buf, binary.BigEndian, uint16(1+len(raw))); err != nil {
return err
}
fmt.Printf("WritePacket: binary.Write [OKAY]\n")

if err := buf.WriteByte(byte(t)); err != nil {
return err
}
fmt.Printf("WritePacket: buf.WriteByte [OKAY]\n")

if _, err := buf.Write(raw); err != nil {
return err
}
fmt.Printf("WritePacket: buf.Write [OKAY]\n")
fmt.Printf("WritePacket: buf(%d): %v\n", buf.Len(), buf.Bytes())

_, err = buf.WriteTo(p.rw)
return err
}
Expand Down

0 comments on commit 64edf77

Please sign in to comment.