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

Commit

Permalink
add Close method to interface, fix closing of StaticAutoNAT
Browse files Browse the repository at this point in the history
  • Loading branch information
marten-seemann committed Aug 29, 2021
1 parent e6e029f commit 1be3293
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions autonat.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,3 +457,8 @@ func (s *StaticAutoNAT) PublicAddr() (ma.Multiaddr, error) {
}
return nil, errors.New("no available address")
}

func (s *StaticAutoNAT) Close() error {
s.service.Disable()
return nil
}
2 changes: 2 additions & 0 deletions interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package autonat

import (
"context"
"io"

"github.com/libp2p/go-libp2p-core/network"
"github.com/libp2p/go-libp2p-core/peer"
Expand All @@ -16,6 +17,7 @@ type AutoNAT interface {
// PublicAddr returns the public dial address when NAT status is public and an
// error otherwise
PublicAddr() (ma.Multiaddr, error)
io.Closer
}

// Client is a stateless client interface to AutoNAT peers
Expand Down

0 comments on commit 1be3293

Please sign in to comment.