Skip to content

Commit

Permalink
Merge pull request #75 from lucab/to-upstream/netutil-proxy-logging
Browse files Browse the repository at this point in the history
netutil: remove capnslog dependency
  • Loading branch information
jonboulle authored Jul 27, 2016
2 parents a48e304 + 737983b commit 3ac0863
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions netutil/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,10 @@ package netutil

import (
"io"
"log"
"net"
"sync"
"time"

"github.com/coreos/pkg/capnslog"
)

var (
log = capnslog.NewPackageLogger("github.com/coreos/pkg/netutil", "main")
)

// ProxyTCP proxies between two TCP connections.
Expand All @@ -30,9 +25,9 @@ func ProxyTCP(conn1, conn2 net.Conn, tlsWriteDeadline, tlsReadDeadline time.Dura

func copyBytes(dst, src net.Conn, wg *sync.WaitGroup, writeDeadline, readDeadline time.Duration) {
defer wg.Done()
n, err := io.Copy(dst, src)
_, err := io.Copy(dst, src)
if err != nil {
log.Errorf("proxy i/o error: %v", err)
log.Printf("proxy i/o error: %v", err)
}

if cr, ok := src.(*net.TCPConn); ok {
Expand All @@ -50,6 +45,4 @@ func copyBytes(dst, src net.Conn, wg *sync.WaitGroup, writeDeadline, readDeadlin
rto := time.Now().Add(readDeadline)
dst.SetReadDeadline(rto)
}

log.Debugf("proxy copied %d bytes %s -> %s", n, src.RemoteAddr(), dst.RemoteAddr())
}

0 comments on commit 3ac0863

Please sign in to comment.