Skip to content

Commit

Permalink
Fix data reading
Browse files Browse the repository at this point in the history
  • Loading branch information
askolesov committed Nov 3, 2024
1 parent 59bdfbe commit 58541cb
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions pkg/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,21 @@ func (p *Proxy) proxy(dst, src net.Conn, t codec.Transformer) {
buf := make([]byte, 1024)
for {
n, err := src.Read(buf)
if n > 0 {
data := buf[:n]
data = t(data)

_, writeErr := dst.Write(data)
if writeErr != nil {
log.Printf("Error writing to connection: %v", writeErr)
return
}
}
if err != nil {
if err != io.EOF {
log.Printf("Error reading from connection: %v", err)
}
return
}

buf = buf[:n]

buf = t(buf)

_, err = dst.Write(buf)
if err != nil {
log.Printf("Error writing to connection: %v", err)
return
}
}
}

0 comments on commit 58541cb

Please sign in to comment.