mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 01:20:42 +00:00
Modify "qrenderdoc --targetcontrol" command
Modify "qrenderdoc --targetcontrol" to accept hostname or ipv4 address.
This commit is contained in:
committed by
baldurk
parent
5529cb9c8d
commit
14019cf6c7
@@ -219,34 +219,45 @@ int main(int argc, char *argv[])
|
||||
|
||||
if(parser.isSet(targetcontrol))
|
||||
{
|
||||
QRegularExpression regexp(lit("^([a-zA-Z0-9_-]+:)?([0-9]+)$"));
|
||||
QRegularExpression regexp(lit("^([a-zA-Z\\.0-9_-]+)?(:([0-9]+))?$"));
|
||||
|
||||
QRegularExpressionMatch match = regexp.match(parser.value(targetcontrol));
|
||||
|
||||
if(!match.hasMatch())
|
||||
{
|
||||
qCritical() << "--targetcontrol option must be followed by host:port";
|
||||
qCritical() << "--targetcontrol option must be followed by host:port or host";
|
||||
return 1;
|
||||
}
|
||||
|
||||
QString host = match.captured(1);
|
||||
|
||||
if(host.length() > 0 && host[host.length() - 1] == QLatin1Char(':'))
|
||||
host.chop(1);
|
||||
|
||||
bool ok = false;
|
||||
uint32_t ident = match.captured(2).toUInt(&ok);
|
||||
|
||||
if(ok)
|
||||
uint32_t ident = 0;
|
||||
if(match.capturedLength(2) > 0)
|
||||
{
|
||||
remoteHost = host;
|
||||
remoteIdent = ident;
|
||||
ident = match.captured(3).toUInt(&ok);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical() << "--targetcontrol parameter" << match.captured(1) << "malformed";
|
||||
// no port specified, find the first open port.
|
||||
ident = RENDERDOC_EnumerateRemoteTargets(host.toLocal8Bit().data(), ident);
|
||||
ok = (ident != 0);
|
||||
}
|
||||
|
||||
if(!ok)
|
||||
{
|
||||
if(match.capturedLength(2) > 0)
|
||||
{
|
||||
qCritical() << "--targetcontrol port " << match.captured(3) << "malformed";
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical() << "All ports are busy, cannot find an available port";
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
remoteHost = host;
|
||||
remoteIdent = ident;
|
||||
}
|
||||
|
||||
QString crashReportPath;
|
||||
|
||||
@@ -425,7 +425,11 @@ Socket *CreateClientSocket(const char *host, uint16_t port, int timeoutMS)
|
||||
hints.ai_protocol = IPPROTO_TCP;
|
||||
|
||||
addrinfo *addrResult = NULL;
|
||||
getaddrinfo(host, portstr, &hints, &addrResult);
|
||||
int res = getaddrinfo(host, portstr, &hints, &addrResult);
|
||||
if(res != 0)
|
||||
{
|
||||
RDCDEBUG("%s", gai_strerror(res));
|
||||
}
|
||||
|
||||
for(addrinfo *ptr = addrResult; ptr != NULL; ptr = ptr->ai_next)
|
||||
{
|
||||
|
||||
@@ -66,6 +66,30 @@ static std::string wsaerr_string(int err)
|
||||
return "WSAEHOSTDOWN: A socket operation failed because the destination host was down.";
|
||||
case WSAEHOSTUNREACH:
|
||||
return "WSAETIMEDOUT: A socket operation was attempted to an unreachable host.";
|
||||
case WSATRY_AGAIN: return "WSATRY_AGAIN: A temporary failure in name resolution occurred.";
|
||||
case WSAEINVAL:
|
||||
return "WSAEINVAL: An invalid value was provided for the ai_flags member of the pHints "
|
||||
"parameter.";
|
||||
case WSANO_RECOVERY:
|
||||
return "WSANO_RECOVERY: A nonrecoverable failure in name resolution occurred.";
|
||||
case WSAEAFNOSUPPORT:
|
||||
return "WSAEAFNOSUPPORT: The ai_family member of the pHints parameter is not supported.";
|
||||
case WSA_NOT_ENOUGH_MEMORY:
|
||||
return "WSA_NOT_ENOUGH_MEMORY: A memory allocation failure occurred.";
|
||||
case WSAHOST_NOT_FOUND:
|
||||
return "WSAHOST_NOT_FOUND: The name does not resolve for the supplied parameters or the "
|
||||
"pNodeName and pServiceName parameters were not provided.";
|
||||
case WSATYPE_NOT_FOUND:
|
||||
return "WSATYPE_NOT_FOUND: The pServiceName parameter is not supported for the specified "
|
||||
"ai_socktype member of the pHints parameter.";
|
||||
case WSAESOCKTNOSUPPORT:
|
||||
return "WSAESOCKTNOSUPPORT: The ai_socktype member of the pHints parameter is not supported.";
|
||||
case WSANO_DATA:
|
||||
return "WSANO_DATA: The requested name is valid, but no data of the requested type was "
|
||||
"found.";
|
||||
case WSANOTINITIALISED:
|
||||
return "WSANOTINITIALISED: A successful WSAStartup call must occur before using this "
|
||||
"function.";
|
||||
default: break;
|
||||
}
|
||||
|
||||
@@ -386,7 +410,12 @@ Socket *CreateClientSocket(const char *host, uint16_t port, int timeoutMS)
|
||||
std::wstring whost = StringFormat::UTF82Wide(string(host));
|
||||
|
||||
addrinfoW *addrResult = NULL;
|
||||
GetAddrInfoW(whost.c_str(), portwstr, &hints, &addrResult);
|
||||
int res = GetAddrInfoW(whost.c_str(), portwstr, &hints, &addrResult);
|
||||
if(res != 0)
|
||||
{
|
||||
RDCDEBUG("%s", wsaerr_string(res).c_str());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for(addrinfoW *ptr = addrResult; ptr != NULL; ptr = ptr->ai_next)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user