Skip to content

Commit

Permalink
netutil: remove capnslog dependency
Browse files Browse the repository at this point in the history
This commit decouples netutil from capnslog, making it easier to
later deprecate it and to fix dependency loops between coreos/pkg
and coreos/go-systemd.
  • Loading branch information
lucab committed Jul 13, 2016
1 parent a48e304 commit 737983b
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 737983b

Please sign in to comment.