Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

Commit

Permalink
add support for system proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Tabing010102 committed Mar 2, 2023
1 parent 77de7b4 commit 7a66fc9
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion WaiterLibrary/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace WaiterLibrary
{
public static class Global
{
static Global()
{
var systemProxy = WebRequest.GetSystemWebProxy();
var httpProxy = new WebProxy(systemProxy.GetProxy(new Uri("https://google.com")));
var httpHandler = new HttpClientHandler();
httpHandler.Proxy = httpProxy;
//httpHandler.SslProtocols = System.Security.Authentication.SslProtocols.Tls13;
httpHandler.UseProxy = true;
var httpClient = new HttpClient(httpHandler, true);
ChannelOptions = new GrpcChannelOptions();
ChannelOptions.HttpClient = httpClient;
}
private static GrpcChannel? _channel;

public static string ServerURL = "https://theam-grpc.gyx.moe";
public static GrpcChannelOptions ChannelOptions;
public static GrpcChannel Channel
{
get => _channel ??= GrpcChannel.ForAddress(ServerURL);
get => _channel ??= GrpcChannel.ForAddress(ServerURL, ChannelOptions);
set => _channel = value;
}
}
Expand Down

0 comments on commit 7a66fc9

Please sign in to comment.