public static IApplicationBuilder UseLocalTunnel( this IApplicationBuilder app, string subdomain ) { var services = app.GetServiceProvider(); var tunnelClient = services.GetRequiredService <LocaltunnelClient>(); var tunnel = tunnelClient.OpenAsync ( handle => { var options = new ProxiedHttpTunnelOptions() { Host = "localhost", Port = 5100, ReceiveBufferSize = 10 }; return(new ProxiedHttpTunnelConnection(handle, options)); }, subdomain: subdomain, CancellationToken.None ).Result; tunnel.StartAsync(); var tunnelUrl = tunnel.Information.Url; var tunnelId = tunnel.Information.Id; Log.Information("Tunnel URL: {TunnelUrl}", tunnelUrl); Log.Information("Tunnel URL: {TunnelId}", tunnelId); return(app); }
private Task RunAsync(HttpProxyConfiguration configuration, CancellationToken cancellationToken) { var options = new ProxiedHttpTunnelOptions { Host = configuration.Host, ReceiveBufferSize = configuration.ReceiveBufferSize, Port = configuration.Port, }; if (configuration.Passthrough) { options.RequestProcessor = null; } return(CliBootstrapper.RunAsync(configuration, x => new ProxiedHttpTunnelConnection(x, options), cancellationToken)); }
public Tunnel CreateTunnel( string subdomain, int port ) { var tunnelClient = new LocaltunnelClient(); Log.Information( "Creating tunnel for subdomain {Subdomain}:{Port}", subdomain, port ); var tunnel = tunnelClient.OpenAsync( handle => { var options = new ProxiedHttpTunnelOptions() { Host = "localhost", Port = port, ReceiveBufferSize = 100 }; return(new ProxiedHttpTunnelConnection(handle, options)); }, subdomain: subdomain, CancellationToken.None ) .WaitAndUnwrapException(); tunnel.StartAsync().WaitAndUnwrapException(); var tunnelUrl = tunnel.Information.Url; var tunnelId = tunnel.Information.Id; Log.Information("Tunnel URL: {TunnelUrl}", tunnelUrl); Log.Information("Tunnel URL: {TunnelId}", tunnelId); return(tunnel); }