Add Ip override
SuccessfulCode/SuccessfulCodeTools/master This commit looks good

This commit is contained in:
2020-03-01 13:05:22 +00:00
parent 56554f1f3a
commit cd34a10f74
2 changed files with 4 additions and 1 deletions
@@ -33,7 +33,8 @@ namespace SuccessfulCodeTools.LowLevelHttpClient
var ipLocalEndPoint = new IPEndPoint(IPAddress.Any, outBoundPort); var ipLocalEndPoint = new IPEndPoint(IPAddress.Any, outBoundPort);
using (var tcp = new TcpClient(ipLocalEndPoint)) using (var tcp = new TcpClient(ipLocalEndPoint))
{ {
var remoteEndpoint = new IPEndPoint(Dns.GetHostEntry(message.Uri.Host).AddressList[0], 80); var remoteIp = message.IpToOveride ?? Dns.GetHostEntry(message.Uri.Host).AddressList[0];
var remoteEndpoint = new IPEndPoint(remoteIp, 80);
tcp.Connect(remoteEndpoint); tcp.Connect(remoteEndpoint);
tcp.LingerState.Enabled = false; tcp.LingerState.Enabled = false;
@@ -2,6 +2,7 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Text; using System.Text;
@@ -13,6 +14,7 @@ namespace SuccessfulCodeTools.LowLevelHttpClient
public Uri Uri { get; set; } public Uri Uri { get; set; }
public string Method { get; set; } public string Method { get; set; }
public IPAddress IpToOveride { get; set; }
public CustomHttpRequestMessage(HttpMethod method, string url) public CustomHttpRequestMessage(HttpMethod method, string url)
{ {
Uri = new Uri(url); Uri = new Uri(url);