-
Notifications
You must be signed in to change notification settings - Fork 237
Provides SRV support for connecting to directories from client or server #3556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
af7fa97
5ba919d
0fa4fe6
8a50dc4
044bccc
951b41d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -318,13 +318,13 @@ void CConnectDlg::RequestServerList() | |
| } | ||
| cbxDirectory->blockSignals ( false ); | ||
|
|
||
| // Get the IP address of the directory server (using the ParseNetworAddress | ||
| // Get the IP address of the directory server (using the ParseNetworkAddress | ||
| // function) when the connect dialog is opened, this seems to be the correct | ||
| // time to do it. Note that in case of custom directories we | ||
| // use iCustomDirectoryIndex as an index into the vector. | ||
|
|
||
| // Allow IPv4 only for communicating with Directories | ||
| if ( NetworkUtil().ParseNetworkAddress ( | ||
| if ( NetworkUtil::ParseNetworkAddress ( | ||
| NetworkUtil::GetDirectoryAddress ( pSettings->eDirectoryType, pSettings->vstrDirectoryAddress[pSettings->iCustomDirectoryIndex] ), | ||
| haDirectoryAddress, | ||
| false ) ) | ||
|
|
@@ -856,7 +856,8 @@ void CConnectDlg::OnTimerPing() | |
|
|
||
| // try to parse host address string which is stored as user data | ||
| // in the server list item GUI control element | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As per |
||
| if ( NetworkUtil().ParseNetworkAddress ( pCurListViewItem->data ( LVC_NAME, Qt::UserRole ).toString(), haServerAddress, bEnableIPv6 ) ) | ||
| // the data to be parsed is just IP:port, so no SRV discovery is needed | ||
| if ( NetworkUtil::ParseNetworkAddressBare ( pCurListViewItem->data ( LVC_NAME, Qt::UserRole ).toString(), haServerAddress, bEnableIPv6 ) ) | ||
| { | ||
| // if address is valid, send ping message using a new thread | ||
| #if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -482,12 +482,12 @@ CServerDlg::CServerDlg ( CServer* pNServP, CServerSettings* pNSetP, const bool b | |
| // Send the request to two servers for redundancy if either or both of them | ||
| // has a higher release version number, the reply will trigger the notification. | ||
|
|
||
| if ( NetworkUtil().ParseNetworkAddress ( UPDATECHECK1_ADDRESS, UpdateServerHostAddress, pServer->IsIPv6Enabled() ) ) | ||
| if ( NetworkUtil::ParseNetworkAddress ( UPDATECHECK1_ADDRESS, UpdateServerHostAddress, pServer->IsIPv6Enabled() ) ) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As client. |
||
| { | ||
| pServer->CreateCLServerListReqVerAndOSMes ( UpdateServerHostAddress ); | ||
| } | ||
|
|
||
| if ( NetworkUtil().ParseNetworkAddress ( UPDATECHECK2_ADDRESS, UpdateServerHostAddress, pServer->IsIPv6Enabled() ) ) | ||
| if ( NetworkUtil::ParseNetworkAddress ( UPDATECHECK2_ADDRESS, UpdateServerHostAddress, pServer->IsIPv6Enabled() ) ) | ||
| { | ||
| pServer->CreateCLServerListReqVerAndOSMes ( UpdateServerHostAddress ); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -805,7 +805,9 @@ bool CServerListManager::Load() | |
| continue; | ||
| } | ||
|
|
||
| NetworkUtil::ParseNetworkAddress ( slLine[0], haServerHostAddr, bEnableIPv6 ); | ||
| // This uses ParseNetworkAddressBare because it is just parsing ip:host that was saved to the file. | ||
| // Therefore no SRV lookup is appropriate. | ||
| NetworkUtil::ParseNetworkAddressBare ( slLine[0], haServerHostAddr, bEnableIPv6 ); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs a comment explaining why
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it stores the registered string, not the resolved string, to allow for dynamic DNS. (Same with the server list returned from the Directory to the Client -- it's unresolved entries.) |
||
| int iIdx = IndexOf ( haServerHostAddr ); | ||
| if ( iIdx != INVALID_INDEX ) | ||
| { | ||
|
|
@@ -969,13 +971,23 @@ void CServerListManager::SetRegistered ( const bool bIsRegister ) | |
| return; | ||
| } | ||
|
|
||
| // It is very important to unlock the Mutex before doing address resolution, | ||
| // so that the event loop can run and any other timers that need the mutex | ||
| // can obtain it. Otherwise there is the possibility of deadlock when doing | ||
| // the SRV lookup, if another timer fires that needs the same mutex. | ||
| locker.unlock(); | ||
ann0see marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| // get the correct directory address | ||
| // Note that we always have to parse the server address again since if | ||
| // it is an URL of a dynamic IP address, the IP address might have | ||
| // changed in the meanwhile. | ||
| // Allow IPv4 only for communicating with Directories | ||
| // Use SRV DNS discovery for directory connections, fallback to A/AAAA if none. | ||
| const QString strNetworkAddress = NetworkUtil::GetDirectoryAddress ( DirectoryType, strDirectoryAddress ); | ||
| const bool bDirectoryAddressValid = NetworkUtil().ParseNetworkAddress ( strNetworkAddress, DirectoryAddress, false ); | ||
| const bool bDirectoryAddressValid = NetworkUtil::ParseNetworkAddress ( strNetworkAddress, DirectoryAddress, false ); | ||
|
|
||
| // lock the mutex again now that the address has been resolved. | ||
| locker.relock(); | ||
|
|
||
| if ( bIsRegister ) | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment in
global.h-- I think these should go through...Bare(for safety).