func (r *ForwarderRequest) Complete(sendReset bool) {
	r.mu.Lock()
	defer r.mu.Unlock()
	if r.segment == nil {
		panic("Completing already completed forwarder request")
	}
	r.forwarder.mu.Lock()
	delete(r.forwarder.inFlight, r.segment.id)
	r.forwarder.mu.Unlock()
	if sendReset {
		replyWithReset(r.segment)
	}
	r.segment.decRef()
	r.segment = nil
	r.forwarder = nil
}
Complete completes the request, and optionally sends a RST segment back to the
sender.
package tcp
import (
	"sync"
	tcpip "github.com/brewlin/net-protocol/protocol"
	"github.com/brewlin/net-protocol/pkg/buffer"
	"github.com/brewlin/net-protocol/protocol/header"
	"github.com/brewlin/net-protocol/pkg/seqnum"
	"github.com/brewlin/net-protocol/stack"
	"github.com/brewlin/net-protocol/pkg/waiter"
)
type Forwarder struct {
	maxInFlight int
	handler     func(*ForwarderRequest)
	mu       sync.Mutex
	inFlight map[stack.TransportEndpointID]struct{}
	listen   *listenContext
}
func NewForwarder(s *stack.Stack, rcvWnd, maxInFlight int, handler func(*ForwarderRequest)) *Forwarder {
	if rcvWnd == 0 {
		rcvWnd = DefaultBufferSize
	}
	return &Forwarder{
		maxInFlight: maxInFlight,
		handler:     handler,
		inFlight:    make(map[stack.TransportEndpointID]struct{}),
		listen:      newListenContext(s, seqnum.Size(rcvWnd), true, 0),
	}
}
func (f *Forwarder) HandlePacket(r *stack.Route, id stack.TransportEndpointID, vv buffer.VectorisedView) bool {
	s := newSegment(r, id, vv)
	defer s.decRef()
	if !s.parse() || s.flags != flagSyn {
		return false
	}
	opts := parseSynSegmentOptions(s)
	f.mu.Lock()
	defer f.mu.Unlock()
	if _, ok := f.inFlight[id]; ok {
		return true
	}
	if len(f.inFlight) >= f.maxInFlight {
		return true
	}
	f.inFlight[id] = struct{}{}
	s.incRef()
	go f.handler(&ForwarderRequest{
		forwarder:  f,
		segment:    s,
		synOptions: opts,
	})
	return true
}
type ForwarderRequest struct {
	mu         sync.Mutex
	forwarder  *Forwarder
	segment    *segment
	synOptions header.TCPSynOptions
}
func (r *ForwarderRequest) ID() stack.TransportEndpointID {
	return r.segment.id
}