mirror of https://github.com/poanetwork/gecko.git
dropped error msg from unmapallport
This commit is contained in:
parent
210ad164f3
commit
20637a0f23
14
nat/nat.go
14
nat/nat.go
|
@ -9,7 +9,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/ava-labs/gecko/utils/logging"
|
||||
"github.com/ava-labs/gecko/utils/wrappers"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -46,8 +45,6 @@ type Mapper struct {
|
|||
r Router
|
||||
closer chan struct{}
|
||||
wg sync.WaitGroup
|
||||
errLock sync.Mutex
|
||||
errs wrappers.Errs
|
||||
}
|
||||
|
||||
func NewPortMapper(log logging.Logger, r Router) Mapper {
|
||||
|
@ -81,13 +78,9 @@ func (dev *Mapper) keepPortMapping(mappedPort chan<- uint16, protocol string,
|
|||
dev.log.Debug("Port %d is taken by %s:%d: %s, retry with the next port",
|
||||
extPort, intaddr, intPort, desc)
|
||||
continue
|
||||
}
|
||||
if err := dev.r.MapPort(protocol, intPort, extPort, desc, mapTimeout); err != nil {
|
||||
dev.log.Error("Map port failed. Protocol %s Internal %d External %d. %s",
|
||||
} else if err := dev.r.MapPort(protocol, intPort, extPort, desc, mapTimeout); err != nil {
|
||||
dev.log.Debug("Map port failed. Protocol %s Internal %d External %d. %s",
|
||||
protocol, intPort, extPort, err)
|
||||
dev.errLock.Lock()
|
||||
dev.errs.Add(err)
|
||||
dev.errLock.Unlock()
|
||||
} else {
|
||||
dev.log.Info("Mapped Protocol %s Internal %d External %d.", protocol,
|
||||
intPort, extPort)
|
||||
|
@ -128,9 +121,8 @@ func (dev *Mapper) keepPortMapping(mappedPort chan<- uint16, protocol string,
|
|||
mappedPort <- 0
|
||||
}
|
||||
|
||||
func (dev *Mapper) UnmapAllPorts() error {
|
||||
func (dev *Mapper) UnmapAllPorts() {
|
||||
close(dev.closer)
|
||||
dev.wg.Wait()
|
||||
dev.log.Info("Unmapped all ports")
|
||||
return dev.errs.Err
|
||||
}
|
||||
|
|
|
@ -39,12 +39,12 @@ func getOutboundIP() (net.IP, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer conn.Close()
|
||||
|
||||
if udpAddr, ok := conn.LocalAddr().(*net.UDPAddr); ok {
|
||||
return udpAddr.IP, conn.Close()
|
||||
}
|
||||
|
||||
conn.Close()
|
||||
return nil, fmt.Errorf("getting outbound IP failed")
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue