mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 01:40:07 +00:00
Move copyBytes closer to use-sites
This commit is contained in:
parent
cf6ccaee54
commit
20826e6d50
@ -125,6 +125,17 @@ func proxyTCP(in, out *net.TCPConn) {
|
|||||||
out.Close()
|
out.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func copyBytes(in, out *net.TCPConn, wg *sync.WaitGroup) {
|
||||||
|
defer wg.Done()
|
||||||
|
glog.Infof("Copying from %v <-> %v <-> %v <-> %v",
|
||||||
|
in.RemoteAddr(), in.LocalAddr(), out.LocalAddr(), out.RemoteAddr())
|
||||||
|
if _, err := io.Copy(in, out); err != nil {
|
||||||
|
glog.Errorf("I/O error: %v", err)
|
||||||
|
}
|
||||||
|
in.CloseRead()
|
||||||
|
out.CloseWrite()
|
||||||
|
}
|
||||||
|
|
||||||
// udpProxySocket implements proxySocket. Close() is implemented by net.UDPConn. When Close() is called,
|
// udpProxySocket implements proxySocket. Close() is implemented by net.UDPConn. When Close() is called,
|
||||||
// no new connections are allowed and existing connections are broken.
|
// no new connections are allowed and existing connections are broken.
|
||||||
// TODO: We could lame-duck this ourselves, if it becomes important.
|
// TODO: We could lame-duck this ourselves, if it becomes important.
|
||||||
@ -306,17 +317,6 @@ func NewProxier(loadBalancer LoadBalancer, address string) *Proxier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyBytes(in, out *net.TCPConn, wg *sync.WaitGroup) {
|
|
||||||
defer wg.Done()
|
|
||||||
glog.Infof("Copying from %v <-> %v <-> %v <-> %v",
|
|
||||||
in.RemoteAddr(), in.LocalAddr(), out.LocalAddr(), out.RemoteAddr())
|
|
||||||
if _, err := io.Copy(in, out); err != nil {
|
|
||||||
glog.Errorf("I/O error: %v", err)
|
|
||||||
}
|
|
||||||
in.CloseRead()
|
|
||||||
out.CloseWrite()
|
|
||||||
}
|
|
||||||
|
|
||||||
// StopProxy stops the proxy for the named service.
|
// StopProxy stops the proxy for the named service.
|
||||||
func (proxier *Proxier) StopProxy(service string) error {
|
func (proxier *Proxier) StopProxy(service string) error {
|
||||||
info, found := proxier.getServiceInfo(service)
|
info, found := proxier.getServiceInfo(service)
|
||||||
|
Loading…
Reference in New Issue
Block a user