Skip to content

Commit

Permalink
Merge pull request #64 from kambala-decapitator/http-proxy
Browse files Browse the repository at this point in the history
add support for http proxy in CLI
  • Loading branch information
chewitt authored Feb 27, 2024
2 parents 7025e86 + 26787f1 commit bb64dfd
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,19 @@ int main(int argc, char *argv[])

qDebug() << "App data: Version:" << BUILD_VERSION << ", Build date:" << BUILD_DATE;

if (cmdArgs.contains("--no-proxy") == false) {
const QLatin1String httpProxyParam{"--http-proxy"};
const auto httpProxyParamIndex = cmdArgs.indexOf(httpProxyParam);
if (httpProxyParamIndex != -1)
{
const auto httpProxy = cmdArgs.at(httpProxyParamIndex + 1);
const auto proxyHostPort = httpProxy.split(':');

QNetworkProxy proxy{QNetworkProxy::HttpProxy, proxyHostPort[0]};
if (proxyHostPort.size() > 1)
proxy.setPort(proxyHostPort[1].toUShort());
QNetworkProxy::setApplicationProxy(proxy);
}
else if (!cmdArgs.contains("--no-proxy")) {
QNetworkProxyQuery npq(QUrl("http://releases.libreelec.tv/"));
QList<QNetworkProxy> listOfProxies = QNetworkProxyFactory::systemProxyForQuery(npq);
if (listOfProxies.size()) {
Expand Down

0 comments on commit bb64dfd

Please sign in to comment.