angelobreuer / localtunnel.net

.NET implementation of a tunnel client for localtunnel.me.
MIT License
125 stars 31 forks source link

Need Localtunnel Server with .Net (C#) #12

Closed zobayerhossainmamun closed 2 years ago

zobayerhossainmamun commented 2 years ago

I got the localtunnel server with nodejs. But, I need localtunnel server with c#.

angelobreuer commented 2 years ago

Hello @zobayerhossainmamun , see #11.

If there is really a need for a .NET implementation, and if there are multiple users that could benefit from a .NET implementation, then it could be worth to implement a .NET version.

Do you have any use cases where a .NET implementation can provide something that the NodeJS implementation is unable to do? Also I would have to ask the owner of the NodeJS server, because he got the main idea. I think then we could also provide WebSocket support. Note that the NodeJS server is used in public and hosted on a server, that the owner has to pay for. I do not have the resources to provide a public-hosted server.

angelobreuer commented 2 years ago

cc @savage8811

zobayerhossainmamun commented 2 years ago

Actually, I'm using dot net client version. So, If I got server also with dotnet. It's better for me. I don't need to use nodejs with this.

angelobreuer commented 2 years ago

I see. I've collected a couple of things that a new .NET implementation could improve over the NodeJS version:

I will create an issue in the home repo of the localtunnel server, to ask the owner whether he would like to have a .NET based server implementation.

zobayerhossainmamun commented 2 years ago

Okay Thanks.

zobayerhossainmamun commented 2 years ago

It's very helpful for us if you are able to public .Net version soon.

angelobreuer commented 2 years ago

There is an alpha version available at https://github.com/angelobreuer/localtunnel-client/tree/feat/server/src/Localtunnel.Server

The appsettings.json should look like this:

{
  "Dns": {
    "Zone": "localtunnel.example.com"
  },
  "PortAllocation": {
    "BindAddress": "Any" // 'IPv4Only', 'IPv6Only', 'Any' (Dual Stack)
  }
}

The latest Visual Studio preview or .NET SDK 6.0.200 is required for compilation.

Currently, HTTP/HTTPS is supported, HTTP/1.1 on proxy-side, and HTTP/1.1, HTTP/2.0, and HTTP/3.0 on server-side experimentally (can be enabled using appsettings.json, see ASP.NET). WebSockets are currently not supported.

zobayerhossainmamun commented 2 years ago

Thanks a lot for your help.

zobayerhossainmamun commented 2 years ago

I'm surprised for your quick update. We are small developers easily can learn more for those developer like you. I'm really thankful to you. May god gives you more power for nice work.

savage8811 commented 2 years ago

Wow! Really nice, TY @angelobreuer

angelobreuer commented 2 years ago

I am currently working on a full overhaul of the client to support WebSockets, HTTP/1.1, and HTTP/2.0. The server should now be ready for HTTP/1.1, HTTP/2.0, HTTP/3.0, but not WebSockets. I also reworked the passthrough and "non-passthrough" modes. We now support full request parsing using Kestrel's HTTP parser. I think in the future localtunnel could support HTTP+QUIC (aka HTTP/3.0). Now it is more easy to access the tunnel API for server-side ASP.NET (for example setting up a tunnel and changing headers, then passing it to ASP.NET).

I think as this is no longer a "localtunnel-client", this repository will be renamed to "localtunnel.net". The NuGet package name will stay the same.

A preview is available as a docker container and can be run:

docker run --env Dns__Zone=yourdomain.com -p 80:80 angelobreuer/localtunnel-server

docker run -it --env Dns__Zone=localtunnel.net --network host angelobreuer/localtunnel-server
samirsommaior commented 2 years ago

Congratulations on your work @angelobreuer. Are you working on the implementation of WebSockets? Do you need any specific help?

angelobreuer commented 2 years ago

Thank you @samirsommaior. I started working today at the implementation of WebSockets on the server-side, which seems to work (https://github.com/angelobreuer/localtunnel.net/commit/58acaac5bea0ac8d15222cbaf2a4bcc73a93fa16). I will add client support for WebSockets now, currently, it only works in passthrough mode (as the client does not forward Upgrade connections correctly). I've tried to make it as abstract as possible, so that not only WebSocket protocols work but all HTTP protocols that use the Upgrade handshake method. I'll let you know if I need any help.

angelobreuer commented 2 years ago

Full WebSocket support implemented in https://github.com/angelobreuer/localtunnel.net/commit/8ca3252eff189658bafd7ddd17ba8b5d17c9935e

angelobreuer commented 2 years ago

Closing as server support entered the main branch