QList<QNetworkProxy> PackageManagerProxyFactory::queryProxy(const QNetworkProxyQuery &query) { const Settings &settings = m_core->settings(); QList<QNetworkProxy> list; if (settings.proxyType() == Settings::SystemProxy) { #if defined(Q_OS_UNIX) && !defined(Q_OS_OSX) QUrl proxyUrl = QUrl::fromUserInput(QString::fromUtf8(qgetenv("http_proxy"))); if (proxyUrl.isValid()) { return list << QNetworkProxy(QNetworkProxy::HttpProxy, proxyUrl.host(), proxyUrl.port(), proxyUrl.userName(), proxyUrl.password()); } #endif return QNetworkProxyFactory::systemProxyForQuery(query); } if ((settings.proxyType() == Settings::NoProxy)) return list << QNetworkProxy(QNetworkProxy::NoProxy); if (query.queryType() == QNetworkProxyQuery::UrlRequest) { if (query.url().scheme() == QLatin1String("ftp")) return list << settings.ftpProxy(); if ((query.url().scheme() == QLatin1String("http")) || (query.url().scheme() == QLatin1String("https"))) { return list << settings.httpProxy(); } } return list << QNetworkProxy(QNetworkProxy::DefaultProxy); }
virtual QList<QNetworkProxy> queryProxy(const QNetworkProxyQuery& query = QNetworkProxyQuery()) { if ((query.peerHostName().compare("localhost", Qt::CaseInsensitive) == 0) || (query.peerHostName().compare("127.0.0.1") == 0)) { return *_defaultProxyList; } else if (_useProxy) { return *_proxyList; } else { return QNetworkProxyFactory::systemProxyForQuery(query); } }
QList< QNetworkProxy > NetworkProxyFactory::queryProxy( const QNetworkProxyQuery& query ) { tDebug() << Q_FUNC_INFO << "query.peerHostName() = " << query.peerHostName() << ", m_noProxyHosts = " << m_noProxyHosts; QList< QNetworkProxy > proxies; QString hostname = query.peerHostName(); if ( m_proxy.hostName().isEmpty() || hostname.isEmpty() || m_noProxyHosts.contains( hostname ) || TomahawkSettings::instance()->proxyType() == QNetworkProxy::NoProxy ) proxies << QNetworkProxy( QNetworkProxy::DefaultProxy ) << QNetworkProxy( QNetworkProxy::NoProxy ); else proxies << m_proxy << QNetworkProxy( QNetworkProxy::DefaultProxy ) << QNetworkProxy( QNetworkProxy::NoProxy ); tDebug() << Q_FUNC_INFO << " proxies size = " << proxies.size(); return proxies; }
QList<QNetworkProxy> EnvHttpProxyFactory::queryProxy(const QNetworkProxyQuery& query) { QString protocol = query.protocolTag().toLower(); bool localHost = false; if (!query.peerHostName().compare(QLatin1String("localhost"), Qt::CaseInsensitive) || !query.peerHostName().compare(QLatin1String("127.0.0.1"), Qt::CaseInsensitive)) localHost = true; if (protocol == QLatin1String("http") && !localHost) return m_httpProxy; if (protocol == QLatin1String("https") && !localHost) return m_httpsProxy; QList<QNetworkProxy> proxies; proxies << QNetworkProxy::NoProxy; return proxies; }
QList<QNetworkProxy> NetworkProxyFactory::queryProxy(const QNetworkProxyQuery& query) { QList<QNetworkProxy> results; if (query.peerHostName() == QString::fromAscii("127.0.0.1") || query.peerHostName().toLower() == QString::fromAscii("localhost")) { results.append(QNetworkProxy::NoProxy); } else { results = systemProxyForQuery(query); } return results; }
QList<QNetworkProxy> PackageManagerProxyFactory::queryProxy(const QNetworkProxyQuery &query) { const Settings &settings = m_core->settings(); QList<QNetworkProxy> list; if (settings.proxyType() == Settings::SystemProxy) { QList<QNetworkProxy> systemProxies = systemProxyForQuery(query); auto proxyIter = systemProxies.begin(); for (; proxyIter != systemProxies.end(); ++proxyIter) { QNetworkProxy &proxy = *proxyIter; auto p = std::find_if(m_proxyCredentials.constBegin(), m_proxyCredentials.constEnd(), FindProxyCredential(proxy.hostName(), proxy.port())); if (p != m_proxyCredentials.constEnd()) { proxy.setUser(p->user); proxy.setPassword(p->password); } } return systemProxies; } if ((settings.proxyType() == Settings::NoProxy)) return list << QNetworkProxy(QNetworkProxy::NoProxy); if (query.queryType() == QNetworkProxyQuery::UrlRequest) { QNetworkProxy proxy; if (query.url().scheme() == QLatin1String("ftp")) { proxy = settings.ftpProxy(); } else if (query.url().scheme() == QLatin1String("http") || query.url().scheme() == QLatin1String("https")) { proxy = settings.httpProxy(); } auto p = std::find_if(m_proxyCredentials.constBegin(), m_proxyCredentials.constEnd(), FindProxyCredential(proxy.hostName(), proxy.port())); if (p != m_proxyCredentials.constEnd()) { proxy.setUser(p->user); proxy.setPassword(p->password); } return list << proxy; } return list << QNetworkProxy(QNetworkProxy::DefaultProxy); }
static QList<QNetworkProxy> parseServerList(const QNetworkProxyQuery &query, const QStringList &proxyList) { // Reference documentation from Microsoft: // http://msdn.microsoft.com/en-us/library/aa383912(VS.85).aspx // // According to the website, the proxy server list is // one or more of the space- or semicolon-separated strings in the format: // ([<scheme>=][<scheme>"://"]<server>[":"<port>]) QList<QNetworkProxy> result; foreach (const QString &entry, proxyList) { int server = 0; int pos = entry.indexOf(QLatin1Char('=')); if (pos != -1) { QStringRef scheme = entry.leftRef(pos); if (scheme != query.protocolTag()) continue; server = pos + 1; } QNetworkProxy::ProxyType proxyType = QNetworkProxy::HttpProxy; quint16 port = 8080; pos = entry.indexOf(QLatin1String("://"), server); if (pos != -1) { QStringRef scheme = entry.midRef(server, pos - server); if (scheme == QLatin1String("http") || scheme == QLatin1String("https")) { // no-op // defaults are above } else if (scheme == QLatin1String("socks") || scheme == QLatin1String("socks5")) { proxyType = QNetworkProxy::Socks5Proxy; port = 1080; } else { // unknown proxy type continue; } server = pos + 3; } pos = entry.indexOf(QLatin1Char(':'), server); if (pos != -1) { bool ok; uint value = entry.mid(pos + 1).toUInt(&ok); if (!ok || value > 65535) continue; // invalid port number port = value; } else { pos = entry.length(); } result << QNetworkProxy(proxyType, entry.mid(server, pos - server), port); }
QList<QNetworkProxy> NetworkProxyFactory::queryProxy(const QNetworkProxyQuery &query) { QList<QNetworkProxy> ret; if (query.protocolTag() == QLatin1String("http") && m_httpProxy.type() != QNetworkProxy::DefaultProxy) ret << m_httpProxy; ret << m_globalProxy; return ret; }
QList< QNetworkProxy > NetworkProxyFactory::queryProxy( const QNetworkProxyQuery& query ) { QList< QNetworkProxy > proxies; QString hostname = query.peerHostName(); if ( m_proxy.hostName().isEmpty() || hostname.isEmpty() || m_noProxyHosts.contains( hostname ) || TomahawkSettings::instance()->proxyType() == QNetworkProxy::NoProxy ) proxies << systemProxyForQuery( query ); else proxies << m_proxy << systemProxyForQuery( query ); return proxies; }
QList<QNetworkProxy> NetworkProxyFactory::queryProxy(const QNetworkProxyQuery &query) { if (m_proxyMode == SystemProxy) { return QNetworkProxyFactory::systemProxyForQuery(query); } if (m_proxyMode == ManualProxy) { const QString protocol = query.protocolTag().toLower(); if (m_proxies.contains(QNetworkProxy::Socks5Proxy)) { return m_proxies[QNetworkProxy::Socks5Proxy]; } else if (protocol == QLatin1String("http") && m_proxies.contains(QNetworkProxy::HttpProxy)) { return m_proxies[QNetworkProxy::HttpProxy]; } else if (protocol == QLatin1String("https") && m_proxies.contains(QNetworkProxy::HttpCachingProxy)) { return m_proxies[QNetworkProxy::HttpCachingProxy]; } else if (protocol == QLatin1String("ftp") && m_proxies.contains(QNetworkProxy::FtpCachingProxy)) { return m_proxies[QNetworkProxy::FtpCachingProxy]; } else { return m_proxies[QNetworkProxy::NoProxy]; } } if (m_proxyMode == AutomaticProxy && m_automaticProxy) { return m_automaticProxy->getProxy(query.url().toString(), query.peerHostName()); } return m_proxies[QNetworkProxy::NoProxy]; }
QList< QNetworkProxy > NetworkProxyFactory::queryProxy( const QNetworkProxyQuery& query ) { //tDebug() << Q_FUNC_INFO << "query hostname is " << query.peerHostName(); QList< QNetworkProxy > proxies; QString hostname = query.peerHostName(); s_noProxyHostsMutex.lock(); if ( s_noProxyHosts.contains( hostname ) ) proxies << QNetworkProxy::NoProxy << systemProxyForQuery( query ); else if ( m_proxy.hostName().isEmpty() || hostname.isEmpty() || TomahawkSettings::instance()->proxyType() == QNetworkProxy::NoProxy ) proxies << systemProxyForQuery( query ); else proxies << m_proxy << systemProxyForQuery( query ); s_noProxyHostsMutex.unlock(); return proxies; }
QList<QNetworkProxy> QGlobalNetworkProxy::proxyForQuery(const QNetworkProxyQuery &query) { QMutexLocker locker(&mutex); QList<QNetworkProxy> result; // don't look for proxies for a local connection QHostAddress parsed; QString hostname = query.url().host(); if (hostname == QLatin1String("localhost") || hostname.startsWith(QLatin1String("localhost.")) || (parsed.setAddress(hostname) && (parsed == QHostAddress::LocalHost || parsed == QHostAddress::LocalHostIPv6))) { result << QNetworkProxy(QNetworkProxy::NoProxy); return result; } if (!applicationLevelProxyFactory) { if (applicationLevelProxy && applicationLevelProxy->type() != QNetworkProxy::DefaultProxy) result << *applicationLevelProxy; else result << QNetworkProxy(QNetworkProxy::NoProxy); return result; } // we have a factory result = applicationLevelProxyFactory->queryProxy(query); if (result.isEmpty()) { qWarning("QNetworkProxyFactory: factory %p has returned an empty result set", applicationLevelProxyFactory); result << QNetworkProxy(QNetworkProxy::NoProxy); } return result; }
QT_BEGIN_NAMESPACE QList<QNetworkProxy> QNetworkProxyFactory::systemProxyForQuery(const QNetworkProxyQuery &query) { QNetworkProxy proxy; if (query.queryType() != QNetworkProxyQuery::UrlRequest) { qWarning("Unsupported query type: %d", query.queryType()); return QList<QNetworkProxy>() << QNetworkProxy(QNetworkProxy::NoProxy); } QUrl url = query.url(); if (!url.isValid()) { qWarning("Invalid URL: %s", qPrintable(url.toString())); return QList<QNetworkProxy>() << QNetworkProxy(QNetworkProxy::NoProxy); } netstatus_proxy_details_t details; memset(&details, 0, sizeof(netstatus_proxy_details_t)); #if BPS_VERSION >= 3001001 QByteArray bUrl(url.toEncoded()); QString sInterface(query.networkConfiguration().name()); QByteArray bInterface; if (!sInterface.isEmpty()) { if (query.networkConfiguration().type() != QNetworkConfiguration::InternetAccessPoint) { qWarning("Unsupported configuration type: %d", query.networkConfiguration().type()); return QList<QNetworkProxy>() << QNetworkProxy(QNetworkProxy::NoProxy); } bInterface = sInterface.toUtf8(); } if (netstatus_get_proxy_details_for_url(bUrl.constData(), (bInterface.isEmpty() ? NULL : bInterface.constData()), &details) != BPS_SUCCESS) { qWarning("netstatus_get_proxy_details_for_url failed! errno: %d", errno); return QList<QNetworkProxy>() << QNetworkProxy(QNetworkProxy::NoProxy); } #else if (netstatus_get_proxy_details(&details) != BPS_SUCCESS) { qWarning("netstatus_get_proxy_details failed! errno: %d", errno); return QList<QNetworkProxy>() << QNetworkProxy(QNetworkProxy::NoProxy); } #endif if (details.http_proxy_host == NULL) { // No proxy netstatus_free_proxy_details(&details); return QList<QNetworkProxy>() << QNetworkProxy(QNetworkProxy::NoProxy); } QString protocol = query.protocolTag(); if (protocol.startsWith(QLatin1String("http"), Qt::CaseInsensitive)) { // http, https proxy.setType((QNetworkProxy::HttpProxy)); } else if (protocol == QLatin1String("ftp")) { proxy.setType(QNetworkProxy::FtpCachingProxy); } else { // assume http proxy qDebug("Proxy type: %s assumed to be http proxy", qPrintable(protocol)); proxy.setType((QNetworkProxy::HttpProxy)); } // Set host // Note: ftp and https proxy type fields *are* obsolete. // The user interface allows only one host/port which gets duplicated // to all proxy type fields. proxy.setHostName(QString::fromUtf8(details.http_proxy_host)); // Set port proxy.setPort(details.http_proxy_port); // Set username if (details.http_proxy_login_user) proxy.setUser(QString::fromUtf8(details.http_proxy_login_user)); // Set password if (details.http_proxy_login_password) proxy.setPassword(QString::fromUtf8(details.http_proxy_login_password)); netstatus_free_proxy_details(&details); return QList<QNetworkProxy>() << proxy; }
QList<QNetworkProxy> NetworkProxyFactory::queryProxy(const QNetworkProxyQuery &query) { if (m_proxyMode == SystemProxy) { return QNetworkProxyFactory::systemProxyForQuery(query); } if (m_proxyMode == ManualProxy) { const QString host(query.peerHostName()); for (int i = 0; i < m_proxyExceptions.count(); ++i) { if (m_proxyExceptions.at(i).contains(QLatin1Char('/'))) { const QHostAddress address(host); const QPair<QHostAddress, int> subnet(QHostAddress::parseSubnet(m_proxyExceptions.at(i))); if (!address.isNull() && subnet.second != -1 && address.isInSubnet(subnet)) { return m_proxies[QLatin1String("NoProxy")]; } } else if (host.contains(m_proxyExceptions.at(i), Qt::CaseInsensitive)) { return m_proxies[QLatin1String("NoProxy")]; } } const QString protocol(query.protocolTag().toLower()); if (m_proxies.contains(QLatin1String("socks"))) { return m_proxies[QLatin1String("socks")]; } if (protocol == QLatin1String("http") && m_proxies.contains(protocol)) { return m_proxies[protocol]; } if (protocol == QLatin1String("https") && m_proxies.contains(protocol)) { return m_proxies[protocol]; } if (protocol == QLatin1String("ftp") && m_proxies.contains(protocol)) { return m_proxies[protocol]; } return m_proxies[QLatin1String("NoProxy")]; } if (m_proxyMode == AutomaticProxy && m_automaticProxy) { return m_automaticProxy->getProxy(query.url().toString(), query.peerHostName()); } return m_proxies[QLatin1String("NoProxy")]; }
QList<QNetworkProxy> macQueryInternal(const QNetworkProxyQuery &query) { QList<QNetworkProxy> result; // obtain a dictionary to the proxy settings: CFDictionaryRef dict = SCDynamicStoreCopyProxies(NULL); if (!dict) { qWarning("QNetworkProxyFactory::systemProxyForQuery: SCDynamicStoreCopyProxies returned NULL"); return result; // failed } if (isHostExcluded(dict, query.peerHostName())) { CFRelease(dict); return result; // no proxy for this host } // is there a PAC enabled? If so, use it first. CFNumberRef pacEnabled; if ((pacEnabled = (CFNumberRef)CFDictionaryGetValue(dict, kSCPropNetProxiesProxyAutoConfigEnable))) { int enabled; if (CFNumberGetValue(pacEnabled, kCFNumberIntType, &enabled) && enabled) { // PAC is enabled CFStringRef cfPacLocation = (CFStringRef)CFDictionaryGetValue(dict, kSCPropNetProxiesProxyAutoConfigURLString); #if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) { QCFType<CFDataRef> pacData; QCFType<CFURLRef> pacUrl = CFURLCreateWithString(kCFAllocatorDefault, cfPacLocation, NULL); SInt32 errorCode; if (!CFURLCreateDataAndPropertiesFromResource(kCFAllocatorDefault, pacUrl, &pacData, NULL, NULL, &errorCode)) { QString pacLocation = QCFString::toQString(cfPacLocation); qWarning("Unable to get the PAC script at \"%s\" (%s)", qPrintable(pacLocation), cfurlErrorDescription(errorCode)); return result; } QCFType<CFStringRef> pacScript = CFStringCreateFromExternalRepresentation(kCFAllocatorDefault, pacData, kCFStringEncodingISOLatin1); if (!pacScript) { // This should never happen, but the documentation says it may return NULL if there was a problem creating the object. QString pacLocation = QCFString::toQString(cfPacLocation); qWarning("Unable to read the PAC script at \"%s\"", qPrintable(pacLocation)); return result; } QByteArray encodedURL = query.url().toEncoded(); // converted to UTF-8 if (encodedURL.isEmpty()) { return result; // Invalid URL, abort } QCFType<CFURLRef> targetURL = CFURLCreateWithBytes(kCFAllocatorDefault, (UInt8*)encodedURL.data(), encodedURL.size(), kCFStringEncodingUTF8, NULL); if (!targetURL) { return result; // URL creation problem, abort } QCFType<CFErrorRef> pacError; QCFType<CFArrayRef> proxies = CFNetworkCopyProxiesForAutoConfigurationScript(pacScript, targetURL, &pacError); if (!proxies) { QString pacLocation = QCFString::toQString(cfPacLocation); QCFType<CFStringRef> pacErrorDescription = CFErrorCopyDescription(pacError); qWarning("Execution of PAC script at \"%s\" failed: %s", qPrintable(pacLocation), qPrintable(QCFString::toQString(pacErrorDescription))); return result; } CFIndex size = CFArrayGetCount(proxies); for (CFIndex i = 0; i < size; ++i) { CFDictionaryRef proxy = (CFDictionaryRef)CFArrayGetValueAtIndex(proxies, i); result << proxyFromDictionary(proxy); } return result; } else #endif { QString pacLocation = QCFString::toQString(cfPacLocation); qWarning("Mac system proxy: PAC script at \"%s\" not handled", qPrintable(pacLocation)); } } } // no PAC, decide which proxy we're looking for based on the query bool isHttps = false; QString protocol = query.protocolTag().toLower(); // try the protocol-specific proxy QNetworkProxy protocolSpecificProxy; if (protocol == QLatin1String("ftp")) { protocolSpecificProxy = proxyFromDictionary(dict, QNetworkProxy::FtpCachingProxy, kSCPropNetProxiesFTPEnable, kSCPropNetProxiesFTPProxy, kSCPropNetProxiesFTPPort); } else if (protocol == QLatin1String("http")) { protocolSpecificProxy = proxyFromDictionary(dict, QNetworkProxy::HttpProxy, kSCPropNetProxiesHTTPEnable, kSCPropNetProxiesHTTPProxy, kSCPropNetProxiesHTTPPort); } else if (protocol == QLatin1String("https")) { isHttps = true; protocolSpecificProxy = proxyFromDictionary(dict, QNetworkProxy::HttpProxy, kSCPropNetProxiesHTTPSEnable, kSCPropNetProxiesHTTPSProxy, kSCPropNetProxiesHTTPSPort); } if (protocolSpecificProxy.type() != QNetworkProxy::DefaultProxy) result << protocolSpecificProxy; // let's add SOCKSv5 if present too QNetworkProxy socks5 = proxyFromDictionary(dict, QNetworkProxy::Socks5Proxy, kSCPropNetProxiesSOCKSEnable, kSCPropNetProxiesSOCKSProxy, kSCPropNetProxiesSOCKSPort); if (socks5.type() != QNetworkProxy::DefaultProxy) result << socks5; // let's add the HTTPS proxy if present (and if we haven't added // yet) if (!isHttps) { QNetworkProxy https = proxyFromDictionary(dict, QNetworkProxy::HttpProxy, kSCPropNetProxiesHTTPSEnable, kSCPropNetProxiesHTTPSProxy, kSCPropNetProxiesHTTPSPort); if (https.type() != QNetworkProxy::DefaultProxy && https != protocolSpecificProxy) result << https; } CFRelease(dict); return result; }
QList<QNetworkProxy> macQueryInternal(const QNetworkProxyQuery &query) { QList<QNetworkProxy> result; // obtain a dictionary to the proxy settings: CFDictionaryRef dict = SCDynamicStoreCopyProxies(NULL); if (!dict) { qWarning("QNetworkProxyFactory::systemProxyForQuery: SCDynamicStoreCopyProxies returned NULL"); return result; // failed } if (isHostExcluded(dict, query.peerHostName())) return result; // no proxy for this host // is there a PAC enabled? If so, use it first. CFNumberRef pacEnabled; if ((pacEnabled = (CFNumberRef)CFDictionaryGetValue(dict, kSCPropNetProxiesProxyAutoConfigEnable))) { int enabled; if (CFNumberGetValue(pacEnabled, kCFNumberIntType, &enabled) && enabled) { // PAC is enabled CFStringRef pacUrl = (CFStringRef)CFDictionaryGetValue(dict, kSCPropNetProxiesProxyAutoConfigURLString); QString url = QCFString::toQString(pacUrl); // ### Use PAC somehow qDebug("Mac system proxy: found PAC script at \"%s\"", qPrintable(url)); } } // no PAC, decide which proxy we're looking for based on the query bool isHttps = false; QString protocol = query.protocolTag().toLower(); // try the protocol-specific proxy QNetworkProxy protocolSpecificProxy; if (protocol == QLatin1String("ftp")) { protocolSpecificProxy = proxyFromDictionary(dict, QNetworkProxy::FtpCachingProxy, kSCPropNetProxiesFTPEnable, kSCPropNetProxiesFTPProxy, kSCPropNetProxiesFTPPort); } else if (protocol == QLatin1String("http")) { protocolSpecificProxy = proxyFromDictionary(dict, QNetworkProxy::HttpProxy, kSCPropNetProxiesHTTPEnable, kSCPropNetProxiesHTTPProxy, kSCPropNetProxiesHTTPPort); } else if (protocol == QLatin1String("https")) { isHttps = true; protocolSpecificProxy = proxyFromDictionary(dict, QNetworkProxy::HttpProxy, kSCPropNetProxiesHTTPSEnable, kSCPropNetProxiesHTTPSProxy, kSCPropNetProxiesHTTPSPort); } if (protocolSpecificProxy.type() != QNetworkProxy::DefaultProxy) result << protocolSpecificProxy; // let's add SOCKSv5 if present too QNetworkProxy socks5 = proxyFromDictionary(dict, QNetworkProxy::Socks5Proxy, kSCPropNetProxiesSOCKSEnable, kSCPropNetProxiesSOCKSProxy, kSCPropNetProxiesSOCKSPort); if (socks5.type() != QNetworkProxy::DefaultProxy) result << socks5; // let's add the HTTPS proxy if present (and if we haven't added // yet) if (!isHttps) { QNetworkProxy https = proxyFromDictionary(dict, QNetworkProxy::HttpProxy, kSCPropNetProxiesHTTPSEnable, kSCPropNetProxiesHTTPSProxy, kSCPropNetProxiesHTTPSPort); if (https.type() != QNetworkProxy::DefaultProxy && https != protocolSpecificProxy) result << https; } return result; }
void MainWindow::on_connectBtn_clicked() { VpnInfo *vpninfo = NULL; StoredServer *ss = new StoredServer(this->settings); QFuture < void >future; QString name, str, url; QList < QNetworkProxy > proxies; QUrl turl; QNetworkProxyQuery query; if (ui->connectBtn->isEnabled() == false) { return; } if (this->cmd_fd != INVALID_SOCKET) { QMessageBox::information(this, tr(APP_NAME), tr ("A previous VPN instance is still running (socket is active)")); return; } if (this->futureWatcher.isRunning() == true) { QMessageBox::information(this, tr(APP_NAME), tr ("A previous VPN instance is still running")); return; } if (ui->comboBox->currentText().isEmpty()) { QMessageBox::information(this, tr(APP_NAME), tr ("You need to specify a gateway. E.g. vpn.example.com:443")); return; } name = ui->comboBox->currentText(); ss->load(name); turl.setUrl("https://" + ss->get_servername()); query.setUrl(turl); /* ss is now deallocated by vpninfo */ vpninfo = new VpnInfo(tr(APP_STRING), ss, this); if (vpninfo == NULL) { QMessageBox::information(this, tr(APP_NAME), tr ("There was an issue initializing the VPN.")); goto fail; } this->minimize_on_connect = vpninfo->get_minimize(); vpninfo->parse_url(ss->get_servername().toLocal8Bit().data()); this->cmd_fd = vpninfo->get_cmd_fd(); if (this->cmd_fd == INVALID_SOCKET) { QMessageBox::information(this, tr(APP_NAME), tr ("There was an issue establishing IPC with openconnect; try restarting the application.")); goto fail; } proxies = QNetworkProxyFactory::systemProxyForQuery(query); if (proxies.size() > 0 && proxies.at(0).type() != QNetworkProxy::NoProxy) { if (proxies.at(0).type() == QNetworkProxy::Socks5Proxy) url = "socks5://"; else if (proxies.at(0).type() == QNetworkProxy::HttpCachingProxy || proxies.at(0).type() == QNetworkProxy::HttpProxy) url = "http://"; if (url.isEmpty() == false) { str = proxies.at(0).user() + ":" + proxies.at(0).password() + "@" + proxies.at(0).hostName(); if (proxies.at(0).port() != 0) { str += ":" + QString::number(proxies.at(0).port()); } this->updateProgressBar(tr("Setting proxy to: ") + str); openconnect_set_http_proxy(vpninfo->vpninfo, str.toAscii().data()); } } future = QtConcurrent::run(main_loop, vpninfo, this); this->futureWatcher.setFuture(future); return; fail: if (vpninfo != NULL) delete vpninfo; return; }