Skip to content

Commit 5a3cb32

Browse files
committed
Take -port into account when resolving -bind's
1 parent 139d2f7 commit 5a3cb32

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

src/init.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -611,14 +611,14 @@ bool AppInit2(int argc, char* argv[])
611611
std::string strError;
612612
if (mapArgs.count("-bind")) {
613613
BOOST_FOREACH(std::string strBind, mapMultiArgs["-bind"]) {
614-
fBound |= Bind(CService(strBind, GetDefaultPort(), false));
614+
fBound |= Bind(CService(strBind, GetListenPort(), false));
615615
}
616616
} else {
617617
struct in_addr inaddr_any;
618618
inaddr_any.s_addr = INADDR_ANY;
619-
fBound |= Bind(CService(inaddr_any, GetDefaultPort()));
619+
fBound |= Bind(CService(inaddr_any, GetListenPort()));
620620
#ifdef USE_IPV6
621-
fBound |= Bind(CService(in6addr_any, GetDefaultPort()));
621+
fBound |= Bind(CService(in6addr_any, GetListenPort()));
622622
#endif
623623
}
624624
if (!fBound)
@@ -628,7 +628,7 @@ bool AppInit2(int argc, char* argv[])
628628
if (mapArgs.count("-externalip"))
629629
{
630630
BOOST_FOREACH(string strAddr, mapMultiArgs["-externalip"])
631-
AddLocal(CNetAddr(strAddr, fNameLookup), LOCAL_MANUAL);
631+
AddLocal(CService(strAddr, GetListenPort(), fNameLookup), LOCAL_MANUAL);
632632
}
633633

634634
if (mapArgs.count("-paytxfee"))

src/net.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,9 @@ bool AddLocal(const CService& addr, int nScore)
231231
return true;
232232
}
233233

234-
bool AddLocal(const CNetAddr& addr, int nScore, int port)
234+
bool AddLocal(const CNetAddr &addr, int nScore)
235235
{
236-
if (port == -1)
237-
port = GetListenPort();
238-
return AddLocal(CService(addr, port), nScore);
236+
return AddLocal(CService(addr, GetListenPort()), nScore);
239237
}
240238

241239
/** Make a particular network entirely off-limits (no automatic connects to it) */

src/net.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ CNode* FindNode(const CNetAddr& ip);
3838
CNode* FindNode(const CService& ip);
3939
CNode* ConnectNode(CAddress addrConnect, const char *strDest = NULL, int64 nTimeout=0);
4040
void MapPort(bool fMapPort);
41+
unsigned short GetListenPort();
4142
bool BindListenPort(const CService &bindAddr, std::string& strError=REF(std::string()));
4243
void StartNode(void* parg);
4344
bool StopNode();
@@ -58,7 +59,7 @@ enum
5859
void SetLimited(enum Network net, bool fLimited = true);
5960
bool IsLimited(const CNetAddr& addr);
6061
bool AddLocal(const CService& addr, int nScore = LOCAL_NONE);
61-
bool AddLocal(const CNetAddr& addr, int nScore = LOCAL_NONE, int port = -1);
62+
bool AddLocal(const CNetAddr& addr, int nScore = LOCAL_NONE);
6263
bool SeenLocal(const CService& addr);
6364
bool IsLocal(const CService& addr);
6465
bool GetLocal(CService &addr, const CNetAddr *paddrPeer = NULL);

0 commit comments

Comments
 (0)