Browse Source

Merge pull request #1726 from tendermint/1717-panic-in-netaddress

return an error if we fail to parse external IP
pull/1657/merge
Alexander Simmerl 6 years ago
committed by GitHub
parent
commit
dfc5aefd5f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions
  1. +6
    -0
      p2p/upnp/upnp.go

+ 6
- 0
p2p/upnp/upnp.go View File

@ -9,6 +9,7 @@ import (
"bytes"
"encoding/xml"
"errors"
"fmt"
"io/ioutil"
"net"
"net/http"
@ -324,12 +325,17 @@ func (n *upnpNAT) getExternalIPAddress() (info statusInfo, err error) {
return
}
// GetExternalAddress returns an external IP. If GetExternalIPAddress action
// fails or IP returned is invalid, GetExternalAddress returns an error.
func (n *upnpNAT) GetExternalAddress() (addr net.IP, err error) {
info, err := n.getExternalIPAddress()
if err != nil {
return
}
addr = net.ParseIP(info.externalIpAddress)
if addr == nil {
err = fmt.Errorf("Failed to parse IP: %v", info.externalIpAddress)
}
return
}


Loading…
Cancel
Save