mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 18:22:55 +02:00
Merge pull request #13014 from druiz17/fix-localhost-port
hide default port from addresses, fix localhost scheme
This commit is contained in:
commit
ed39b4f63e
2 changed files with 15 additions and 10 deletions
|
@ -333,12 +333,14 @@ bool AddressManager::handleUrl(const QUrl& lookupUrl, LookupTrigger trigger) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const QString LOCALHOST = "localhost";
|
||||||
|
|
||||||
bool isPossiblePlaceName(QString possiblePlaceName) {
|
bool isPossiblePlaceName(QString possiblePlaceName) {
|
||||||
bool result { false };
|
bool result { false };
|
||||||
int length = possiblePlaceName.length();
|
int length = possiblePlaceName.length();
|
||||||
static const int MINIMUM_PLACENAME_LENGTH = 1;
|
static const int MINIMUM_PLACENAME_LENGTH = 1;
|
||||||
static const int MAXIMUM_PLACENAME_LENGTH = 64;
|
static const int MAXIMUM_PLACENAME_LENGTH = 64;
|
||||||
if (possiblePlaceName.toLower() != "localhost" &&
|
if (possiblePlaceName.toLower() != LOCALHOST &&
|
||||||
length >= MINIMUM_PLACENAME_LENGTH && length <= MAXIMUM_PLACENAME_LENGTH) {
|
length >= MINIMUM_PLACENAME_LENGTH && length <= MAXIMUM_PLACENAME_LENGTH) {
|
||||||
const QRegExp PLACE_NAME_REGEX = QRegExp("^[0-9A-Za-z](([0-9A-Za-z]|-(?!-))*[^\\W_]$|$)");
|
const QRegExp PLACE_NAME_REGEX = QRegExp("^[0-9A-Za-z](([0-9A-Za-z]|-(?!-))*[^\\W_]$|$)");
|
||||||
result = PLACE_NAME_REGEX.indexIn(possiblePlaceName) == 0;
|
result = PLACE_NAME_REGEX.indexIn(possiblePlaceName) == 0;
|
||||||
|
@ -358,7 +360,7 @@ void AddressManager::handleLookupString(const QString& lookupString, bool fromSu
|
||||||
sanitizedString = sanitizedString.remove(HIFI_SCHEME_REGEX);
|
sanitizedString = sanitizedString.remove(HIFI_SCHEME_REGEX);
|
||||||
|
|
||||||
lookupURL = QUrl(sanitizedString);
|
lookupURL = QUrl(sanitizedString);
|
||||||
if (lookupURL.scheme().isEmpty()) {
|
if (lookupURL.scheme().isEmpty() || lookupURL.scheme().toLower() == LOCALHOST) {
|
||||||
lookupURL = QUrl("hifi://" + sanitizedString);
|
lookupURL = QUrl("hifi://" + sanitizedString);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -607,7 +609,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString, LookupTri
|
||||||
if (ipAddressRegex.indexIn(lookupString) != -1) {
|
if (ipAddressRegex.indexIn(lookupString) != -1) {
|
||||||
QString domainIPString = ipAddressRegex.cap(1);
|
QString domainIPString = ipAddressRegex.cap(1);
|
||||||
|
|
||||||
quint16 domainPort = DEFAULT_DOMAIN_SERVER_PORT;
|
quint16 domainPort = 0;
|
||||||
if (!ipAddressRegex.cap(2).isEmpty()) {
|
if (!ipAddressRegex.cap(2).isEmpty()) {
|
||||||
domainPort = (quint16) ipAddressRegex.cap(2).toInt();
|
domainPort = (quint16) ipAddressRegex.cap(2).toInt();
|
||||||
}
|
}
|
||||||
|
@ -629,7 +631,7 @@ bool AddressManager::handleNetworkAddress(const QString& lookupString, LookupTri
|
||||||
if (hostnameRegex.indexIn(lookupString) != -1) {
|
if (hostnameRegex.indexIn(lookupString) != -1) {
|
||||||
QString domainHostname = hostnameRegex.cap(1);
|
QString domainHostname = hostnameRegex.cap(1);
|
||||||
|
|
||||||
quint16 domainPort = DEFAULT_DOMAIN_SERVER_PORT;
|
quint16 domainPort = 0;
|
||||||
|
|
||||||
if (!hostnameRegex.cap(2).isEmpty()) {
|
if (!hostnameRegex.cap(2).isEmpty()) {
|
||||||
domainPort = (quint16)hostnameRegex.cap(2).toInt();
|
domainPort = (quint16)hostnameRegex.cap(2).toInt();
|
||||||
|
|
|
@ -166,7 +166,12 @@ void DomainHandler::setURLAndID(QUrl domainURL, QUuid domainID) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_domainURL != domainURL || _sockAddr.getPort() != domainURL.port()) {
|
auto domainPort = domainURL.port();
|
||||||
|
if (domainPort == -1) {
|
||||||
|
domainPort = DEFAULT_DOMAIN_SERVER_PORT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_domainURL != domainURL || _sockAddr.getPort() != domainPort) {
|
||||||
// re-set the domain info so that auth information is reloaded
|
// re-set the domain info so that auth information is reloaded
|
||||||
hardReset();
|
hardReset();
|
||||||
|
|
||||||
|
@ -192,12 +197,10 @@ void DomainHandler::setURLAndID(QUrl domainURL, QUuid domainID) {
|
||||||
|
|
||||||
emit domainURLChanged(_domainURL);
|
emit domainURLChanged(_domainURL);
|
||||||
|
|
||||||
if (_sockAddr.getPort() != domainURL.port()) {
|
if (_sockAddr.getPort() != domainPort) {
|
||||||
qCDebug(networking) << "Updated domain port to" << domainURL.port();
|
qCDebug(networking) << "Updated domain port to" << domainPort;
|
||||||
|
_sockAddr.setPort(domainPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
// grab the port by reading the string after the colon
|
|
||||||
_sockAddr.setPort(domainURL.port());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue