Skip to content

Commit

Permalink
protocol/reuse.go: Redo UPnP before Dialing
Browse files Browse the repository at this point in the history
  • Loading branch information
hzyitc committed May 25, 2021
1 parent 00be6f7 commit f9b3b38
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions TCPMode/reuse.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ func NewReuse(rpfc routerPortForward.Config, port int) (Interface, error) {
}

func (s *reuse) Dial(addr string) (net.Conn, error) {
s.rpf.Redo()

if s.conn != nil {
return nil, errors.New("double dial")
}
Expand Down
7 changes: 7 additions & 0 deletions routerPortForward/upnp.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type Config struct {
}

type Interface interface {
Redo()
Close()
}

Expand Down Expand Up @@ -44,6 +45,12 @@ func New(config Config, port int) (Interface, error) {
}, nil
}

func (s *upnpImpl) Redo() {
if s.config.Enable {
s.d.Forward(s.port, "mnh")
}
}

func (s *upnpImpl) Close() {
if s.config.Enable {
s.d.Clear(s.port)
Expand Down

0 comments on commit f9b3b38

Please sign in to comment.