Re: [Tails-dev] minitube (Youtube client) |
This message is part of the following thread: | |
---|---|
the complete thread tree sorted by date | |
Alessandro Grassi at | |
adrelanos at |
+++ global.h 2012-12-07 12:45:16.000000000 +0000 @@ -123,12 +123,77 @@ } }
+ void networkSocks5ProxySetting() { + char *socks5_server_env; + socks5_server_env = std::getenv("socks5_server"); + if (!socks5_server_env) { + socks5_server_env = std::getenv("SOCKS5_SERVER"); + } + + if (socks5_server_env) { + QString proxy_host = ""; + QString proxy_port = ""; + QString proxy_user = ""; + QString proxy_pass = ""; + QString socks5_server = QString(socks5_server_env); + socks5_server.remove(QRegExp("/$")); + + // parse username and password + if (socks5_server.contains(QChar('@'))) { + QStringList socks5_server_list = socks5_server.split(QChar('@')); + QStringList socks5_server_user_pass = socks5_server_list[0].split(QChar(':')); + if (socks5_server_user_pass.size() > 0) { + proxy_user = QUrl::fromPercentEncoding(socks5_server_user_pass[0].toUtf8()); + } + if (socks5_server_user_pass.size() == 2) { + proxy_pass = QUrl::fromPercentEncoding(socks5_server_user_pass[1].toUtf8()); + } + if (socks5_server_list.size() > 1) { + socks5_server = socks5_server_list[1]; + } + } + + // parse hostname and port + QStringList socks5_server_list = socks5_server.split(QChar(':')); + if (socks5_server_list.size() > 0) { + proxy_host = socks5_server_list[0]; + } + if (socks5_server_list.size() > 1) { + proxy_port = socks5_server_list[1]; + } + + // set proxy setting + if (!proxy_host.isEmpty()) { + QNetworkProxy proxy; + proxy.setType(QNetworkProxy::Socks5Proxy); + proxy.setHostName(proxy_host); + if (!proxy_port.isEmpty()) { + proxy.setPort(proxy_port.toUShort()); + } + if (!proxy_user.isEmpty()) { + proxy.setUser(proxy_user); + } + if (!proxy_pass.isEmpty()) { + proxy.setPassword(proxy_pass); + } + + qDebug() << "Using SOCKS5 proxy:" << socks5_server_env; + QNetworkProxy::setApplicationProxy(proxy); + } + } + } + static QNetworkAccessManager *nam = 0;
QNetworkAccessManager* networkAccessManager() { if (!nam) { - networkHttpProxySetting(); - maybeSetSystemProxy(); + if( std::getenv("socks5_server") || std::getenv("SOCKS5_SERVER") ) { + networkSocks5ProxySetting(); + } else if ( std::getenv("http_proxy") || std::getenv("HTTP_PROXY") ) { + networkHttpProxySetting(); + } else { + maybeSetSystemProxy(); + } nam = new QNetworkAccessManager(); } return nam;
This message was posted to the following mailing lists: | ||||
---|---|---|---|---|
tails-dev Mailing List Info | Nearby Messages | Re: [Tails-dev] minitube (Youtube client) | Re: [Tails-dev] minitube (Youtube client) |
lists.autistici.org administrated by postmaster | Lurker (version 2.3) |