Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
fix: stream read timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
aarshkshah1992 committed Dec 17, 2020
1 parent 703926f commit e4c7f4c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
manet "github.com/multiformats/go-multiaddr/net"
)

var streamReadTimeout = 60 * time.Second

// AutoNATService provides NAT autodetection services to other peers
type autoNATService struct {
ctx context.Context
Expand Down Expand Up @@ -50,6 +52,8 @@ func newAutoNATService(ctx context.Context, c *config) (*autoNATService, error)
}

func (as *autoNATService) handleStream(s network.Stream) {
s.SetReadDeadline(time.Now().Add(streamReadTimeout))

defer s.Close()

pid := s.Conn().RemotePeer()
Expand Down

0 comments on commit e4c7f4c

Please sign in to comment.