Skip to content

Commit

Permalink
Merge pull request connamara#697 from ABSJ415/new-config-value-for-ig…
Browse files Browse the repository at this point in the history
…nore-proxy

Adding new session settings for ignoring proxy.
  • Loading branch information
gbirchmeier authored Feb 12, 2024
2 parents e710523 + 683205d commit f75123b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions Examples/TradeClient/tradeclient.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ UseDataDictionary=Y
DataDictionary=../../spec/fix/FIX44.xml
SocketConnectHost=127.0.0.1
SocketConnectPort=5001
SocketIgnoreProxy=Y
LogoutTimeout=5
ResetOnLogon=Y
ResetOnDisconnect=Y
Expand Down
1 change: 1 addition & 0 deletions QuickFIXn/SessionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public class SessionSettings
public const string RESETSEQUENCE_MESSAGE_REQUIRES_ORIGSENDINGTIME = "RequiresOrigSendingTime";
public const string CHECK_LATENCY = "CheckLatency";
public const string MAX_LATENCY = "MaxLatency";
public const string SOCKET_IGNORE_PROXY = "SocketIgnoreProxy";

public const string SSL_ENABLE = "SSLEnable";
public const string SSL_SERVERNAME = "SSLServerName";
Expand Down
11 changes: 11 additions & 0 deletions QuickFIXn/SocketSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ public class SocketSettings : ICloneable
/// </value>
public int? SocketSendTimeout { get; internal set; }

/// <summary>
/// Gets a value that specifies whether the proxy server settings should be ignored.
/// </summary>
/// <value>
/// <c>false</c> if connection should use proxy; otherwise for ignoring proxy, <c>true</c>. The default is <c>false</c>.
/// </value>
public bool SocketIgnoreProxy { get; internal set; }
#endregion

#region SSL Settings
Expand Down Expand Up @@ -149,6 +156,7 @@ public SocketSettings()
CheckCertificateRevocation = true;
RequireClientCertificate = true;
SocketNodelay = true;
SocketIgnoreProxy = false;
}

/// <summary>
Expand All @@ -161,6 +169,9 @@ public SocketSettings()
/// <param name="dictionary">the dictionary to read the settings from</param>
public void Configure(QuickFix.Dictionary dictionary)
{
if (dictionary.Has(SessionSettings.SOCKET_IGNORE_PROXY))
SocketIgnoreProxy = dictionary.GetBool(SessionSettings.SOCKET_IGNORE_PROXY);

if (dictionary.Has(SessionSettings.SOCKET_NODELAY))
SocketNodelay = dictionary.GetBool(SessionSettings.SOCKET_NODELAY);

Expand Down
9 changes: 7 additions & 2 deletions QuickFIXn/Transport/StreamFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,13 @@ public static class StreamFactory
/// <returns>an opened and initiated stream which can be read and written to</returns>
public static Stream CreateClientStream(IPEndPoint endpoint, SocketSettings settings, ILog logger)
{
// If system has configured a proxy for this config, use it.
Socket? socket = CreateTunnelThruProxy(endpoint.Address.ToString(), endpoint.Port);
Socket? socket = null;

if (!settings.SocketIgnoreProxy)
{
// If system has configured a proxy for this config, use it.
socket = CreateTunnelThruProxy(endpoint.Address.ToString(), endpoint.Port);
}

// No proxy. Set up a regular socket.
if (socket is null)
Expand Down
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ What's New
* #711 - fix explicit 0.0.0.0 address binding (bohdanstefaniuk)
* #823 - get rid of IOIQty enums in FIX5 DDs, allow free string (gbirchmeier)
* #786 - rewrite HttpServer: better HTML, no crash on errors (gbirchmeier)
* #697 - new SocketIgnoreProxy setting (ABSJ415)

### v1.11.2:
* same as v1.11.1, but I fixed the readme in the pushed nuget packages
Expand Down
3 changes: 3 additions & 0 deletions UnitTests/SocketSettingsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public void DefaultValues()
{
SocketSettings socketSettings = new SocketSettings();

Assert.IsFalse(socketSettings.SocketIgnoreProxy);
Assert.IsTrue(socketSettings.SocketNodelay);
Assert.IsNull(socketSettings.SocketReceiveBufferSize);
Assert.IsNull(socketSettings.SocketSendBufferSize);
Expand All @@ -31,6 +32,7 @@ public void DefaultValues()
private Dictionary BaseTestDict()
{
Dictionary dict = new Dictionary();
dict.SetBool(SessionSettings.SOCKET_IGNORE_PROXY, false);
dict.SetBool(SessionSettings.SOCKET_NODELAY, false);
dict.SetLong(SessionSettings.SOCKET_RECEIVE_BUFFER_SIZE, 1);
dict.SetLong(SessionSettings.SOCKET_SEND_BUFFER_SIZE, 2);
Expand All @@ -54,6 +56,7 @@ public void Configure()
SocketSettings socketSettings = new SocketSettings();
socketSettings.Configure(BaseTestDict());

Assert.IsFalse(socketSettings.SocketIgnoreProxy);
Assert.IsFalse(socketSettings.SocketNodelay);
Assert.AreEqual(1, socketSettings.SocketReceiveBufferSize);
Assert.AreEqual(2, socketSettings.SocketSendBufferSize);
Expand Down

0 comments on commit f75123b

Please sign in to comment.