From f4fa112822c63fce2174d50c6d32f7319a0428f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E5=BF=97=E5=AE=87?= Date: Mon, 8 Apr 2019 17:00:18 +0800 Subject: [PATCH] Removed debug messages. --- pkg/router/route_manager.go | 2 -- pkg/router/route_manager_test.go | 6 ------ pkg/setup/protocol.go | 13 ------------- 3 files changed, 21 deletions(-) diff --git a/pkg/router/route_manager.go b/pkg/router/route_manager.go index 96c2c04d5..7cc62f9db 100644 --- a/pkg/router/route_manager.go +++ b/pkg/router/route_manager.go @@ -75,14 +75,12 @@ func (rm *routeManager) RemoveLoopRule(addr *app.LoopAddr) error { func (rm *routeManager) Serve(rw io.ReadWriter) error { proto := setup.NewProtocol(rw) - fmt.Println("got proto!") t, body, err := proto.ReadPacket() if err != nil { fmt.Println("err:", err) return err } - fmt.Println("read packet!") rm.Logger.Infof("Got new Setup request with type %s", t) var respBody interface{} diff --git a/pkg/router/route_manager_test.go b/pkg/router/route_manager_test.go index 90b51d01f..878454901 100644 --- a/pkg/router/route_manager_test.go +++ b/pkg/router/route_manager_test.go @@ -1,7 +1,6 @@ package router import ( - "fmt" "net" "testing" "time" @@ -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() { @@ -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.NewProtocol(in) diff --git a/pkg/setup/protocol.go b/pkg/setup/protocol.go index c6667f302..c3ff77366 100644 --- a/pkg/setup/protocol.go +++ b/pkg/setup/protocol.go @@ -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") } @@ -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 }