本文整理汇总了C++中QTcpSocket::proxy方法的典型用法代码示例。如果您正苦于以下问题:C++ QTcpSocket::proxy方法的具体用法?C++ QTcpSocket::proxy怎么用?C++ QTcpSocket::proxy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTcpSocket
的用法示例。
在下文中一共展示了QTcpSocket::proxy方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TcpCreateProxy
void ExitTunnel::TcpCreateProxy(QSharedPointer<Packet> packet)
{
TcpStartPacket *sp = dynamic_cast<TcpStartPacket*>(packet.data());
if(!sp) return;
QTcpSocket* socket = new QTcpSocket(this);
socket->setProxy(_exit_proxy);
// Check the verification key
if(!_table.SaveConnection(socket, sp->GetConnectionId(), sp->GetVerificationKey())) return;
_tcp_buffers[socket] = QByteArray();
connect(socket, SIGNAL(readyRead()), this, SLOT(TcpReadFromProxy()));
connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this,
SLOT(TcpProxyStateChanged(QAbstractSocket::SocketState)));
connect(socket, SIGNAL(disconnected()), this, SLOT(DiscardProxy()));
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this,
SLOT(HandleError(QAbstractSocket::SocketError)));
qDebug() << "SOCKS Creating connection" << sp->GetConnectionId();
bool proxy_does_lookups = (socket->proxy().capabilities() & QNetworkProxy::HostNameLookupCapability);
qDebug() << "Direct" << proxy_does_lookups;
if(sp->GetHostName().IsHostName()) {
if(proxy_does_lookups) {
// Connect directly to hostname
qDebug() << "SOCKS ConnectToHost Direct" << sp->GetHostName().GetName() << ":"
<< sp->GetHostName().GetPort() << (sp->GetHostName().IsHostName() ? "DNS" : "Address");
socket->connectToHost(sp->GetHostName().GetName(), sp->GetHostName().GetPort());
} else {
// Resolve hostname, then connect to IP address
qDebug() << "SOCKS Hostname" << sp->GetHostName().GetName();
int lookup_id = QHostInfo::lookupHost(sp->GetHostName().GetName(),
this, SLOT(TcpDnsLookupFinished(const QHostInfo &)));
TcpPendingDnsData dns_data = {socket, sp->GetHostName().GetPort()};
_tcp_pending_dns[lookup_id] = dns_data;
}
} else {