riobard / go-shadowsocks2

Experimental Shadowsocks in Go. Stable fork at https://github.com/shadowsocks/go-shadowsocks2
Apache License 2.0
719 stars 1.67k forks source link

Too many goroutines created for relay udp #15

Closed linkerlin closed 7 years ago

linkerlin commented 7 years ago

func (m *natmap) Add(peer net.Addr, dst, src net.PacketConn, srcIncluded bool) { m.Set(peer.String(), src)

go func() { timedCopy(dst, peer, src, m.timeout, srcIncluded) if pc := m.Del(peer.String()); pc != nil { pc.Close() } }() }

Every udp packet need a goroutine.