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

Function handleConn

cmd/snix/engine_linux.go:111–124  ·  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

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