diff options
author | Cory Fields <cory-nospam-@coryfields.com> | 2016-08-04 16:37:49 -0400 |
---|---|---|
committer | Cory Fields <cory-nospam-@coryfields.com> | 2016-08-04 16:41:39 -0400 |
commit | 8945384bca00f74ba85c98a52925c254c49025a5 (patch) | |
tree | c5479d77e5feb28ed75b53715073bcf3b46c1ffe /src/netbase.cpp | |
parent | 21ba407a7369a0229b8a8554dee0da63a64e6639 (diff) |
net: Have LookupNumeric return a CService directly
Also fix up a few small issues:
- Lookup with "badip:port" now sets the port to 0
- Don't allow assert to have side-effects
Diffstat (limited to 'src/netbase.cpp')
-rw-r--r-- | src/netbase.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/netbase.cpp b/src/netbase.cpp index c2294a078d..4f243ec6f5 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -231,9 +231,14 @@ bool Lookup(const char *pszName, CService& addr, int portDefault, bool fAllowLoo return true; } -bool LookupNumeric(const char *pszName, CService& addr, int portDefault) +CService LookupNumeric(const char *pszName, int portDefault) { - return Lookup(pszName, addr, portDefault, false); + CService addr; + // "1.2:345" will fail to resolve the ip, but will still set the port. + // If the ip fails to resolve, re-init the result. + if(!Lookup(pszName, addr, portDefault, false)) + addr = CService(); + return addr; } struct timeval MillisToTimeval(int64_t nTimeout) |