Skip to content

Commit

Permalink
loaded more proxy info for proxy protocol v1
Browse files Browse the repository at this point in the history
  • Loading branch information
kerryjiang committed Aug 11, 2024
1 parent 6f3ee11 commit e512f75
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
using System;
using System.Buffers;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Text;
using Microsoft.VisualBasic;

namespace SuperSocket.ProtoBase.ProxyProtocol
{
Expand Down Expand Up @@ -35,9 +33,15 @@ public override bool Process(TPackageInfo package, object filterContext, ref Seq
var proxyLineReader = new SequenceReader<byte>(proxyLineSequence);

var proxyLine = proxyLineReader.ReadString();

LoadProxyInfo(filterContext as ProxyInfo, proxyLine, 12, 13);


var proxyInfo = filterContext as ProxyInfo;

LoadProxyInfo(proxyInfo, proxyLine, 12, 13);

proxyInfo.Version = 1;
proxyInfo.Command = ProxyCommand.PROXY;
proxyInfo.ProtocolType = ProtocolType.Tcp;

return true;
}

Expand Down
4 changes: 3 additions & 1 deletion test/SuperSocket.Tests/ProxyProtocolHostConfigurator.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
Expand Down Expand Up @@ -54,7 +56,7 @@ public Socket CreateClient()
public async ValueTask<Stream> GetClientStream(Socket socket)
{
var stream = await _innerHostConfigurator.GetClientStream(socket);

await stream.WriteAsync(_proxyProtocolV2_IPV4_SampleData, 0, _proxyProtocolV2_IPV4_SampleData.Length);
await stream.FlushAsync();

Expand Down

0 comments on commit e512f75

Please sign in to comment.