diff --git a/MetingJS.Server.Fc/.config/dotnet-tools.json b/MetingJS.Server.Fc/.config/dotnet-tools.json new file mode 100644 index 0000000..4ab7ed2 --- /dev/null +++ b/MetingJS.Server.Fc/.config/dotnet-tools.json @@ -0,0 +1,12 @@ +{ + "version": 1, + "isRoot": true, + "tools": { + "dotnet-ef": { + "version": "3.1.3", + "commands": [ + "dotnet-ef" + ] + } + } +} \ No newline at end of file diff --git a/MetingJS.Server.Fc/FcRemoteEntrypoint.cs b/MetingJS.Server.Fc/FcRemoteEntrypoint.cs new file mode 100644 index 0000000..ac6df56 --- /dev/null +++ b/MetingJS.Server.Fc/FcRemoteEntrypoint.cs @@ -0,0 +1,13 @@ +using Aliyun.Serverless.Core.Http; +using Microsoft.AspNetCore.Hosting; + +namespace MetingJS.Server.Fc +{ + public class FcRemoteEntrypoint : FcHttpEntrypoint + { + protected override void Init(IWebHostBuilder builder) + { + builder.UseStartup(); + } + } +} diff --git a/MetingJS.Server.Fc/MetingJS.Server.Fc.csproj b/MetingJS.Server.Fc/MetingJS.Server.Fc.csproj new file mode 100644 index 0000000..5caf0fc --- /dev/null +++ b/MetingJS.Server.Fc/MetingJS.Server.Fc.csproj @@ -0,0 +1,24 @@ + + + + netcoreapp2.1 + + + + TRACE;NETCORE21 + + + + TRACE;NETCORE21 + + + + + + + + + + + + diff --git a/MetingJS.Server.Fc/MetingJS.Server.Fc.csproj.user b/MetingJS.Server.Fc/MetingJS.Server.Fc.csproj.user new file mode 100644 index 0000000..6434c40 --- /dev/null +++ b/MetingJS.Server.Fc/MetingJS.Server.Fc.csproj.user @@ -0,0 +1,10 @@ + + + + ProjectDebugger + + + MetingJS.Server.Fc + FolderProfile + + \ No newline at end of file diff --git a/MetingJS.Server.Fc/Program.cs b/MetingJS.Server.Fc/Program.cs new file mode 100644 index 0000000..4c22d09 --- /dev/null +++ b/MetingJS.Server.Fc/Program.cs @@ -0,0 +1,23 @@ +using System; +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; + +namespace MetingJS.Server.Fc +{ + public class Program + { + // public static void Main(string[] args) + // { + // CreateWebHostBuilder(args).Build().Run(); + // } + // + // public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + // WebHost.CreateDefaultBuilder(args) + // .UseStartup(); + + public static void Main(string[] args) + { + Console.WriteLine("请不要这样启动"); + } + } +} diff --git a/MetingJS.Server.Fc/Properties/PublishProfiles/FolderProfile.pubxml b/MetingJS.Server.Fc/Properties/PublishProfiles/FolderProfile.pubxml new file mode 100644 index 0000000..d3fb199 --- /dev/null +++ b/MetingJS.Server.Fc/Properties/PublishProfiles/FolderProfile.pubxml @@ -0,0 +1,22 @@ + + + + + FileSystem + FileSystem + Release + Any CPU + + True + False + netcoreapp2.1 + linux-x64 + 783cd8db-2b6e-477b-a57c-f603d4acfc64 + false + bin\Release\netcoreapp2.1\publish\ + True + + \ No newline at end of file diff --git a/MetingJS.Server.Fc/Properties/PublishProfiles/FolderProfile.pubxml.user b/MetingJS.Server.Fc/Properties/PublishProfiles/FolderProfile.pubxml.user new file mode 100644 index 0000000..cdf8b4a --- /dev/null +++ b/MetingJS.Server.Fc/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -0,0 +1,11 @@ + + + + + + <_PublishTargetUrl>D:\MonoLogueChi\Documents\GitHub\MetingJS.Server\MetingJS.Server.Fc\bin\Release\netcoreapp2.1\publish\ + + \ No newline at end of file diff --git a/MetingJS.Server.Fc/appsettings.Development.json b/MetingJS.Server.Fc/appsettings.Development.json new file mode 100644 index 0000000..aec8334 --- /dev/null +++ b/MetingJS.Server.Fc/appsettings.Development.json @@ -0,0 +1,24 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug", + "System": "Information", + "Microsoft": "Information" + } + }, + "AllowedHosts": "*", + "WithOrigins": [ + "*" + ], + "Urls": "http://localhost:5000", + "Url": "", + "Replace": { + "Url": [ + [ "http://", "https://" ], + [ "ws.stream.qqmusic.qq.com", "dl.stream.qqmusic.qq.com" ] + ], + "Pic": [ + [ "http://", "https://" ] + ] + } +} diff --git a/MetingJS.Server.Fc/appsettings.json b/MetingJS.Server.Fc/appsettings.json new file mode 100644 index 0000000..4a02f29 --- /dev/null +++ b/MetingJS.Server.Fc/appsettings.json @@ -0,0 +1,24 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*", + "WithOrigins": [ + "*" + ], + "Url": "", + "DefaultServerProvider": "Tencent", + "Replace": { + "Url": [ + [ "http://", "https://" ], + [ "ws.stream.qqmusic.qq.com", "dl.stream.qqmusic.qq.com" ] + ], + "Pic": [ + [ "http://", "https://" ] + ] + } +} \ No newline at end of file diff --git a/MetingJS.Server.sln b/MetingJS.Server.sln index 8f1e7ff..64081c7 100644 --- a/MetingJS.Server.sln +++ b/MetingJS.Server.sln @@ -10,7 +10,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MetingJS.Server.Fc", "MetingJS.Server.Fc\MetingJS.Server.Fc.csproj", "{9902B01C-7372-42A8-B69A-C3823761AD10}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MetingJS.Server.Fc", "MetingJS.Server.Fc\MetingJS.Server.Fc.csproj", "{783CD8DB-2B6E-477B-A57C-F603D4ACFC64}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -25,12 +25,12 @@ Global {A1955290-E9A3-4572-B250-76C55F88B92D}.Linux|Any CPU.Build.0 = Linux|Any CPU {A1955290-E9A3-4572-B250-76C55F88B92D}.Release|Any CPU.ActiveCfg = Release|Any CPU {A1955290-E9A3-4572-B250-76C55F88B92D}.Release|Any CPU.Build.0 = Release|Any CPU - {9902B01C-7372-42A8-B69A-C3823761AD10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9902B01C-7372-42A8-B69A-C3823761AD10}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9902B01C-7372-42A8-B69A-C3823761AD10}.Linux|Any CPU.ActiveCfg = Debug|Any CPU - {9902B01C-7372-42A8-B69A-C3823761AD10}.Linux|Any CPU.Build.0 = Debug|Any CPU - {9902B01C-7372-42A8-B69A-C3823761AD10}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9902B01C-7372-42A8-B69A-C3823761AD10}.Release|Any CPU.Build.0 = Release|Any CPU + {783CD8DB-2B6E-477B-A57C-F603D4ACFC64}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {783CD8DB-2B6E-477B-A57C-F603D4ACFC64}.Debug|Any CPU.Build.0 = Debug|Any CPU + {783CD8DB-2B6E-477B-A57C-F603D4ACFC64}.Linux|Any CPU.ActiveCfg = Debug|Any CPU + {783CD8DB-2B6E-477B-A57C-F603D4ACFC64}.Linux|Any CPU.Build.0 = Debug|Any CPU + {783CD8DB-2B6E-477B-A57C-F603D4ACFC64}.Release|Any CPU.ActiveCfg = Release|Any CPU + {783CD8DB-2B6E-477B-A57C-F603D4ACFC64}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/MetingJS.Server/Controllers/MusicController.cs b/MetingJS.Server/Controllers/MusicController.cs index 289d492..949ef11 100644 --- a/MetingJS.Server/Controllers/MusicController.cs +++ b/MetingJS.Server/Controllers/MusicController.cs @@ -22,6 +22,7 @@ public MusicController(Meting meting, AppSettings settings) [HttpGet] public ActionResult Get([FromQuery] QueryModel query) { + if (string.IsNullOrEmpty(query.Id)) return BadRequest(); var meting = query.Server.Equals(_settings.DefaultServerProvider) diff --git a/MetingJS.Server/MetingJS.Server.csproj b/MetingJS.Server/MetingJS.Server.csproj index 198f85b..019f43b 100644 --- a/MetingJS.Server/MetingJS.Server.csproj +++ b/MetingJS.Server/MetingJS.Server.csproj @@ -1,7 +1,7 @@ - + - netcoreapp3.1 + netcoreapp3.1;netcoreapp2.1 Debug;Release;Linux @@ -15,8 +15,23 @@ TRACE;LINUX - + + NETCORE31 + + + + NETCORE21 + + + + + + + + + + diff --git a/MetingJS.Server/MetingJS.Server.csproj.user b/MetingJS.Server/MetingJS.Server.csproj.user index e7e745d..468b6bf 100644 --- a/MetingJS.Server/MetingJS.Server.csproj.user +++ b/MetingJS.Server/MetingJS.Server.csproj.user @@ -11,6 +11,7 @@ False MetingJS.Server FolderProfile + netcoreapp2.1 ProjectDebugger diff --git a/MetingJS.Server/Program.cs b/MetingJS.Server/Program.cs index 33304a4..050e2b4 100644 --- a/MetingJS.Server/Program.cs +++ b/MetingJS.Server/Program.cs @@ -1,29 +1,49 @@ -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Hosting; -#if LINUX -using System.IO; -#endif - -namespace MetingJS.Server -{ - public class Program - { - public static void Main(string[] args) - { - CreateHostBuilder(args).Build().Run(); - } - - public static IHostBuilder CreateHostBuilder(string[] args) => - Host.CreateDefaultBuilder(args) - .ConfigureWebHostDefaults(webBuilder => - { - webBuilder.UseStartup().ConfigureKestrel((context, options) => - { -#if LINUX - if (File.Exists("/tmp/metingJS.Server.sock")) File.Delete("/tmp/metingJS.Server.sock"); - options.ListenUnixSocket("/tmp/metingJS.Server.sock"); -#endif - }); - }); - } -} +#if NETCORE31 +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; +#elif NETCORE21 +using Microsoft.AspNetCore; +using Microsoft.AspNetCore.Hosting; +#endif + +#if LINUX +using System.IO; +#endif + +namespace MetingJS.Server +{ + public class Program + { +#if NETCORE21 + public static void Main(string[] args) + { + CreateWebHostBuilder(args).Build().Run(); + } + + public static IWebHostBuilder CreateWebHostBuilder(string[] args) => + WebHost.CreateDefaultBuilder(args) + .UseStartup(); +#elif NETCORE31 + + public static void Main(string[] args) + { + CreateHostBuilder(args).Build().Run(); + } + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup().ConfigureKestrel((context, options) => + { +#if LINUX + if (File.Exists("/tmp/metingJS.Server.sock")) File.Delete("/tmp/metingJS.Server.sock"); + options.ListenUnixSocket("/tmp/metingJS.Server.sock"); +#endif + }); + }); +#endif + } + +} + diff --git a/MetingJS.Server/Startup.cs b/MetingJS.Server/Startup.cs index 06ff825..5cd55e5 100644 --- a/MetingJS.Server/Startup.cs +++ b/MetingJS.Server/Startup.cs @@ -1,3 +1,4 @@ +#if NETCORE31 using MetingJS.Server.Models; using MetingJS.Server.Utils; using Microsoft.AspNetCore.Builder; @@ -41,3 +42,52 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, AppSetti } } } + +#endif + +#if NETCORE21 +using MetingJS.Server.Models; +using MetingJS.Server.Utils; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; + +namespace MetingJS.Server +{ + public class Startup + { + public Startup(IConfiguration configuration) + { + Configuration = configuration; + } + + public IConfiguration Configuration { get; } + + // This method gets called by the runtime. Use this method to add services to the container. + public void ConfigureServices(IServiceCollection services) + { + services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddSingleton(new AppSettings(Configuration)); + services.AddScoped(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env, AppSettings appSettings) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseCors(builder => + builder.WithOrigins(appSettings.WithOrigins).SetIsOriginAllowedToAllowWildcardSubdomains() + .WithMethods("GET", "OPTIONS") + .AllowAnyHeader()); + + app.UseMvc(); + } + } +} +#endif diff --git a/MetingJS.Server/appsettings.json b/MetingJS.Server/appsettings.json index 6264ff7..ed7e14f 100644 --- a/MetingJS.Server/appsettings.json +++ b/MetingJS.Server/appsettings.json @@ -8,7 +8,6 @@ }, "AllowedHosts": "*", "WithOrigins": [ - "https://*.xxwhite.com", "*" ], "Urls": "http://localhost:5001",