MCPcopy
hub / github.com/openziti/ziti / Run

Function Run

tunnel/tunnel.go:86–117  ·  view source on GitHub ↗
(zitiConn edge.Conn, clientConn net.Conn, halfClose bool)

Source from the content-addressed store, hash-verified

84}
85
86func Run(zitiConn edge.Conn, clientConn net.Conn, halfClose bool) {
87 loggerFields := logrus.Fields{
88 "src-remote": clientConn.RemoteAddr().String(), "src-local": clientConn.LocalAddr().String(),
89 "dst-local": zitiConn.LocalAddr().String(), "dst-remote": zitiConn.RemoteAddr().String(),
90 "circuitId": zitiConn.GetCircuitId()}
91
92 log := pfxlog.Logger().WithFields(loggerFields)
93 log.Info("tunnel started")
94
95 doneSend := make(chan int64)
96 doneRecv := make(chan int64)
97
98 go myCopy(clientConn, zitiConn, doneSend, halfClose, zitiConn.GetCircuitId())
99
100 go myCopy(zitiConn, clientConn, doneRecv, halfClose, zitiConn.GetRouterId())
101
102 defer func() {
103 _ = clientConn.Close()
104 _ = zitiConn.Close()
105 }()
106
107 var n1, n2 int64
108 for count := 2; count > 0; {
109 select {
110 case n1 = <-doneSend:
111 case n2 = <-doneRecv:
112 }
113 count = count - 1
114 }
115
116 log.Infof("tunnel closed: %d bytes sent; %d bytes received", n2, n1)
117}
118
119func myCopy(dst net.Conn, src net.Conn, done chan int64, halfClose bool, circuitId string) {
120 loggerFields := logrus.Fields{

Callers 2

TunnelServiceMethod · 0.85
acceptMethod · 0.85

Calls 9

myCopyFunction · 0.85
InfoMethod · 0.80
StringMethod · 0.65
LocalAddrMethod · 0.65
GetCircuitIdMethod · 0.65
WithFieldsMethod · 0.65
GetRouterIdMethod · 0.65
CloseMethod · 0.65
RemoteAddrMethod · 0.45

Tested by

no test coverage detected