From 4a566f7dca85eafaf08b95e7f4de5a4ebd35596b Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 15 Jul 2020 04:40:31 +0000 Subject: [PATCH] more debugging --- mplexer/decoder.go | 6 ++---- mplexer/v1.go | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/mplexer/decoder.go b/mplexer/decoder.go index 047065f..333dc5b 100644 --- a/mplexer/decoder.go +++ b/mplexer/decoder.go @@ -1,6 +1,7 @@ package telebit import ( + "encoding/hex" "fmt" "io" ) @@ -44,12 +45,9 @@ func (d *Decoder) Decode(out Router) error { }() for { - //fmt.Println("poopers gonna poop") select { - // TODO, do we actually need ctx here? - // would it be sufficient to expect the reader to be closed by the caller instead? case b := <-rx: - fmt.Println("[debug] [decoder] [srv] Tunnel write", len(b), string(b)) + fmt.Println("[debug] [decoder] [srv] Tunnel write", len(b), hex.EncodeToString(b)) _, err := p.Write(b) if nil != err { fmt.Println("[debug] [decoder] [srv] Tunnel write error") diff --git a/mplexer/v1.go b/mplexer/v1.go index 51a4b05..604a535 100644 --- a/mplexer/v1.go +++ b/mplexer/v1.go @@ -125,8 +125,7 @@ func (p *Parser) unpackV1Header(b []byte, n int) ([]byte, error) { if p.state.headerLen != len(p.state.header) { return b, nil } - parts := strings.Split(string(p.state.header), ",") - fmt.Println("[debug] Tun Header", string(p.state.header)) + parts := strings.Split(strings.TrimSpace(string(p.state.header)), ",") p.state.header = nil if len(parts) < 5 { return nil, errors.New("error unpacking header") @@ -141,8 +140,7 @@ func (p *Parser) unpackV1Header(b []byte, n int) ([]byte, error) { port, _ := strconv.Atoi(parts[PortIndex]) service := parts[ServiceIndex] - fmt.Printf("[debug] parts: %s\n", parts) - fmt.Printf("[debug] service: %s\n", service) + fmt.Printf("[debug] parts: %s\n", strings.Join(parts, " | ")) if "control" == service { fmt.Printf("[debug] control: %s\n", service) return nil, errors.New("'control' messages not implemented")