Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#742 rebase/squash) Improvements to HTTP web proxy #917

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions QuickFIXn/Transport/StreamFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
/// </summary>
internal static class StreamFactory
{
private static Socket? CreateTunnelThruProxy(string destIp, int destPort)
private static Socket? CreateTunnelThruProxy(string destIp, int destPort, string destHostName)
{
string destUriWithPort = $"{destIp}:{destPort}";
UriBuilder uriBuilder = new UriBuilder(destUriWithPort);
Uri destUri = uriBuilder.Uri;
IWebProxy webProxy = WebRequest.GetSystemWebProxy();
IWebProxy webProxy = WebRequest.DefaultWebProxy ?? WebRequest.GetSystemWebProxy();

try
{
Expand All @@ -44,7 +44,7 @@
Socket socketThruProxy = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socketThruProxy.Connect(proxyEndPoint);

string proxyMsg = $"CONNECT {destIp}:{destPort} HTTP/1.1 \n\n";
string proxyMsg = $"CONNECT {destHostName}:{destPort} HTTP/1.1\nHost: {destHostName}:{destPort}\n\n";
byte[] buffer = Encoding.ASCII.GetBytes(proxyMsg);
byte[] buffer12 = new byte[500];
socketThruProxy.Send(buffer, buffer.Length, 0);
Expand Down Expand Up @@ -73,7 +73,7 @@
if (!settings.SocketIgnoreProxy)
{
// If system has configured a proxy for this config, use it.
socket = CreateTunnelThruProxy(endpoint.Address.ToString(), endpoint.Port);
socket = CreateTunnelThruProxy(endpoint.Address.ToString(), endpoint.Port, settings.ServerCommonName);

Check warning on line 76 in QuickFIXn/Transport/StreamFactory.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'destHostName' in 'Socket? StreamFactory.CreateTunnelThruProxy(string destIp, int destPort, string destHostName)'.

Check warning on line 76 in QuickFIXn/Transport/StreamFactory.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'destHostName' in 'Socket? StreamFactory.CreateTunnelThruProxy(string destIp, int destPort, string destHostName)'.
}

// No proxy. Set up a regular socket.
Expand Down
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ What's New
* #516 - remove ability to toggle Session-enable via HttpServer because it never really worked (gbirchmeier)
* #913/#741 - new FieldMap.ReadGroups for iterating on groups (NoviProg/gbirchmeier)
* #914 - Optimize MessageCracker.IsHandlerMethod (vasily-balansea)
* #742 - Improvements to HTTP web proxy (IanLeeClaxton)

### v1.12.0

Expand Down
Loading