Skip to content

Commit

Permalink
The current http proxy implementation has a few issues that I encount…
Browse files Browse the repository at this point in the history
…ered when trying to implement behind a Squid proxy so we were unable to use it. This update should resolve the issues we encountered

Bug: proxy connect packet is malformed due to a space after HTTP/1.1.
Feature: Pass the host name so proxy host acls can be matched.
Feature: Switch to the WebRequest.DefaultWebProxy which allows for overriding in app.settings file and falls back to the system proxy if not configured.
Improvement: Use ordinal comparision for IndexOf on the proxy response.
  • Loading branch information
IanLeeClaxton committed Mar 7, 2024
2 parents 7c7d2d9 + b9e93b4 commit 95a786f
Show file tree
Hide file tree
Showing 1,281 changed files with 1,266,578 additions and 1,185,931 deletions.
30 changes: 21 additions & 9 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
# Make all the C# source be crlf
generator/*rb text eol=crlf
*.cs text eol=crlf
*.bat text eol=crlf
*.csproj text eol=crlf
*.sln text eol=crlf
*.cfg text
*.pfx binary
*.cer binary
# Auto detect text files and perform LF normalization
* text=auto

*.bat text
*.cer binary
*.cfg text
*.cs text
*.csproj text
*.def text
*.erb text
*.fmt text
*.md text
*.pfx binary
*.ps1 text
*.rb text
*.sln text
*.txt text
*.xml text
*.xsl text
*.yml text

1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
blank_issues_enabled: false
19 changes: 19 additions & 0 deletions .github/ISSUE_TEMPLATE/new-issue-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: New issue template
about: You should choose this one
title: ''
labels: ''
assignees: ''

---

**DO NOT ASK FOR USAGE HELP HERE.**
Please see [this page](https://quickfixengine.org/n/support/)
to learn where you should ask for help.

Github issues are **only** for engine bugs and feature requests,
and only a couple people are notified. If you ask for regular usage help here,
we will close your issue without helping.

Ok? If you have an engine bug or feature request,
then please delete this message and proceed with your report. Thanks!
31 changes: 31 additions & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# This workflow will build a .NET project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net

name: .NET

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Unit Test
run: dotnet test --no-build --verbosity normal UnitTests
- name: Acceptance
run: dotnet test --no-build --verbosity normal AcceptanceTest

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ upload_to_s3.rb
*.suo
.vs/
.vscode/
tmp/

# ReSharper is a .NET coding add-in
_ReSharper*/
Expand Down Expand Up @@ -164,3 +165,8 @@ FakesAssemblies/

# JetBrains Rider
.idea

# stuff from the gh-pages branch I guess
.sass-cache/
_site/

15 changes: 0 additions & 15 deletions .slugignore

This file was deleted.

13 changes: 13 additions & 0 deletions AcceptanceTest/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[*.cs]

# NUnit2003: Consider using Assert.That(expr, Is.True) instead of Assert.IsTrue(expr)
dotnet_diagnostic.NUnit2003.severity = silent

# NUnit2005: Consider using Assert.That(actual, Is.EqualTo(expected)) instead of Assert.AreEqual(expected, actual)
dotnet_diagnostic.NUnit2005.severity = silent

# NUnit2017: Consider using Assert.That(expr, Is.Null) instead of Assert.IsNull(expr)
dotnet_diagnostic.NUnit2017.severity = silent

# NUnit2019: Consider using Assert.That(expr, Is.Not.Null) instead of Assert.IsNotNull(expr)
dotnet_diagnostic.NUnit2019.severity = silent
1 change: 0 additions & 1 deletion AcceptanceTest/.gitignore

This file was deleted.

135 changes: 66 additions & 69 deletions AcceptanceTest/ATApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,182 +5,179 @@ namespace AcceptanceTest
{
public class ATApplication : MessageCracker, IApplication
{
public event System.Action StopMeEvent;
public event System.Action? StopMeEvent;

private HashSet<KeyValuePair<string, SessionID>> clOrdIDs_ = new HashSet<KeyValuePair<string, SessionID>>();
private FileLog log_;
private readonly HashSet<KeyValuePair<string, SessionID>> _clOrdIDs = new();

public ATApplication(FileLog debugLog)
public ATApplication()
{
log_ = debugLog;
}

public void OnMessage(QuickFix.FIX40.NewOrderSingle nos, SessionID sessionID)
public void OnMessage(QuickFix.FIX40.NewOrderSingle nos, SessionID sessionId)
{
ProcessNOS(nos, sessionID);
ProcessNOS(nos, sessionId);
}

public void OnMessage(QuickFix.FIX41.NewOrderSingle nos, SessionID sessionID)
public void OnMessage(QuickFix.FIX41.NewOrderSingle nos, SessionID sessionId)
{
ProcessNOS(nos, sessionID);
ProcessNOS(nos, sessionId);
}

public void OnMessage(QuickFix.FIX42.NewOrderSingle nos, SessionID sessionID)
public void OnMessage(QuickFix.FIX42.NewOrderSingle nos, SessionID sessionId)
{
ProcessNOS(nos, sessionID);
ProcessNOS(nos, sessionId);
}

public void OnMessage(QuickFix.FIX42.SecurityDefinition message, SessionID sessionID)
public void OnMessage(QuickFix.FIX42.SecurityDefinition message, SessionID sessionId)
{
Echo(message, sessionID);
Echo(message, sessionId);
}

public void OnMessage(QuickFix.FIX43.NewOrderSingle nos, SessionID sessionID)
public void OnMessage(QuickFix.FIX43.NewOrderSingle nos, SessionID sessionId)
{
ProcessNOS(nos, sessionID);
ProcessNOS(nos, sessionId);
}

public void OnMessage(QuickFix.FIX43.SecurityDefinition message, SessionID sessionID)
public void OnMessage(QuickFix.FIX43.SecurityDefinition message, SessionID sessionId)
{
Echo(message, sessionID);
Echo(message, sessionId);
}

public void OnMessage(QuickFix.FIX44.NewOrderSingle nos, SessionID sessionID)
public void OnMessage(QuickFix.FIX44.NewOrderSingle nos, SessionID sessionId)
{
ProcessNOS(nos, sessionID);
ProcessNOS(nos, sessionId);
}

public void OnMessage(QuickFix.FIX44.SecurityDefinition message, SessionID sessionID)
public void OnMessage(QuickFix.FIX44.SecurityDefinition message, SessionID sessionId)
{
Echo(message, sessionID);
Echo(message, sessionId);
}

public void OnMessage(QuickFix.FIX44.QuoteRequest message, SessionID sessionID)
public void OnMessage(QuickFix.FIX44.QuoteRequest message, SessionID sessionId)
{
Echo(message, sessionID);
Echo(message, sessionId);
}

public void OnMessage(QuickFix.FIX50.NewOrderSingle nos, SessionID sessionID)
public void OnMessage(QuickFix.FIX50.NewOrderSingle nos, SessionID sessionId)
{
ProcessNOS(nos, sessionID);
ProcessNOS(nos, sessionId);
}

public void OnMessage(QuickFix.FIX50.SecurityDefinition message, SessionID sessionID)
public void OnMessage(QuickFix.FIX50.SecurityDefinition message, SessionID sessionId)
{
Echo(message, sessionID);
Echo(message, sessionId);
}

public void OnMessage(QuickFix.FIX50SP1.NewOrderSingle nos, SessionID sessionID)
public void OnMessage(QuickFix.FIX50SP1.NewOrderSingle nos, SessionID sessionId)
{
ProcessNOS(nos, sessionID);
ProcessNOS(nos, sessionId);
}

public void OnMessage(QuickFix.FIX50SP1.SecurityDefinition message, SessionID sessionID)
public void OnMessage(QuickFix.FIX50SP1.SecurityDefinition message, SessionID sessionId)
{
Echo(message, sessionID);
Echo(message, sessionId);
}

public void OnMessage(QuickFix.FIX50SP2.NewOrderSingle nos, SessionID sessionID)
public void OnMessage(QuickFix.FIX50SP2.NewOrderSingle nos, SessionID sessionId)
{
ProcessNOS(nos, sessionID);
ProcessNOS(nos, sessionId);
}

public void OnMessage(QuickFix.FIX50SP2.SecurityDefinition message, SessionID sessionID)
public void OnMessage(QuickFix.FIX50SP2.SecurityDefinition message, SessionID sessionId)
{
Echo(message, sessionID);
Echo(message, sessionId);
}

protected void Echo(Message message, SessionID sessionID)
private static void Echo(Message message, SessionID sessionId)
{
Message echo = new Message(message);
Session.SendToTarget(echo, sessionID);
Message echo = new(message);
Session.SendToTarget(echo, sessionId);
}

protected void ProcessNOS(Message message, SessionID sessionID)
private void ProcessNOS(Message message, SessionID sessionId)
{
Message echo = new Message(message);
Message echo = new(message);

bool possResend = false;
if (message.Header.IsSetField(QuickFix.Fields.Tags.PossResend))
possResend = message.Header.GetBoolean(QuickFix.Fields.Tags.PossResend);

KeyValuePair<string, SessionID> pair = new KeyValuePair<string, SessionID>(message.GetString(QuickFix.Fields.Tags.ClOrdID), sessionID);
if (possResend && clOrdIDs_.Contains(pair))
KeyValuePair<string, SessionID> pair = new(message.GetString(QuickFix.Fields.Tags.ClOrdID), sessionId);
if (possResend && _clOrdIDs.Contains(pair))
return;
clOrdIDs_.Add(pair);
_clOrdIDs.Add(pair);

Session.SendToTarget(echo, sessionID);
Session.SendToTarget(echo, sessionId);
}


public void OnMessage(QuickFix.FIX41.News news, SessionID sessionID) { ProcessNews(news, sessionID); }
public void OnMessage(QuickFix.FIX42.News news, SessionID sessionID) { ProcessNews(news, sessionID); }
public void OnMessage(QuickFix.FIX43.News news, SessionID sessionID) { ProcessNews(news, sessionID); }
public void OnMessage(QuickFix.FIX44.News news, SessionID sessionID) { ProcessNews(news, sessionID); }
public void OnMessage(QuickFix.FIX50.News news, SessionID sessionID) { ProcessNews(news, sessionID); }
public void OnMessage(QuickFix.FIX50SP1.News news, SessionID sessionID) { ProcessNews(news, sessionID); }
public void OnMessage(QuickFix.FIX50SP2.News news, SessionID sessionID) { ProcessNews(news, sessionID); }
public void OnMessage(QuickFix.FIX41.News news, SessionID sessionId) { ProcessNews(news, sessionId); }
public void OnMessage(QuickFix.FIX42.News news, SessionID sessionId) { ProcessNews(news, sessionId); }
public void OnMessage(QuickFix.FIX43.News news, SessionID sessionId) { ProcessNews(news, sessionId); }
public void OnMessage(QuickFix.FIX44.News news, SessionID sessionId) { ProcessNews(news, sessionId); }
public void OnMessage(QuickFix.FIX50.News news, SessionID sessionId) { ProcessNews(news, sessionId); }
public void OnMessage(QuickFix.FIX50SP1.News news, SessionID sessionId) { ProcessNews(news, sessionId); }
public void OnMessage(QuickFix.FIX50SP2.News news, SessionID sessionId) { ProcessNews(news, sessionId); }

public void ProcessNews(QuickFix.Message msg, SessionID sessionID)
private void ProcessNews(Message msg, SessionID sessionId)
{
if (msg.IsSetField(QuickFix.Fields.Tags.Headline) && (msg.GetString(QuickFix.Fields.Tags.Headline) == "STOPME"))
{
if (this.StopMeEvent != null)
StopMeEvent();
}
else
Echo(msg, sessionID);
Echo(msg, sessionId);
}

public void OnMessage(QuickFix.FIX44.TradeCaptureReportRequest msg, SessionID sessionID)
public void OnMessage(QuickFix.FIX44.TradeCaptureReportRequest msg, SessionID sessionId)
{
// do nothing, just swallow it.
}

#region Application Methods

public void OnCreate(SessionID sessionID)
public void OnCreate(SessionID sessionId)
{
Session session = Session.LookupSession(sessionID);
Session? session = Session.LookupSession(sessionId);

// Hey QF/N users, don't do this in a real app.
if (null != session)
session.Reset("AT Session Reset");
session?.Reset("AT Session Reset");
}

public void OnLogout(SessionID sessionID)
public void OnLogout(SessionID sessionId)
{
clOrdIDs_.Clear();
_clOrdIDs.Clear();
}

public void OnLogon(SessionID sessionID)
public void OnLogon(SessionID sessionId)
{ }

public void FromApp(Message message, SessionID sessionID)
public void FromApp(Message message, SessionID sessionId)
{
try
{
string msgType = message.Header.GetString(QuickFix.Fields.Tags.MsgType);
//string msgType = message.Header.GetString(QuickFix.Fields.Tags.MsgType);
// log_.OnEvent("Got message " + msgType);
// System.Console.WriteLine("===got message " + msgType);

Crack(message, sessionID);
Crack(message, sessionId);
}
catch (QuickFix.UnsupportedMessageType)
catch (UnsupportedMessageType)
{
throw;
}
catch (System.Exception e)
{
log_.OnEvent("FromApp: " + e.ToString() + " while processing msg (" + message.ToString() + ")");
Session.LookupSession(sessionId)?.Log.OnEvent($"Exception during FromApp: {e}\n while processing msg ({message})");
}
}

public void FromAdmin(Message message, SessionID sessionID)
public void FromAdmin(Message message, SessionID sessionId)
{ }

public void ToAdmin(Message message, SessionID sessionID) { }
public void ToApp(Message message, SessionID sessionID) { }
public void ToAdmin(Message message, SessionID sessionId) { }
public void ToApp(Message message, SessionID sessionId) { }

#endregion
}
Expand Down
Loading

0 comments on commit 95a786f

Please sign in to comment.