static void Main(string[] args) { try { var signInfo = ArgsReader.Read(args); SignatureWorker signWorker = new SignatureWorker(signInfo.InputFile, signInfo.BlockSize); signWorker.Start(); } catch (Exception exc) { Console.WriteLine(exc.Message); Console.WriteLine(exc.StackTrace); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, MimirContext db) { if (env.IsDevelopment()) { log.Info("LittleC is a potato!"); app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/error"); } // Load logic configs. log.Info("Loading logic configs."); try { Program.ServerName = (from o in db.Options where o.Option == "ServerName" select o.Value).First(); if ((from o in db.Options where o.Option == "PrivateKeyXml" select o.Value).First() == string.Empty) { SignatureWorker.GenKey(db); } RSACryptoServiceProviderExtensions.FromXmlString(Program.PrivateKeyProvider, (from o in db.Options where o.Option == "PrivateKeyXml" select o.Value).First()); Program.PublicKey = (from o in db.Options where o.Option == "PublicKey" select o.Value).First(); Program.ServerDomain = (from o in db.Options where o.Option == "ServerDomain" select o.Value).First(); int.TryParse((from o in db.Options where o.Option == "SecurityLoginTryTimes" select o.Value).First(), out Program.SecurityLoginTryTimes); bool.TryParse((from o in db.Options where o.Option == "IsEnableMultiProfiles" select o.Value).First(), out Program.IsEnableMultiProfiles); int.TryParse((from o in db.Options where o.Option == "MaxTokensPerProfile" select o.Value).First(), out Program.MaxTokensPerProfile); int.TryParse((from o in db.Options where o.Option == "TokensExpireDaysLimit" select o.Value).First(), out Program.TokensExpireDaysLimit); long.TryParse((from o in db.Options where o.Option == "SessionsExpireSeconds" select o.Value).First(), out Program.SessionsExpireSeconds); Program.SkinDomains = (from o in db.Options where o.Option == "SkinDomains" select o.Value).First().Split(","); int.TryParse((from o in db.Options where o.Option == "MaxProfileCountPerQuery" select o.Value).First(), out Program.MaxProfileCountPerQuery); bool.TryParse((from o in db.Options where o.Option == "IsEnableLandingPage" select o.Value).First(), out Program.IsEnableLandingPage); bool.TryParse((from o in db.Options where o.Option == "IsEnableSmtp" select o.Value).First(), out Program.IsEnableSmtp); Program.SmtpDomain = (from o in db.Options where o.Option == "SmtpDomain" select o.Value).First(); int.TryParse((from o in db.Options where o.Option == "SmtpPort" select o.Value).First(), out Program.SmtpPort); Program.SmtpEmail = (from o in db.Options where o.Option == "SmtpEmail" select o.Value).First(); Program.SmtpName = (from o in db.Options where o.Option == "SmtpName" select o.Value).First(); Program.SmtpPassword = (from o in db.Options where o.Option == "SmtpPassword" select o.Value).First(); bool.TryParse((from o in db.Options where o.Option == "SmtpIsSsl" select o.Value).First(), out Program.SmtpIsSsl); int.TryParse((from o in db.Options where o.Option == "MaxProfileCountPerUser" select o.Value).First(), out Program.MaxProfileCountPerUser); bool.TryParse((from o in db.Options where o.Option == "IsHttps" select o.Value).First(), out Program.IsHttps); } catch (Exception) { log.Fatal("Bad database."); throw; } log.Info("Logic configs loaded."); app.UseSession(); //app.UseHttpsRedirection(); app.UseStaticFiles(new StaticFileOptions() { ServeUnknownFileTypes = true, DefaultContentType = "image/png" }); app.Use(next => { return(async context => { context.Response.OnStarting(() => { // Add ALI. if (Program.IsHttps) { context.Response.Headers.Add("X-Authlib-Injector-API-Location", "https://" + Program.ServerDomain + "/api/"); } else { context.Response.Headers.Add("X-Authlib-Injector-API-Location", "http://" + Program.ServerDomain + "/api/"); } context.Response.Headers["Server"] = "Mimir"; context.Response.Headers.Add("Author", "Romonov"); return Task.CompletedTask; }); await next(context); }); }); app.UseMvc(routes => { routes.MapRoute( name: "yggdrasil_sessionserver_get_profile", template: "api/sessionserver/session/minecraft/profile/{uuid}", defaults: new { controller = "SessionServer", action = "Profile" }); routes.MapRoute( name: "yggdrasil_sessionserver_join", template: "api/sessionserver/session/minecraft/join", defaults: new { controller = "SessionServer", action = "Join" }); routes.MapRoute( name: "yggdrasil_sessionserver_has_joined", template: "api/sessionserver/session/minecraft/hasJoined", defaults: new { controller = "SessionServer", action = "HasJoined" }); routes.MapRoute( name: "yggdrasil_api_profiles_query", template: "api/api/profiles/minecraft", defaults: new { controller = "Api", action = "Profiles" }); routes.MapRoute( name: "yggdrasil_authserver", template: "api/authserver/{action}", defaults: new { controller = "AuthServer" }); routes.MapRoute( name: "yggdrasil_index", template: "api", defaults: new { controller = "Api", action = "Index" }); routes.MapRoute( name: "default", template: "{controller=Index}/{action=Index}/{id?}"); }); }