MCPcopy
hub / github.com/windtf/wireproxy / STDIOTcpForward

Function STDIOTcpForward

routine.go:243–259  ·  view source on GitHub ↗

STDIOTcpForward starts a new connection via wireguard and forward traffic from `conn`

(vt *VirtualTun, raddr *addressPort, input *os.File, output *os.File)

Source from the content-addressed store, hash-verified

241
242// STDIOTcpForward starts a new connection via wireguard and forward traffic from `conn`
243func STDIOTcpForward(vt *VirtualTun, raddr *addressPort, input *os.File, output *os.File) {
244 target, err := vt.resolveToAddrPort(raddr)
245 if err != nil {
246 errorLogger.Printf("Name resolution error for %s: %s\n", raddr.address, err.Error())
247 return
248 }
249
250 tcpAddr := net.TCPAddrFromAddrPort(*target)
251 sconn, err := vt.Tnet.DialTCP(tcpAddr)
252 if err != nil {
253 errorLogger.Printf("TCP Client Tunnel to %s (%s): %s\n", target, tcpAddr, err.Error())
254 return
255 }
256
257 go connForward(input, sconn)
258 go connForward(sconn, output)
259}
260
261// SpawnRoutine spawns a local TCP server which acts as a proxy to the specified target
262func (conf *TCPClientTunnelConfig) SpawnRoutine(vt *VirtualTun) {

Callers 1

SpawnRoutineMethod · 0.85

Calls 2

connForwardFunction · 0.85
resolveToAddrPortMethod · 0.80

Tested by

no test coverage detected