Skip to content

Commit

Permalink
added ProxyProtocolPipelineFilterFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
kerryjiang committed Aug 10, 2024
1 parent 08e600c commit 2b191a2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/SuperSocket.ProtoBase/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Buffers;
using System.Text;
using System.Buffers.Text;
using SuperSocket.ProtoBase.ProxyProtocol;

namespace SuperSocket.ProtoBase
{
Expand Down Expand Up @@ -147,5 +148,11 @@ public static int Write(this IBufferWriter<byte> writer, ReadOnlySpan<char> text

return totalBytes;
}

public static IPipelineFilterFactory<TPackageInfo> UseProxyProtocol<TPackageInfo>(this IPipelineFilterFactory<TPackageInfo> pipelineFilterFactory)
where TPackageInfo : class
{
return new ProxyProtocolPipelineFilterFactory<TPackageInfo>(pipelineFilterFactory);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Buffers;

namespace SuperSocket.ProtoBase.ProxyProtocol
{
public class ProxyProtocolPipelineFilterFactory<TPackageInfo> : IPipelineFilterFactory<TPackageInfo>
where TPackageInfo : class
{
private readonly IPipelineFilterFactory<TPackageInfo> _pipelineFilterFactory;

public ProxyProtocolPipelineFilterFactory(IPipelineFilterFactory<TPackageInfo> pipelineFilterFactory)
{
_pipelineFilterFactory = pipelineFilterFactory;
}

public IPipelineFilter<TPackageInfo> Create(object client)
{
return new ProxyProtocolPipelineFilter<TPackageInfo>(_pipelineFilterFactory.Create(client));
}
}
}

0 comments on commit 2b191a2

Please sign in to comment.