mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-10-30 17:40:47 +03:00
Simple SOCKS proxy support (#110)
This commit is contained in:
parent
7e03ca4359
commit
8c5a331c73
1 changed files with 29 additions and 0 deletions
29
src/main.cc
29
src/main.cc
|
@ -19,11 +19,38 @@
|
|||
#include <QDesktopWidget>
|
||||
#include <QFontDatabase>
|
||||
#include <QLibraryInfo>
|
||||
#include <QNetworkProxy>
|
||||
#include <QSettings>
|
||||
#include <QTranslator>
|
||||
|
||||
#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
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
|
@ -62,6 +89,8 @@ main(int argc, char *argv[])
|
|||
appTranslator.load("nheko_" + lang, ":/translations");
|
||||
app.installTranslator(&appTranslator);
|
||||
|
||||
setupProxy();
|
||||
|
||||
MainWindow w;
|
||||
|
||||
// Move the MainWindow to the center
|
||||
|
|
Loading…
Reference in a new issue