mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-28 13:02:38 +02:00
Qt: Ask user to use standard port on startup if specified port is in use
If the port (specified by -port or GUI setting) is already in use when starting the GUI client, and it's not the standard port, ask the user if they want to listen via the standard network port instead. Github-Pull: #7107 Rebased-From: 1f37c87d8f2fbb7113c38674d1cc65933a222ccb
This commit is contained in:
parent
1684b30abe
commit
f29a7dd518
24
src/net.cpp
24
src/net.cpp
@ -3224,7 +3224,29 @@ bool CConnman::InitBinds(const Options& options)
|
||||
inaddr_any.s_addr = htonl(INADDR_ANY);
|
||||
const CService ipv4_any{inaddr_any, GetListenPort()}; // 0.0.0.0
|
||||
if (!Bind(ipv4_any, BF_REPORT_ERROR, NetPermissionFlags::None)) {
|
||||
return false;
|
||||
int defaultPort = Params().GetDefaultPort();
|
||||
// If listening failed and another port than the standard port was specified,
|
||||
// ask if the user wants to connect via the standard port for the network instead
|
||||
if (GetListenPort() != defaultPort) {
|
||||
bool fRet = uiInterface.ThreadSafeQuestion(
|
||||
strprintf(_("Do you want to use the standard network port for %s (port %s) instead?"), PACKAGE_NAME, defaultPort),
|
||||
strprintf(_("Listen on port %s failed.").translated, GetListenPort()),
|
||||
"", CClientUIInterface::MSG_INFORMATION | CClientUIInterface::MODAL | CClientUIInterface::BTN_OK | CClientUIInterface::BTN_ABORT);
|
||||
|
||||
if (fRet) {
|
||||
// FIXME: Unbind IPv6 on the other port
|
||||
|
||||
gArgs.ForceSetArg("-port", defaultPort);
|
||||
// Attempt to use standard port
|
||||
struct in6_addr inaddr6_any = IN6ADDR_ANY_INIT;
|
||||
Bind(CService(inaddr6_any, defaultPort), BF_NONE, NetPermissionFlags::None);
|
||||
struct in_addr inaddr_any;
|
||||
inaddr_any.s_addr = INADDR_ANY;
|
||||
if (!Bind(CService(inaddr_any, defaultPort), BF_REPORT_ERROR, NetPermissionFlags::None)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user