Skip to content

Commit d0e7f61

Browse files
committedJan 5, 2018
owncloudcmd: Set proxy earlier #6281
In particular before the capability call. Also warn if no proxy is set because the command line doesn't follow the strict format requirements.
1 parent 0f8790d commit d0e7f61

File tree

1 file changed

+24
-23
lines changed

1 file changed

+24
-23
lines changed
 

‎src/cmd/cmd.cpp

+24-23
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,30 @@ int main(int argc, char **argv)
420420
folder.chop(1);
421421
}
422422

423+
if (!options.proxy.isNull()) {
424+
QString host;
425+
int port = 0;
426+
bool ok;
427+
428+
QStringList pList = options.proxy.split(':');
429+
if (pList.count() == 3) {
430+
// http: //192.168.178.23 : 8080
431+
// 0 1 2
432+
host = pList.at(1);
433+
if (host.startsWith("//"))
434+
host.remove(0, 2);
435+
436+
port = pList.at(2).toInt(&ok);
437+
438+
QNetworkProxyFactory::setUseSystemConfiguration(false);
439+
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, host, port));
440+
} else {
441+
qFatal("Could not read httpproxy. The proxy should have the format \"http://hostname:port\".");
442+
}
443+
} else {
444+
clientProxy.setupQtProxyFromConfig();
445+
}
446+
423447
SimpleSslErrorHandler *sslErrorHandler = new SimpleSslErrorHandler;
424448

425449
HttpCredentialsText *cred = new HttpCredentialsText(user, password);
@@ -457,31 +481,8 @@ int main(int argc, char **argv)
457481
int restartCount = 0;
458482
restart_sync:
459483

460-
461484
opts = &options;
462485

463-
if (!options.proxy.isNull()) {
464-
QString host;
465-
int port = 0;
466-
bool ok;
467-
468-
QStringList pList = options.proxy.split(':');
469-
if (pList.count() == 3) {
470-
// http: //192.168.178.23 : 8080
471-
// 0 1 2
472-
host = pList.at(1);
473-
if (host.startsWith("//"))
474-
host.remove(0, 2);
475-
476-
port = pList.at(2).toInt(&ok);
477-
478-
QNetworkProxyFactory::setUseSystemConfiguration(false);
479-
QNetworkProxy::setApplicationProxy(QNetworkProxy(QNetworkProxy::HttpProxy, host, port));
480-
}
481-
} else {
482-
clientProxy.setupQtProxyFromConfig();
483-
}
484-
485486
QStringList selectiveSyncList;
486487
if (!options.unsyncedfolders.isEmpty()) {
487488
QFile f(options.unsyncedfolders);

0 commit comments

Comments
 (0)
Please sign in to comment.