forked from BoBiene/ReverseTunnel.Yarp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
37 lines (29 loc) · 1.62 KB
/
Program.cs
File metadata and controls
37 lines (29 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using UFX.Relay.Tunnel;
using UFX.Relay.Tunnel.Forwarder;
Console.WriteLine(@"
███████╗███████╗██████╗ ██╗ ██╗███████╗██████╗
██╔════╝██╔════╝██╔══██╗██║ ██║██╔════╝██╔══██╗
███████╗█████╗ ██████╔╝██║ ██║█████╗ ██████╔╝
╚════██║██╔══╝ ██╔══██╗╚██╗ ██╔╝██╔══╝ ██╔══██╗
███████║███████╗██║ ██║ ╚████╔╝ ███████╗██║ ██║
╚══════╝╚══════╝╚═╝ ╚═╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝
UFX.Relay Sample Server started
");
var builder = WebApplication.CreateBuilder(args);
TunnelPathPrefixTransformer prefixTransformer = new("ufx");
builder.Services.AddTunnelForwarder(options =>
{
options.DefaultTunnelId = "123";
options.TunnelIdFromContext = prefixTransformer.GetTunnelIdFromContext;
options.Transformer = context =>
{
// Remove /ufx/{tunnelId} from the request path before forwarding
context.RequestTransforms.Add(prefixTransformer);
};
});
var app = builder.Build();
app.MapTunnelHost();
app.MapTunnelForwarder();
app.MapGet("/", () => builder.Environment.ApplicationName);
app.MapGet("/server", () => "Hello from Server");
await app.RunAsync();