MCPcopy Create free account
hub / github.com/SamNet-dev/snix / handleConn

Function handleConn

cmd/snix/engine_windows.go:110–123  ·  view source on GitHub ↗
(ctx context.Context, out io.Writer, c net.Conn, remote netip.Addr, port uint16)

Source from the content-addressed store, hash-verified

108}
109
110func handleConn(ctx context.Context, out io.Writer, c net.Conn, remote netip.Addr, port uint16) {
111 defer c.Close()
112 dialer := &net.Dialer{}
113 up, err := dialer.DialContext(ctx, "tcp",
114 net.JoinHostPort(remote.String(), fmt.Sprintf("%d", port)))
115 if err != nil {
116 fmt.Fprintf(out, "snix: dial %s:%d: %v\n", remote, port, err)
117 return
118 }
119 defer up.Close()
120
121 go io.Copy(up, c)
122 _, _ = io.Copy(c, up)
123}
124
125func resolveIPv4(host string) (netip.Addr, error) {
126 if a, err := netip.ParseAddr(host); err == nil && a.Is4() {

Callers 1

runEngineFunction · 0.70

Calls 2

StringMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected