udpnat: Fix read deadline not initialized

This commit is contained in:
世界 2024-08-19 17:56:31 +08:00
parent afd8993773
commit 26511a251f
No known key found for this signature in database
GPG key ID: CD109927C34A63C4

View file

@ -70,9 +70,10 @@ func (s *Service[T]) NewPacket(ctx context.Context, key T, buffer *buf.Buffer, m
func (s *Service[T]) NewContextPacket(ctx context.Context, key T, buffer *buf.Buffer, metadata M.Metadata, init func(natConn N.PacketConn) (context.Context, N.PacketWriter)) {
c, loaded := s.nat.LoadOrStore(key, func() *conn {
c := &conn{
data: make(chan packet, 64),
localAddr: metadata.Source,
remoteAddr: metadata.Destination,
data: make(chan packet, 64),
localAddr: metadata.Source,
remoteAddr: metadata.Destination,
readDeadline: pipe.MakeDeadline(),
}
c.ctx, c.cancel = common.ContextWithCancelCause(ctx)
return c