Skip to content

Commit

Permalink
add support for http proxy in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
kambala-decapitator committed Feb 26, 2024
1 parent 171b1b6 commit 26787f1
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 @@ -83,7 +83,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 26787f1

Please sign in to comment.