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

Method SpawnRoutine

routine.go:314–333  ·  view source on GitHub ↗

SpawnRoutine spawns a TCP server on wireguard which acts as a proxy to the specified target

(vt *VirtualTun)

Source from the content-addressed store, hash-verified

312
313// SpawnRoutine spawns a TCP server on wireguard which acts as a proxy to the specified target
314func (conf *TCPServerTunnelConfig) SpawnRoutine(vt *VirtualTun) {
315 raddr, err := parseAddressPort(conf.Target)
316 if err != nil {
317 log.Fatal(err)
318 }
319
320 addr := &net.TCPAddr{Port: conf.ListenPort}
321 server, err := vt.Tnet.ListenTCP(addr)
322 if err != nil {
323 log.Fatal(err)
324 }
325
326 for {
327 conn, err := server.Accept()
328 if err != nil {
329 log.Fatal(err)
330 }
331 go tcpServerForward(vt, raddr, conn)
332 }
333}
334
335func (d VirtualTun) ServeHTTP(w http.ResponseWriter, r *http.Request) {
336 log.Printf("Health metric request: %s\n", r.URL.Path)

Callers

nothing calls this directly

Calls 2

parseAddressPortFunction · 0.85
tcpServerForwardFunction · 0.85

Tested by

no test coverage detected