You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
this proxy is not really the right tool to do that: when used as a TCP proxy, it just forwards the content of the TCP connection to the remote endpoint without reading it. To intercept HTTP headers, you would need to parse this content.
It's likely there are products out there that already do what you want. What's your use case, and where do you need to run it?
Yes yes you right, but I want to do this for a project :D
I tried to do this, but I don't know why it don't works, I'm not very good with Async and Wait programming in C# :/
I explain you what I want to do, I would like to make a TCP proxy that redirect flow depending on user, so I need to parse Authorization header, getting user, and with this user redirecting to the good IP :)
@clintnetwork did you manage to get the headers? O want to do something like that.
Whenever I read data from the socket, the app erases the socket data and does not forward it to the output.
The project was developed on our side because we needed something very simple for both TCP and UDP:
We needed to support ipv6 trafic to a server that only had ipv4
We needed to forward trafic from a game with hardcoded ip addresses to another server.
Both these requirements don't require modifying the headers even if I agree that it would be very useful in the general case, for HTTP requests.
The proxy currently doesn't try to understand protocols, which is actually very useful if you are not forwarding HTTP trafic and we probably want the TCP forwarder this way.
To read and modify headers, the best option is probably to add a new forwarder type configurable in config, specifically for HTTP, using kestrel as a webserver to parse the requests and then forward them. It would enable scenarios like HTTPS to HTTP forwarding or even simple loadbalancing.
Activity
Falanwe commentedon Jul 19, 2019
Hi,
this proxy is not really the right tool to do that: when used as a TCP proxy, it just forwards the content of the TCP connection to the remote endpoint without reading it. To intercept HTTP headers, you would need to parse this content.
It's likely there are products out there that already do what you want. What's your use case, and where do you need to run it?
imclint21 commentedon Jul 19, 2019
Yes yes you right, but I want to do this for a project :D
I tried to do this, but I don't know why it don't works, I'm not very good with Async and Wait programming in C# :/
I explain you what I want to do, I would like to make a TCP proxy that redirect flow depending on user, so I need to parse Authorization header, getting user, and with this user redirecting to the good IP :)
imclint21 commentedon Jul 19, 2019
Do you have a telegram/discord/skype or something else @Falanwe ?
hudsonventura commentedon Jun 17, 2021
@clintnetwork did you manage to get the headers? O want to do something like that.
Whenever I read data from the socket, the app erases the socket data and does not forward it to the output.
hudsonventura commentedon Jun 19, 2021
@clintnetwork maybe you'll like the line 162 of https://github.com/microsoft/referencesource/blob/master/mscorlib/system/io/stream.cs
Code:
private async Task CopyToAsyncInternal(Stream source, Stream destination)
{
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = await source.ReadAsync(buffer, 0, buffer.Length).ConfigureAwait(false)) != 0)
{
Console.WriteLine(Encoding.ASCII.GetString(buffer, 0, bytesRead));
await destination.WriteAsync(buffer, 0, bytesRead).ConfigureAwait(false);
}
}
jmderuty commentedon Jan 25, 2022
Sorry, it has been some time.
The project was developed on our side because we needed something very simple for both TCP and UDP:
Both these requirements don't require modifying the headers even if I agree that it would be very useful in the general case, for HTTP requests.
The proxy currently doesn't try to understand protocols, which is actually very useful if you are not forwarding HTTP trafic and we probably want the TCP forwarder this way.
To read and modify headers, the best option is probably to add a new forwarder type configurable in config, specifically for HTTP, using kestrel as a webserver to parse the requests and then forward them. It would enable scenarios like HTTPS to HTTP forwarding or even simple loadbalancing.