2023-11-25 03:45:29 +00:00
|
|
|
|
using FSO.Server.Api.Core.Services;
|
2018-11-22 19:37:15 +00:00
|
|
|
|
using FSO.Server.Common;
|
|
|
|
|
|
using FSO.Server.Servers.UserApi;
|
|
|
|
|
|
using System.Collections.Specialized;
|
2018-11-28 19:28:09 +00:00
|
|
|
|
using System.Text;
|
2018-11-22 19:37:15 +00:00
|
|
|
|
|
|
|
|
|
|
namespace FSO.Server.Core
|
|
|
|
|
|
{
|
|
|
|
|
|
class Program
|
|
|
|
|
|
{
|
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
Content.Model.AbstractTextureRef.ImageFetchFunction = CoreImageLoader.SoftImageFetch;
|
|
|
|
|
|
UserApi.CustomStartup = StartWebApi;
|
|
|
|
|
|
|
2018-11-28 19:28:09 +00:00
|
|
|
|
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
|
|
|
|
|
var enc1252 = Encoding.GetEncoding(1252);
|
|
|
|
|
|
|
2018-11-22 19:37:15 +00:00
|
|
|
|
FSO.Server.Program.Main(args);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static IAPILifetime StartWebApi(UserApi api, string url)
|
|
|
|
|
|
{
|
|
|
|
|
|
var config = api.Config;
|
|
|
|
|
|
var userApiConfig = config.Services.UserApi;
|
|
|
|
|
|
var settings = new NameValueCollection();
|
2024-12-30 17:25:21 +00:00
|
|
|
|
settings.Add("maintenance", userApiConfig.Maintenance.ToString());
|
2018-11-22 19:37:15 +00:00
|
|
|
|
settings.Add("authTicketDuration", userApiConfig.AuthTicketDuration.ToString());
|
|
|
|
|
|
settings.Add("regkey", userApiConfig.Regkey);
|
|
|
|
|
|
settings.Add("secret", config.Secret);
|
|
|
|
|
|
settings.Add("updateUrl", userApiConfig.UpdateUrl);
|
|
|
|
|
|
settings.Add("cdnUrl", userApiConfig.CDNUrl);
|
|
|
|
|
|
settings.Add("connectionString", config.Database.ConnectionString);
|
|
|
|
|
|
settings.Add("NFSdir", config.SimNFS);
|
|
|
|
|
|
settings.Add("smtpHost", userApiConfig.SmtpHost);
|
|
|
|
|
|
settings.Add("smtpUser", userApiConfig.SmtpUser);
|
|
|
|
|
|
settings.Add("smtpPassword", userApiConfig.SmtpPassword);
|
|
|
|
|
|
settings.Add("smtpPort", userApiConfig.SmtpPort.ToString());
|
|
|
|
|
|
settings.Add("useProxy", userApiConfig.UseProxy.ToString());
|
2019-03-25 17:39:46 +00:00
|
|
|
|
settings.Add("updateID", config.UpdateID?.ToString() ?? "");
|
2019-04-09 15:53:21 +01:00
|
|
|
|
settings.Add("branchName", config.UpdateBranch);
|
2019-03-25 17:39:46 +00:00
|
|
|
|
|
2018-11-22 19:37:15 +00:00
|
|
|
|
var api2 = new FSO.Server.Api.Core.Api();
|
|
|
|
|
|
api2.Init(settings);
|
2024-12-29 21:25:08 +00:00
|
|
|
|
|
|
|
|
|
|
if (userApiConfig.AwsConfig != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
api2.AddonUploader = new AWSUpdateUploader(userApiConfig.AwsConfig);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
api2.AddonUploader = new FilesystemUpdateUploader(userApiConfig.FilesystemConfig ?? new Common.Config.FilesystemConfig());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (userApiConfig.GithubConfig != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
api2.UpdateUploader = new GithubUpdateUploader(userApiConfig.GithubConfig);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
api2.UpdateUploader = api2.AddonUploader;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-05-20 22:44:09 +01:00
|
|
|
|
api2.Github = userApiConfig.GithubConfig;
|
2018-11-22 19:37:15 +00:00
|
|
|
|
api.SetupInstance(api2);
|
|
|
|
|
|
api2.HostPool = api.GetGluonHostPool();
|
2018-11-28 19:28:09 +00:00
|
|
|
|
|
2018-11-22 19:37:15 +00:00
|
|
|
|
return FSO.Server.Api.Core.Program.RunAsync(new string[] { url });
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|