mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-04-19 14:53:50 +02:00
Implement proxy-server launch argument
Grab proxy-server from launch arguments to match chromium getting it.
This commit is contained in:
@@ -11,7 +11,8 @@ namespace VRCX
|
|||||||
class ImageCache
|
class ImageCache
|
||||||
{
|
{
|
||||||
private static readonly string cacheLocation = Path.Combine(Program.AppDataDirectory, "ImageCache");
|
private static readonly string cacheLocation = Path.Combine(Program.AppDataDirectory, "ImageCache");
|
||||||
private static readonly HttpClient httpClient = new HttpClient();
|
private static readonly HttpClientHandler httpClientHandler = new HttpClientHandler(){ Proxy = StartupArgs.Proxy };
|
||||||
|
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",
|
||||||
@@ -53,8 +54,7 @@ namespace VRCX
|
|||||||
{
|
{
|
||||||
{ "Cookie", cookieString },
|
{ "Cookie", cookieString },
|
||||||
{ "User-Agent", Program.Version }
|
{ "User-Agent", Program.Version }
|
||||||
},
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
using (var response = await httpClient.SendAsync(request))
|
using (var response = await httpClient.SendAsync(request))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,10 +4,12 @@
|
|||||||
// This work is licensed under the terms of the MIT license.
|
// This work is licensed under the terms of the MIT license.
|
||||||
// For a copy, see <https://opensource.org/licenses/MIT>.
|
// For a copy, see <https://opensource.org/licenses/MIT>.
|
||||||
|
|
||||||
|
using CefSharp;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Pipes;
|
using System.IO.Pipes;
|
||||||
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
@@ -15,6 +17,7 @@ namespace VRCX
|
|||||||
{
|
{
|
||||||
internal class StartupArgs
|
internal class StartupArgs
|
||||||
{
|
{
|
||||||
|
public static IWebProxy? Proxy = WebRequest.DefaultWebProxy;
|
||||||
public static string LaunchCommand;
|
public static string LaunchCommand;
|
||||||
public static Process[] processList;
|
public static Process[] processList;
|
||||||
|
|
||||||
@@ -47,6 +50,12 @@ namespace VRCX
|
|||||||
|
|
||||||
if (arg.Length >= 7 && arg.Substring(0, 7) == "--debug")
|
if (arg.Length >= 7 && arg.Substring(0, 7) == "--debug")
|
||||||
Program.LaunchDebug = true;
|
Program.LaunchDebug = true;
|
||||||
|
|
||||||
|
if (arg.Length >= 16 && arg.Substring(0, 14) == "--proxy-server")
|
||||||
|
{
|
||||||
|
string proxyUrl = arg.Substring(15).Replace("'", string.Empty).Replace("\"", string.Empty);
|
||||||
|
Proxy = new WebProxy(proxyUrl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Program.AppDataDirectory))
|
if (!string.IsNullOrEmpty(Program.AppDataDirectory))
|
||||||
|
|||||||
@@ -144,6 +144,7 @@ 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 = StartupArgs.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;
|
||||||
@@ -188,6 +189,7 @@ 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 = StartupArgs.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;
|
||||||
@@ -202,6 +204,7 @@ 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 = StartupArgs.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;
|
||||||
@@ -255,6 +258,7 @@ namespace VRCX
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var request = WebRequest.CreateHttp((string)options["url"]);
|
var request = WebRequest.CreateHttp((string)options["url"]);
|
||||||
|
request.Proxy = StartupArgs.Proxy;
|
||||||
request.CookieContainer = _cookieContainer;
|
request.CookieContainer = _cookieContainer;
|
||||||
request.KeepAlive = true;
|
request.KeepAlive = true;
|
||||||
request.UserAgent = Program.Version;
|
request.UserAgent = Program.Version;
|
||||||
|
|||||||
Reference in New Issue
Block a user