mirror of
https://github.com/linuxkit/linuxkit.git
synced 2026-01-05 09:14:04 +00:00
Do not need to use logrus, not using any features of it here.
Signed-off-by: Justin Cormack <justin@specialbusservice.com>
This commit is contained in:
committed by
Justin Cormack
parent
28afc72a97
commit
d0c3e873f6
@@ -2,9 +2,8 @@ package libproxy
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
type Conn interface {
|
||||
@@ -37,7 +36,7 @@ func NewTCPProxy(listener net.Listener, backendAddr *net.TCPAddr) (*TCPProxy, er
|
||||
func HandleTCPConnection(client Conn, backendAddr *net.TCPAddr, quit chan bool) {
|
||||
backend, err := net.DialTCP("tcp", nil, backendAddr)
|
||||
if err != nil {
|
||||
logrus.Printf("Can't forward traffic to backend tcp/%v: %s\n", backendAddr, err)
|
||||
log.Printf("Can't forward traffic to backend tcp/%v: %s\n", backendAddr, err)
|
||||
client.Close()
|
||||
return
|
||||
}
|
||||
@@ -46,15 +45,15 @@ func HandleTCPConnection(client Conn, backendAddr *net.TCPAddr, quit chan bool)
|
||||
var broker = func(to, from Conn) {
|
||||
written, err := io.Copy(to, from)
|
||||
if err != nil {
|
||||
logrus.Println("error copying:", err)
|
||||
log.Println("error copying:", err)
|
||||
}
|
||||
err = from.CloseRead()
|
||||
if err != nil {
|
||||
logrus.Println("error CloseRead from:", err)
|
||||
log.Println("error CloseRead from:", err)
|
||||
}
|
||||
err = to.CloseWrite()
|
||||
if err != nil {
|
||||
logrus.Println("error CloseWrite to:", err)
|
||||
log.Println("error CloseWrite to:", err)
|
||||
}
|
||||
event <- written
|
||||
}
|
||||
@@ -88,7 +87,7 @@ func (proxy *TCPProxy) Run() {
|
||||
for {
|
||||
client, err := proxy.listener.Accept()
|
||||
if err != nil {
|
||||
logrus.Printf("Stopping proxy on tcp/%v for tcp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err)
|
||||
log.Printf("Stopping proxy on tcp/%v for tcp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err)
|
||||
return
|
||||
}
|
||||
go HandleTCPConnection(client.(Conn), proxy.backendAddr, quit)
|
||||
|
||||
@@ -4,10 +4,9 @@ import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
"sync"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
type udpListener interface {
|
||||
@@ -32,7 +31,7 @@ func (u *udpEncapsulator) getConn() (net.Conn, error) {
|
||||
}
|
||||
conn, err := u.listener.Accept()
|
||||
if err != nil {
|
||||
logrus.Printf("Failed to accept connection: %#v", err)
|
||||
log.Printf("Failed to accept connection: %#v", err)
|
||||
return nil, err
|
||||
}
|
||||
u.conn = &conn
|
||||
|
||||
@@ -2,13 +2,12 @@ package libproxy
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"log"
|
||||
"net"
|
||||
"strings"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -109,7 +108,7 @@ func (proxy *UDPProxy) Run() {
|
||||
// ECONNREFUSED like Read do (see comment in
|
||||
// UDPProxy.replyLoop)
|
||||
if !isClosedError(err) {
|
||||
logrus.Printf("Stopping proxy on %v for udp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err)
|
||||
log.Printf("Stopping proxy on %v for udp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err)
|
||||
}
|
||||
break
|
||||
}
|
||||
@@ -120,7 +119,7 @@ func (proxy *UDPProxy) Run() {
|
||||
if !hit {
|
||||
proxyConn, err = net.DialUDP("udp", nil, proxy.backendAddr)
|
||||
if err != nil {
|
||||
logrus.Printf("Can't proxy a datagram to udp/%s: %s\n", proxy.backendAddr, err)
|
||||
log.Printf("Can't proxy a datagram to udp/%s: %s\n", proxy.backendAddr, err)
|
||||
proxy.connTrackLock.Unlock()
|
||||
continue
|
||||
}
|
||||
@@ -131,7 +130,7 @@ func (proxy *UDPProxy) Run() {
|
||||
for i := 0; i != read; {
|
||||
written, err := proxyConn.Write(readBuf[i:read])
|
||||
if err != nil {
|
||||
logrus.Printf("Can't proxy a datagram to udp/%s: %s\n", proxy.backendAddr, err)
|
||||
log.Printf("Can't proxy a datagram to udp/%s: %s\n", proxy.backendAddr, err)
|
||||
break
|
||||
}
|
||||
i += written
|
||||
|
||||
Reference in New Issue
Block a user