FastTunnel/FastTunnel.Client/Program.cs
2022-07-10 22:34:13 +08:00

48 lines
1.5 KiB
C#

// Licensed under the Apache License, Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// https://github.com/FastTunnel/FastTunnel/edit/v2/LICENSE
// Copyright (c) 2019 Gui.H
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Serilog;
using FastTunnel.Core.Extensions;
namespace FastTunnel.Client;
class Program
{
public static void Main(string[] args)
{
try
{
CreateHostBuilder(args).Build().Run();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.UseSerilog((context, services, loggerConfiguration) =>
{
loggerConfiguration.ReadFrom.Configuration(context.Configuration)
.ReadFrom.Services(services)
.Enrich.FromLogContext()
.WriteTo.Console();
})
.UseWindowsService()
.ConfigureServices((hostContext, services) =>
{
// -------------------FastTunnel START------------------
services.AddFastTunnelClient(hostContext.Configuration.GetSection("FastTunnel"));
// -------------------FastTunnel EDN--------------------
});
}