Skip to content
This repository was archived by the owner on Jul 9, 2023. It is now read-only.

Commit d21ea35

Browse files
committed
add UpStreamEndPoint to sample
1 parent 3d74694 commit d21ea35

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

examples/Titanium.Web.Proxy.Examples.Basic/ProxyTestController.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,12 @@ private async Task onRequest(object sender, SessionEventArgs e)
207207
{
208208
e.GetState().PipelineInfo.AppendLine(nameof(onRequest) + ":" + e.HttpClient.Request.RequestUri);
209209

210+
var clientLocalIp = e.ClientLocalEndPoint.Address;
211+
if (!clientLocalIp.Equals(IPAddress.Loopback) && !clientLocalIp.Equals(IPAddress.IPv6Loopback))
212+
{
213+
e.HttpClient.UpStreamEndPoint = new IPEndPoint(clientLocalIp, 0);
214+
}
215+
210216
if (e.HttpClient.Request.Url.Contains("yahoo.com"))
211217
{
212218
e.CustomUpStreamProxy = new ExternalProxy("localhost", 8888);

0 commit comments

Comments
 (0)