Simple SOCKS proxy support (#110)
This commit is contained in:
parent
7e03ca4359
commit
8c5a331c73
29
src/main.cc
29
src/main.cc
@ -19,11 +19,38 @@
|
|||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QFontDatabase>
|
#include <QFontDatabase>
|
||||||
#include <QLibraryInfo>
|
#include <QLibraryInfo>
|
||||||
|
#include <QNetworkProxy>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QTranslator>
|
#include <QTranslator>
|
||||||
|
|
||||||
#include "MainWindow.h"
|
#include "MainWindow.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
setupProxy()
|
||||||
|
{
|
||||||
|
QSettings settings;
|
||||||
|
|
||||||
|
/**
|
||||||
|
To set up a SOCKS proxy:
|
||||||
|
[user]
|
||||||
|
proxy\socks\host=<>
|
||||||
|
proxy\socks\port=<>
|
||||||
|
proxy\socks\user=<>
|
||||||
|
proxy\socks\password=<>
|
||||||
|
**/
|
||||||
|
if (settings.contains("user/proxy/socks/host")) {
|
||||||
|
QNetworkProxy proxy;
|
||||||
|
proxy.setType(QNetworkProxy::Socks5Proxy);
|
||||||
|
proxy.setHostName(settings.value("user/proxy/socks/host").toString());
|
||||||
|
proxy.setPort(settings.value("user/proxy/socks/port").toInt());
|
||||||
|
if (settings.contains("user/proxy/socks/user"))
|
||||||
|
proxy.setUser(settings.value("user/proxy/socks/user").toString());
|
||||||
|
if (settings.contains("user/proxy/socks/password"))
|
||||||
|
proxy.setPassword(settings.value("user/proxy/socks/password").toString());
|
||||||
|
QNetworkProxy::setApplicationProxy(proxy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -62,6 +89,8 @@ main(int argc, char *argv[])
|
|||||||
appTranslator.load("nheko_" + lang, ":/translations");
|
appTranslator.load("nheko_" + lang, ":/translations");
|
||||||
app.installTranslator(&appTranslator);
|
app.installTranslator(&appTranslator);
|
||||||
|
|
||||||
|
setupProxy();
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
|
||||||
// Move the MainWindow to the center
|
// Move the MainWindow to the center
|
||||||
|
Loading…
Reference in New Issue
Block a user