mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 06:43:51 +02:00
Proxy settings
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
using CefSharp;
|
using CefSharp;
|
||||||
using CefSharp.SchemeHandler;
|
using CefSharp.SchemeHandler;
|
||||||
using CefSharp.WinForms;
|
using CefSharp.WinForms;
|
||||||
@@ -9,6 +10,7 @@ namespace VRCX
|
|||||||
public class CefService
|
public class CefService
|
||||||
{
|
{
|
||||||
public static readonly CefService Instance;
|
public static readonly CefService Instance;
|
||||||
|
private static readonly NLog.Logger logger = NLog.LogManager.GetLogger("VRCX");
|
||||||
|
|
||||||
static CefService()
|
static CefService()
|
||||||
{
|
{
|
||||||
@@ -51,8 +53,14 @@ namespace VRCX
|
|||||||
cefSettings.CefCommandLineArgs.Add("disable-web-security");
|
cefSettings.CefCommandLineArgs.Add("disable-web-security");
|
||||||
cefSettings.SetOffScreenRenderingBestPerformanceArgs(); // causes white screen sometimes?
|
cefSettings.SetOffScreenRenderingBestPerformanceArgs(); // causes white screen sometimes?
|
||||||
|
|
||||||
|
if (WebApi.ProxySet)
|
||||||
|
{
|
||||||
|
cefSettings.CefCommandLineArgs["proxy-server"] = WebApi.ProxyUrl;
|
||||||
|
}
|
||||||
|
|
||||||
if (Program.LaunchDebug)
|
if (Program.LaunchDebug)
|
||||||
{
|
{
|
||||||
|
logger.Info("Debug mode enabled");
|
||||||
cefSettings.RemoteDebuggingPort = 8088;
|
cefSettings.RemoteDebuggingPort = 8088;
|
||||||
cefSettings.CefCommandLineArgs["remote-allow-origins"] = "*";
|
cefSettings.CefCommandLineArgs["remote-allow-origins"] = "*";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,11 +8,10 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace VRCX
|
namespace VRCX
|
||||||
{
|
{
|
||||||
class ImageCache
|
internal static class ImageCache
|
||||||
{
|
{
|
||||||
private static readonly string cacheLocation = Path.Combine(Program.AppDataDirectory, "ImageCache");
|
private static readonly string cacheLocation;
|
||||||
private static readonly HttpClientHandler httpClientHandler = new HttpClientHandler(){ Proxy = WebApi.Proxy };
|
private static readonly HttpClient httpClient;
|
||||||
private static readonly HttpClient httpClient = new HttpClient(httpClientHandler);
|
|
||||||
private static readonly List<string> _imageHosts =
|
private static readonly List<string> _imageHosts =
|
||||||
[
|
[
|
||||||
"api.vrchat.cloud",
|
"api.vrchat.cloud",
|
||||||
@@ -21,6 +20,16 @@ namespace VRCX
|
|||||||
"assets.vrchat.com"
|
"assets.vrchat.com"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
static ImageCache()
|
||||||
|
{
|
||||||
|
cacheLocation = Path.Combine(Program.AppDataDirectory, "ImageCache");
|
||||||
|
var httpClientHandler = new HttpClientHandler();
|
||||||
|
if (WebApi.ProxySet)
|
||||||
|
httpClientHandler.Proxy = WebApi.Proxy;
|
||||||
|
|
||||||
|
httpClient = new HttpClient(httpClientHandler);
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<string> GetImage(string url, string fileId, string version)
|
public static async Task<string> GetImage(string url, string fileId, string version)
|
||||||
{
|
{
|
||||||
var directoryLocation = Path.Combine(cacheLocation, fileId);
|
var directoryLocation = Path.Combine(cacheLocation, fileId);
|
||||||
@@ -74,9 +83,9 @@ namespace VRCX
|
|||||||
|
|
||||||
private static void CleanImageCache()
|
private static void CleanImageCache()
|
||||||
{
|
{
|
||||||
DirectoryInfo dirInfo = new DirectoryInfo(cacheLocation);
|
var dirInfo = new DirectoryInfo(cacheLocation);
|
||||||
var folders = dirInfo.GetDirectories().OrderByDescending(p => p.LastWriteTime).Skip(1000);
|
var folders = dirInfo.GetDirectories().OrderByDescending(p => p.LastWriteTime).Skip(1000);
|
||||||
foreach (DirectoryInfo folder in folders)
|
foreach (var folder in folders)
|
||||||
{
|
{
|
||||||
folder.Delete(true);
|
folder.Delete(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,12 +58,6 @@ namespace VRCX
|
|||||||
Dock = DockStyle.Fill
|
Dock = DockStyle.Fill
|
||||||
};
|
};
|
||||||
|
|
||||||
string? proxyUrl = VRCXStorage.Instance.Get("VRCX_ProxyServer");
|
|
||||||
if (!string.IsNullOrEmpty(proxyUrl))
|
|
||||||
{
|
|
||||||
WebApi.Proxy = new WebProxy(proxyUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
Browser.IsBrowserInitializedChanged += (A, B) =>
|
Browser.IsBrowserInitializedChanged += (A, B) =>
|
||||||
{
|
{
|
||||||
if (Program.LaunchDebug)
|
if (Program.LaunchDebug)
|
||||||
|
|||||||
@@ -167,8 +167,7 @@ namespace VRCX
|
|||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
|
||||||
logger.Info("{0} Starting...", Version);
|
logger.Info("{0} Starting...", Version);
|
||||||
|
|
||||||
|
|
||||||
ProcessMonitor.Instance.Init();
|
ProcessMonitor.Instance.Init();
|
||||||
SQLiteLegacy.Instance.Init();
|
SQLiteLegacy.Instance.Init();
|
||||||
AppApi.Instance.Init();
|
AppApi.Instance.Init();
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ namespace VRCX
|
|||||||
internal class StartupArgs
|
internal class StartupArgs
|
||||||
{
|
{
|
||||||
public static string LaunchCommand;
|
public static string LaunchCommand;
|
||||||
|
public static string ProxyUrl;
|
||||||
public static Process[] processList;
|
public static Process[] processList;
|
||||||
|
|
||||||
public static void ArgsCheck()
|
public static void ArgsCheck()
|
||||||
@@ -52,10 +53,7 @@ namespace VRCX
|
|||||||
Program.LaunchDebug = true;
|
Program.LaunchDebug = true;
|
||||||
|
|
||||||
if (arg.Length >= 16 && arg.Substring(0, 14) == "--proxy-server")
|
if (arg.Length >= 16 && arg.Substring(0, 14) == "--proxy-server")
|
||||||
{
|
ProxyUrl = arg.Substring(15).Replace("'", string.Empty).Replace("\"", string.Empty);
|
||||||
string proxyUrl = arg.Substring(15).Replace("'", string.Empty).Replace("\"", string.Empty);
|
|
||||||
WebApi.Proxy = new WebProxy(proxyUrl);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var type = CommandLineArgsParser.GetArgumentValue(args, CefSharpArguments.SubProcessTypeArgument);
|
var type = CommandLineArgsParser.GetArgumentValue(args, CefSharpArguments.SubProcessTypeArgument);
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ namespace VRCX
|
|||||||
MessageBox.Show(e.ToString(), "Update failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(e.ToString(), "Update failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void DownloadInstallRedist()
|
public static void DownloadInstallRedist()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -78,7 +79,6 @@ namespace VRCX
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static string DownloadFile(string fileUrl)
|
private static string DownloadFile(string fileUrl)
|
||||||
{
|
{
|
||||||
HttpClient client = new HttpClient();
|
HttpClient client = new HttpClient();
|
||||||
|
|||||||
@@ -16,10 +16,14 @@ namespace VRCX
|
|||||||
public class WebApi
|
public class WebApi
|
||||||
{
|
{
|
||||||
public static readonly WebApi Instance;
|
public static readonly WebApi Instance;
|
||||||
|
|
||||||
|
public static bool ProxySet;
|
||||||
|
public static string ProxyUrl = "";
|
||||||
|
public static IWebProxy Proxy = WebRequest.DefaultWebProxy;
|
||||||
|
|
||||||
public CookieContainer _cookieContainer;
|
public CookieContainer _cookieContainer;
|
||||||
private bool _cookieDirty;
|
private bool _cookieDirty;
|
||||||
private Timer _timer;
|
private Timer _timer;
|
||||||
public static IWebProxy? Proxy = WebRequest.DefaultWebProxy;
|
|
||||||
|
|
||||||
static WebApi()
|
static WebApi()
|
||||||
{
|
{
|
||||||
@@ -47,10 +51,30 @@ namespace VRCX
|
|||||||
|
|
||||||
internal void Init()
|
internal void Init()
|
||||||
{
|
{
|
||||||
|
SetProxy();
|
||||||
LoadCookies();
|
LoadCookies();
|
||||||
_timer.Change(1000, 1000);
|
_timer.Change(1000, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetProxy()
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(StartupArgs.ProxyUrl))
|
||||||
|
ProxyUrl = StartupArgs.ProxyUrl;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(ProxyUrl))
|
||||||
|
{
|
||||||
|
var proxyUrl = VRCXStorage.Instance.Get("VRCX_ProxyServer");
|
||||||
|
if (!string.IsNullOrEmpty(proxyUrl))
|
||||||
|
ProxyUrl = proxyUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(ProxyUrl))
|
||||||
|
return;
|
||||||
|
|
||||||
|
ProxySet = true;
|
||||||
|
Proxy = new WebProxy(ProxyUrl);
|
||||||
|
}
|
||||||
|
|
||||||
internal void Exit()
|
internal void Exit()
|
||||||
{
|
{
|
||||||
_timer.Change(-1, -1);
|
_timer.Change(-1, -1);
|
||||||
@@ -145,7 +169,9 @@ namespace VRCX
|
|||||||
|
|
||||||
private static async Task LegacyImageUpload(HttpWebRequest request, IDictionary<string, object> options)
|
private static async Task LegacyImageUpload(HttpWebRequest request, IDictionary<string, object> options)
|
||||||
{
|
{
|
||||||
request.Proxy = Proxy;
|
if (ProxySet)
|
||||||
|
request.Proxy = Proxy;
|
||||||
|
|
||||||
request.Method = "POST";
|
request.Method = "POST";
|
||||||
string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x");
|
string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x");
|
||||||
request.ContentType = "multipart/form-data; boundary=" + boundary;
|
request.ContentType = "multipart/form-data; boundary=" + boundary;
|
||||||
@@ -190,7 +216,9 @@ namespace VRCX
|
|||||||
|
|
||||||
private static async Task UploadFilePut(HttpWebRequest request, IDictionary<string, object> options)
|
private static async Task UploadFilePut(HttpWebRequest request, IDictionary<string, object> options)
|
||||||
{
|
{
|
||||||
request.Proxy = Proxy;
|
if (ProxySet)
|
||||||
|
request.Proxy = Proxy;
|
||||||
|
|
||||||
request.Method = "PUT";
|
request.Method = "PUT";
|
||||||
request.ContentType = options["fileMIME"] as string;
|
request.ContentType = options["fileMIME"] as string;
|
||||||
var fileData = options["fileData"] as string;
|
var fileData = options["fileData"] as string;
|
||||||
@@ -205,7 +233,9 @@ namespace VRCX
|
|||||||
|
|
||||||
private static async Task ImageUpload(HttpWebRequest request, IDictionary<string, object> options)
|
private static async Task ImageUpload(HttpWebRequest request, IDictionary<string, object> options)
|
||||||
{
|
{
|
||||||
request.Proxy = Proxy;
|
if (ProxySet)
|
||||||
|
request.Proxy = Proxy;
|
||||||
|
|
||||||
request.Method = "POST";
|
request.Method = "POST";
|
||||||
string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x");
|
string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x");
|
||||||
request.ContentType = "multipart/form-data; boundary=" + boundary;
|
request.ContentType = "multipart/form-data; boundary=" + boundary;
|
||||||
@@ -259,7 +289,9 @@ namespace VRCX
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var request = WebRequest.CreateHttp((string)options["url"]);
|
var request = WebRequest.CreateHttp((string)options["url"]);
|
||||||
request.Proxy = Proxy;
|
if (ProxySet)
|
||||||
|
request.Proxy = Proxy;
|
||||||
|
|
||||||
request.CookieContainer = _cookieContainer;
|
request.CookieContainer = _cookieContainer;
|
||||||
request.KeepAlive = true;
|
request.KeepAlive = true;
|
||||||
request.UserAgent = Program.Version;
|
request.UserAgent = Program.Version;
|
||||||
|
|||||||
@@ -15659,6 +15659,10 @@ speechSynthesis.getVoices();
|
|||||||
if (!(await VRCXStorage.Get('VRCX_DatabaseLocation'))) {
|
if (!(await VRCXStorage.Get('VRCX_DatabaseLocation'))) {
|
||||||
await VRCXStorage.Set('VRCX_DatabaseLocation', '');
|
await VRCXStorage.Set('VRCX_DatabaseLocation', '');
|
||||||
}
|
}
|
||||||
|
if (!(await VRCXStorage.Get('VRCX_ProxyServer'))) {
|
||||||
|
await VRCXStorage.Set('VRCX_ProxyServer', '');
|
||||||
|
}
|
||||||
|
$app.data.proxyServer = await VRCXStorage.Get('VRCX_ProxyServer');
|
||||||
$app.data.disableWorldDatabase =
|
$app.data.disableWorldDatabase =
|
||||||
(await VRCXStorage.Get('VRCX_DisableWorldDatabase')) === 'true';
|
(await VRCXStorage.Get('VRCX_DisableWorldDatabase')) === 'true';
|
||||||
$app.methods.saveVRCXWindowOption = async function () {
|
$app.methods.saveVRCXWindowOption = async function () {
|
||||||
@@ -32886,6 +32890,35 @@ speechSynthesis.getVoices();
|
|||||||
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
|
// #region proxy settings
|
||||||
|
|
||||||
|
$app.methods.promptProxySettings = function () {
|
||||||
|
this.$prompt(
|
||||||
|
$t('prompt.proxy_settings.description'),
|
||||||
|
$t('prompt.proxy_settings.header'),
|
||||||
|
{
|
||||||
|
distinguishCancelAndClose: true,
|
||||||
|
confirmButtonText: $t('prompt.proxy_settings.restart'),
|
||||||
|
cancelButtonText: $t('prompt.proxy_settings.close'),
|
||||||
|
inputValue: this.proxyServer,
|
||||||
|
inputPlaceholder: $t('prompt.proxy_settings.placeholder'),
|
||||||
|
callback: async (action, instance) => {
|
||||||
|
this.proxyServer = instance.inputValue;
|
||||||
|
await VRCXStorage.Set('VRCX_ProxyServer', this.proxyServer);
|
||||||
|
await VRCXStorage.Flush();
|
||||||
|
await new Promise((resolve) => {
|
||||||
|
workerTimers.setTimeout(resolve, 100);
|
||||||
|
});
|
||||||
|
if (action === 'confirm') {
|
||||||
|
AppApi.RestartApplication();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// #endregion
|
||||||
|
|
||||||
$app = new Vue($app);
|
$app = new Vue($app);
|
||||||
window.$app = $app;
|
window.$app = $app;
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -20,6 +20,8 @@
|
|||||||
"login": "Login",
|
"login": "Login",
|
||||||
"register": "Register",
|
"register": "Register",
|
||||||
"forgotPassword": "Forgot Password?",
|
"forgotPassword": "Forgot Password?",
|
||||||
|
"updater": "Updater",
|
||||||
|
"proxy_settings": "Proxy settings",
|
||||||
"field": {
|
"field": {
|
||||||
"username": "Username or Email",
|
"username": "Username or Email",
|
||||||
"password": "Password",
|
"password": "Password",
|
||||||
@@ -211,7 +213,8 @@
|
|||||||
"header": "Application",
|
"header": "Application",
|
||||||
"startup": "Start at Windows startup",
|
"startup": "Start at Windows startup",
|
||||||
"minimized": "Start as minimized state",
|
"minimized": "Start as minimized state",
|
||||||
"tray": "Close to tray"
|
"tray": "Close to tray",
|
||||||
|
"proxy": "Proxy settings"
|
||||||
},
|
},
|
||||||
"favorites": {
|
"favorites": {
|
||||||
"header": "VRCX Favorite Friends",
|
"header": "VRCX Favorite Friends",
|
||||||
@@ -1600,6 +1603,13 @@
|
|||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
"save": "Save",
|
"save": "Save",
|
||||||
"input_error": "Valid number is required"
|
"input_error": "Valid number is required"
|
||||||
|
},
|
||||||
|
"proxy_settings": {
|
||||||
|
"header": "Proxy Settings",
|
||||||
|
"description": "Enter proxy server address and port",
|
||||||
|
"placeholder": "127.0.0.1:8080",
|
||||||
|
"close": "Close",
|
||||||
|
"restart": "Restart"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"table": {
|
"table": {
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ mixin loginPage()
|
|||||||
.x-login-container(v-if="!API.isLoggedIn" v-loading="loginForm.loading")
|
.x-login-container(v-if="!API.isLoggedIn" v-loading="loginForm.loading")
|
||||||
.x-login
|
.x-login
|
||||||
div(style="position:fixed; top: 0; left: 0; margin:5px")
|
div(style="position:fixed; top: 0; left: 0; margin:5px")
|
||||||
el-button(type="default" @click="showVRCXUpdateDialog" size="mini" icon="el-icon-download" circle)
|
el-tooltip(placement="top" :content="$t('view.login.updater')" :disabled="hideTooltips")
|
||||||
|
el-button(type="default" @click="showVRCXUpdateDialog" size="mini" icon="el-icon-download" circle)
|
||||||
|
el-tooltip(placement="top" :content="$t('view.login.proxy_settings')" :disabled="hideTooltips")
|
||||||
|
el-button(type="default" @click="promptProxySettings" size="mini" icon="el-icon-connection" style="margin-left:5px" circle)
|
||||||
|
|
||||||
div.x-login-form-container
|
div.x-login-form-container
|
||||||
div
|
div
|
||||||
|
|||||||
@@ -84,6 +84,8 @@ mixin settingsTab()
|
|||||||
+simpleSwitch("view.settings.general.application.startup", "isStartAtWindowsStartup", "saveVRCXWindowOption")
|
+simpleSwitch("view.settings.general.application.startup", "isStartAtWindowsStartup", "saveVRCXWindowOption")
|
||||||
+simpleSwitch("view.settings.general.application.minimized", "isStartAsMinimizedState", "saveVRCXWindowOption")
|
+simpleSwitch("view.settings.general.application.minimized", "isStartAsMinimizedState", "saveVRCXWindowOption")
|
||||||
+simpleSwitch("view.settings.general.application.tray", "isCloseToTray", "saveVRCXWindowOption")
|
+simpleSwitch("view.settings.general.application.tray", "isCloseToTray", "saveVRCXWindowOption")
|
||||||
|
div.options-container-item
|
||||||
|
el-button(size="small" icon="el-icon-connection" @click="promptProxySettings()") {{ $t("view.settings.general.application.proxy") }}
|
||||||
//- General | Favorite
|
//- General | Favorite
|
||||||
+simpleSettingsCategory("view.settings.general.favorites.header")
|
+simpleSettingsCategory("view.settings.general.favorites.header")
|
||||||
br
|
br
|
||||||
|
|||||||
Reference in New Issue
Block a user