more api tweaks

removed WebfrontSettings
IW4MAdminSettings are only generated when the file does not exist, placeholder values stored in DefaultSettings.json
This commit is contained in:
RaidMax 2018-04-19 00:48:14 -05:00
parent 23ec72e6b6
commit 438718507b
31 changed files with 310 additions and 77 deletions

View File

@ -10,15 +10,13 @@ namespace IW4MAdmin.Application.API.Master
{ {
public class Heartbeat public class Heartbeat
{ {
static IMasterApi api;
public static async Task Send(ApplicationManager mgr, bool firstHeartbeat = false) public static async Task Send(ApplicationManager mgr, bool firstHeartbeat = false)
{ {
var api = Endpoint.Get();
if (firstHeartbeat) if (firstHeartbeat)
{ {
api = RestClient.For<IMasterApi>("http://127.0.0.1");
var token = await api.Authenticate(new AuthenticationId() var token = await api.Authenticate(new AuthenticationId()
{ {
Id = mgr.GetApplicationSettings().Configuration().Id Id = mgr.GetApplicationSettings().Configuration().Id
@ -48,12 +46,12 @@ namespace IW4MAdmin.Application.API.Master
if (firstHeartbeat) if (firstHeartbeat)
{ {
instance = await api.AddInstance(instance); var message = await api.AddInstance(instance);
} }
else else
{ {
instance = await api.UpdateInstance(instance.Id, instance); var message = await api.UpdateInstance(instance.Id, instance);
} }
} }
} }

View File

@ -19,6 +19,30 @@ namespace IW4MAdmin.Application.API.Master
public string AccessToken { get; set; } public string AccessToken { get; set; }
} }
public class VersionInfo
{
[JsonProperty("current-version-stable")]
public float CurrentVersionStable { get; set; }
[JsonProperty("current-version-prerelease")]
public float CurrentVersionPrerelease { get; set; }
}
public class ResultMessage
{
[JsonProperty("message")]
public string Message { get; set; }
}
public class Endpoint
{
#if !DEBUG
private static IMasterApi api = RestClient.For<IMasterApi>("http://api.raidmax.org:5000");
#else
private static IMasterApi api = RestClient.For<IMasterApi>("http://127.0.0.1");
#endif
public static IMasterApi Get() => api;
}
[Header("User-Agent", "IW4MAdmin-RestEase")] [Header("User-Agent", "IW4MAdmin-RestEase")]
public interface IMasterApi public interface IMasterApi
{ {
@ -29,9 +53,12 @@ namespace IW4MAdmin.Application.API.Master
Task<TokenId> Authenticate([Body] AuthenticationId Id); Task<TokenId> Authenticate([Body] AuthenticationId Id);
[Post("instance/")] [Post("instance/")]
Task<ApiInstance> AddInstance([Body] ApiInstance instance); Task<ResultMessage> AddInstance([Body] ApiInstance instance);
[Put("instance/{id}")] [Put("instance/{id}")]
Task<ApiInstance> UpdateInstance([Path] string id, [Body] ApiInstance instance); Task<ResultMessage> UpdateInstance([Path] string id, [Body] ApiInstance instance);
[Get("version")]
Task<VersionInfo> GetVersion();
} }
} }

View File

@ -17,19 +17,9 @@
<PackageIconUrl>https://raidmax.org/IW4MAdmin/img/iw4adminicon-3.png</PackageIconUrl> <PackageIconUrl>https://raidmax.org/IW4MAdmin/img/iw4adminicon-3.png</PackageIconUrl>
<ApplicationIcon /> <ApplicationIcon />
<AssemblyName>IW4MAdmin</AssemblyName> <AssemblyName>IW4MAdmin</AssemblyName>
<Configurations>Debug;Release;Prerelease</Configurations>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<None Remove="IW4MAdminSettings.json" />
</ItemGroup>
<ItemGroup>
<Content Include="IW4MAdminSettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="RestEase" Version="1.4.5" /> <PackageReference Include="RestEase" Version="1.4.5" />
</ItemGroup> </ItemGroup>
@ -44,6 +34,12 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Update="DefaultSettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent"> <Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="call $(ProjectDir)BuildScripts\PreBuild.bat $(SolutionDir) $(ProjectDir) $(TargetDir) $(OutDir)" /> <Exec Command="call $(ProjectDir)BuildScripts\PreBuild.bat $(SolutionDir) $(ProjectDir) $(TargetDir) $(OutDir)" />
</Target> </Target>

View File

@ -1,4 +1,4 @@
{ {
"AutoMessagePeriod": 60, "AutoMessagePeriod": 60,
"AutoMessages": [ "AutoMessages": [
"This server uses ^5IW4M Admin v{{VERSION}} ^7get it at ^5raidmax.org/IW4MAdmin", "This server uses ^5IW4M Admin v{{VERSION}} ^7get it at ^5raidmax.org/IW4MAdmin",
@ -361,6 +361,34 @@
{ {
"Alias": "Takeoff", "Alias": "Takeoff",
"Name": "mp_takeoff" "Name": "mp_takeoff"
},
{
"Alias": "Buried/Resolution 1295",
"Name": "zm_buried"
},
{
"Alias": "Die Rise/Great Leap Forward",
"Name": "zm_highrise"
},
{
"Alias": "Nuketown",
"Name": "zm_nuked"
},
{
"Alias": "Mob of the Dead",
"Name": "zm_prison"
},
{
"Alias": "Origins",
"Name": "zm_tomb"
},
{
"Alias": "Diner",
"Name": "zm_transit_dr"
},
{
"Alias": "Green Run/Bus Depot/Farm/Town",
"Name": "zm_transit"
} }
] ]
} }

View File

@ -25,7 +25,7 @@ namespace IW4MAdmin.Application
Console.WriteLine("====================================================="); Console.WriteLine("=====================================================");
Console.WriteLine(" IW4M ADMIN"); Console.WriteLine(" IW4M ADMIN");
Console.WriteLine(" by RaidMax "); Console.WriteLine(" by RaidMax ");
Console.WriteLine($" Version {Version}"); Console.WriteLine($" Version {Version.ToString("0.0")}");
Console.WriteLine("====================================================="); Console.WriteLine("=====================================================");
try try
@ -36,9 +36,63 @@ namespace IW4MAdmin.Application
CheckDirectories(); CheckDirectories();
ServerManager = ApplicationManager.GetInstance(); ServerManager = ApplicationManager.GetInstance();
var api = API.Master.Endpoint.Get();
var version = new API.Master.VersionInfo()
{
CurrentVersionStable = 99.99f
};
try
{
version = api.GetVersion().Result;
}
catch (Exception e)
{
ServerManager.Logger.WriteWarning($"Could not get latest IW4MAdmin version");
while (e.InnerException != null)
{
e = e.InnerException;
}
ServerManager.Logger.WriteDebug(e.Message);
}
if (version.CurrentVersionStable == 99.99f)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Could not get latest IW4MAdmin version.");
Console.ForegroundColor = ConsoleColor.White;
}
#if !PRERELEASE
else if (version.CurrentVersionStable > Version)
{
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine($"IW4MAdmin has an update. Latest version is [v{version.CurrentVersionStable.ToString("0.0")}]");
Console.WriteLine($"Your version is [v{Version.ToString("0.0")}]");
Console.ForegroundColor = ConsoleColor.White;
}
#else
else if (version.CurrentVersionPrerelease > Version)
{
Console.ForegroundColor = ConsoleColor.DarkYellow;
Console.WriteLine($"IW4MAdmin-Prerelease has an update. Latest version is [v{version.CurrentVersionPrerelease.ToString("0.0")}-pr]");
Console.WriteLine($"Your version is [v{Version.ToString("0.0")}-pr]");
Console.ForegroundColor = ConsoleColor.White;
}
#endif
else
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("IW4MAdmin is up to date.");
Console.ForegroundColor = ConsoleColor.White;
}
ServerManager.Init().Wait(); ServerManager.Init().Wait();
Task.Run(() => var consoleTask = Task.Run(() =>
{ {
String userInput; String userInput;
Player Origin = ServerManager.GetClientService().Get(1).Result.AsPlayer(); Player Origin = ServerManager.GetClientService().Get(1).Result.AsPlayer();
@ -51,10 +105,13 @@ namespace IW4MAdmin.Application
ServerManager.Stop(); ServerManager.Stop();
if (ServerManager.Servers.Count == 0) if (ServerManager.Servers.Count == 0)
return; {
Console.WriteLine("No servers are currently being monitored");
continue;
}
Origin.CurrentServer = ServerManager.Servers[0]; Origin.CurrentServer = ServerManager.Servers[0];
GameEvent E = new GameEvent((GameEvent.EventType)GameEvent.EventType.Say, userInput, Origin, null, ServerManager.Servers[0]); GameEvent E = new GameEvent(GameEvent.EventType.Say, userInput, Origin, null, ServerManager.Servers[0]);
ServerManager.Servers[0].ExecuteEvent(E); ServerManager.Servers[0].ExecuteEvent(E);
Console.Write('>'); Console.Write('>');
@ -73,12 +130,12 @@ namespace IW4MAdmin.Application
catch (Exception e) catch (Exception e)
{ {
Console.WriteLine($"Fatal Error during initialization: {e.Message}"); Console.WriteLine($"Fatal Error during initialization");
while (e.InnerException != null) while (e.InnerException != null)
{ {
e = e.InnerException; e = e.InnerException;
Console.WriteLine($"Inner exception: {e.Message}");
} }
Console.WriteLine($"Exception: {e.Message}");
Console.WriteLine("Press any key to exit..."); Console.WriteLine("Press any key to exit...");
Console.ReadKey(); Console.ReadKey();
} }

View File

@ -121,27 +121,41 @@ namespace IW4MAdmin.Application
#region CONFIG #region CONFIG
var config = ConfigHandler.Configuration(); var config = ConfigHandler.Configuration();
if (config?.Servers == null)
{
var newConfig = (ApplicationConfiguration)ConfigHandler.Configuration().Generate();
ConfigHandler.Set(newConfig);
newConfig.AutoMessagePeriod = config.AutoMessagePeriod; // copy over default config if it doesn't exist
newConfig.AutoMessages = config.AutoMessages; if (config == null)
newConfig.GlobalRules = config.GlobalRules; {
newConfig.Maps = config.Maps; var defaultConfig = new BaseConfigurationHandler<DefaultConfiguration>("DefaultSettings").Configuration();
ConfigHandler.Set((ApplicationConfiguration)new ApplicationConfiguration().Generate());
var newConfig = ConfigHandler.Configuration();
newConfig.AutoMessagePeriod = defaultConfig.AutoMessagePeriod;
newConfig.AutoMessages = defaultConfig.AutoMessages;
newConfig.GlobalRules = defaultConfig.GlobalRules;
newConfig.Maps = defaultConfig.Maps;
if (newConfig.Servers == null)
{
ConfigHandler.Set(newConfig);
newConfig.Servers = ConfigurationGenerator.GenerateServerConfig(new List<ServerConfiguration>()); newConfig.Servers = ConfigurationGenerator.GenerateServerConfig(new List<ServerConfiguration>());
config = newConfig; config = newConfig;
await ConfigHandler.Save(); await ConfigHandler.Save();
} }
}
else if(config != null) else if (config != null)
{ {
if (string.IsNullOrEmpty(config.Id)) if (string.IsNullOrEmpty(config.Id))
{ {
config.Id = Guid.NewGuid().ToString(); config.Id = Guid.NewGuid().ToString();
await ConfigHandler.Save(); await ConfigHandler.Save();
} }
if (string.IsNullOrEmpty(config.WebfrontBindUrl))
{
config.WebfrontBindUrl = "http://127.0.0.1:1624";
await ConfigHandler.Save();
}
} }
else if (config.Servers.Count == 0) else if (config.Servers.Count == 0)

View File

@ -36,6 +36,10 @@ Global
Debug|Mixed Platforms = Debug|Mixed Platforms Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
Debug|x86 = Debug|x86 Debug|x86 = Debug|x86
Prerelease|Any CPU = Prerelease|Any CPU
Prerelease|Mixed Platforms = Prerelease|Mixed Platforms
Prerelease|x64 = Prerelease|x64
Prerelease|x86 = Prerelease|x86
Release|Any CPU = Release|Any CPU Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms Release|Mixed Platforms = Release|Mixed Platforms
Release|x64 = Release|x64 Release|x64 = Release|x64
@ -50,6 +54,10 @@ Global
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Debug|x64.Build.0 = Debug|Any CPU {B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Debug|x64.Build.0 = Debug|Any CPU
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Debug|x86.ActiveCfg = Debug|x86 {B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Debug|x86.ActiveCfg = Debug|x86
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Debug|x86.Build.0 = Debug|x86 {B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Debug|x86.Build.0 = Debug|x86
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Prerelease|Any CPU.ActiveCfg = Release-Stable|Any CPU
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Prerelease|Mixed Platforms.ActiveCfg = Release-Stable|x86
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Prerelease|x64.ActiveCfg = Release-Stable|Any CPU
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Prerelease|x86.ActiveCfg = Release-Stable|x86
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release|Any CPU.ActiveCfg = Release-Stable|Any CPU {B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release|Any CPU.ActiveCfg = Release-Stable|Any CPU
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release|Any CPU.Build.0 = Release-Stable|Any CPU {B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release|Any CPU.Build.0 = Release-Stable|Any CPU
{B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release|Mixed Platforms.ActiveCfg = Release-Stable|x86 {B8C2A759-8663-4F6F-9BA4-19595F5E12C1}.Release|Mixed Platforms.ActiveCfg = Release-Stable|x86
@ -66,6 +74,14 @@ Global
{AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Debug|x64.Build.0 = Debug|Any CPU {AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Debug|x64.Build.0 = Debug|Any CPU
{AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Debug|x86.ActiveCfg = Debug|Any CPU {AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Debug|x86.ActiveCfg = Debug|Any CPU
{AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Debug|x86.Build.0 = Debug|Any CPU {AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Debug|x86.Build.0 = Debug|Any CPU
{AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Prerelease|Any CPU.ActiveCfg = Prerelease|Any CPU
{AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Prerelease|Any CPU.Build.0 = Prerelease|Any CPU
{AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Prerelease|Mixed Platforms.ActiveCfg = Prerelease|Any CPU
{AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Prerelease|Mixed Platforms.Build.0 = Prerelease|Any CPU
{AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Prerelease|x64.ActiveCfg = Prerelease|Any CPU
{AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Prerelease|x64.Build.0 = Prerelease|Any CPU
{AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Prerelease|x86.ActiveCfg = Prerelease|Any CPU
{AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Prerelease|x86.Build.0 = Prerelease|Any CPU
{AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Release|Any CPU.ActiveCfg = Release|Any CPU {AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Release|Any CPU.Build.0 = Release|Any CPU {AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Release|Any CPU.Build.0 = Release|Any CPU
{AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {AA0541A2-8D51-4AD9-B0AC-3D1F5B162481}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
@ -82,6 +98,14 @@ Global
{D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Debug|x64.Build.0 = Debug|Any CPU {D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Debug|x64.Build.0 = Debug|Any CPU
{D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Debug|x86.ActiveCfg = Debug|Any CPU {D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Debug|x86.ActiveCfg = Debug|Any CPU
{D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Debug|x86.Build.0 = Debug|Any CPU {D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Debug|x86.Build.0 = Debug|Any CPU
{D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Prerelease|Any CPU.ActiveCfg = Prerelease|Any CPU
{D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Prerelease|Any CPU.Build.0 = Prerelease|Any CPU
{D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Prerelease|Mixed Platforms.ActiveCfg = Prerelease|Any CPU
{D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Prerelease|Mixed Platforms.Build.0 = Prerelease|Any CPU
{D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Prerelease|x64.ActiveCfg = Prerelease|Any CPU
{D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Prerelease|x64.Build.0 = Prerelease|Any CPU
{D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Prerelease|x86.ActiveCfg = Prerelease|Any CPU
{D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Prerelease|x86.Build.0 = Prerelease|Any CPU
{D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Release|Any CPU.ActiveCfg = Release|Any CPU {D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Release|Any CPU.Build.0 = Release|Any CPU {D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Release|Any CPU.Build.0 = Release|Any CPU
{D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {D59AC1F1-2FB9-4BE7-813E-0CCCC4FE9067}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
@ -98,6 +122,14 @@ Global
{B4626E78-BB22-43F8-A6AD-890B0853D61F}.Debug|x64.Build.0 = Debug|Any CPU {B4626E78-BB22-43F8-A6AD-890B0853D61F}.Debug|x64.Build.0 = Debug|Any CPU
{B4626E78-BB22-43F8-A6AD-890B0853D61F}.Debug|x86.ActiveCfg = Debug|Any CPU {B4626E78-BB22-43F8-A6AD-890B0853D61F}.Debug|x86.ActiveCfg = Debug|Any CPU
{B4626E78-BB22-43F8-A6AD-890B0853D61F}.Debug|x86.Build.0 = Debug|Any CPU {B4626E78-BB22-43F8-A6AD-890B0853D61F}.Debug|x86.Build.0 = Debug|Any CPU
{B4626E78-BB22-43F8-A6AD-890B0853D61F}.Prerelease|Any CPU.ActiveCfg = Prerelease|Any CPU
{B4626E78-BB22-43F8-A6AD-890B0853D61F}.Prerelease|Any CPU.Build.0 = Prerelease|Any CPU
{B4626E78-BB22-43F8-A6AD-890B0853D61F}.Prerelease|Mixed Platforms.ActiveCfg = Prerelease|Any CPU
{B4626E78-BB22-43F8-A6AD-890B0853D61F}.Prerelease|Mixed Platforms.Build.0 = Prerelease|Any CPU
{B4626E78-BB22-43F8-A6AD-890B0853D61F}.Prerelease|x64.ActiveCfg = Prerelease|Any CPU
{B4626E78-BB22-43F8-A6AD-890B0853D61F}.Prerelease|x64.Build.0 = Prerelease|Any CPU
{B4626E78-BB22-43F8-A6AD-890B0853D61F}.Prerelease|x86.ActiveCfg = Prerelease|Any CPU
{B4626E78-BB22-43F8-A6AD-890B0853D61F}.Prerelease|x86.Build.0 = Prerelease|Any CPU
{B4626E78-BB22-43F8-A6AD-890B0853D61F}.Release|Any CPU.ActiveCfg = Release|Any CPU {B4626E78-BB22-43F8-A6AD-890B0853D61F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B4626E78-BB22-43F8-A6AD-890B0853D61F}.Release|Any CPU.Build.0 = Release|Any CPU {B4626E78-BB22-43F8-A6AD-890B0853D61F}.Release|Any CPU.Build.0 = Release|Any CPU
{B4626E78-BB22-43F8-A6AD-890B0853D61F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {B4626E78-BB22-43F8-A6AD-890B0853D61F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
@ -114,6 +146,14 @@ Global
{98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Debug|x64.Build.0 = Debug|Any CPU {98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Debug|x64.Build.0 = Debug|Any CPU
{98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Debug|x86.ActiveCfg = Debug|Any CPU {98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Debug|x86.ActiveCfg = Debug|Any CPU
{98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Debug|x86.Build.0 = Debug|Any CPU {98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Debug|x86.Build.0 = Debug|Any CPU
{98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Prerelease|Any CPU.ActiveCfg = Prerelease|Any CPU
{98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Prerelease|Any CPU.Build.0 = Prerelease|Any CPU
{98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Prerelease|Mixed Platforms.ActiveCfg = Prerelease|Any CPU
{98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Prerelease|Mixed Platforms.Build.0 = Prerelease|Any CPU
{98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Prerelease|x64.ActiveCfg = Prerelease|Any CPU
{98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Prerelease|x64.Build.0 = Prerelease|Any CPU
{98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Prerelease|x86.ActiveCfg = Prerelease|Any CPU
{98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Prerelease|x86.Build.0 = Prerelease|Any CPU
{98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Release|Any CPU.ActiveCfg = Release|Any CPU {98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Release|Any CPU.Build.0 = Release|Any CPU {98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Release|Any CPU.Build.0 = Release|Any CPU
{98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {98BE4A81-8AFD-4957-83F7-009D353C6BCB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
@ -130,6 +170,14 @@ Global
{179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Debug|x64.Build.0 = Debug|Any CPU {179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Debug|x64.Build.0 = Debug|Any CPU
{179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Debug|x86.ActiveCfg = Debug|Any CPU {179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Debug|x86.ActiveCfg = Debug|Any CPU
{179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Debug|x86.Build.0 = Debug|Any CPU {179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Debug|x86.Build.0 = Debug|Any CPU
{179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Prerelease|Any CPU.ActiveCfg = Prerelease|Any CPU
{179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Prerelease|Any CPU.Build.0 = Prerelease|Any CPU
{179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Prerelease|Mixed Platforms.ActiveCfg = Prerelease|Any CPU
{179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Prerelease|Mixed Platforms.Build.0 = Prerelease|Any CPU
{179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Prerelease|x64.ActiveCfg = Prerelease|Any CPU
{179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Prerelease|x64.Build.0 = Prerelease|Any CPU
{179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Prerelease|x86.ActiveCfg = Prerelease|Any CPU
{179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Prerelease|x86.Build.0 = Prerelease|Any CPU
{179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Release|Any CPU.ActiveCfg = Release|Any CPU {179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Release|Any CPU.ActiveCfg = Release|Any CPU
{179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Release|Any CPU.Build.0 = Release|Any CPU {179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Release|Any CPU.Build.0 = Release|Any CPU
{179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {179140D3-97AA-4CB4-8BF6-A0C73CA75701}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
@ -146,6 +194,14 @@ Global
{958FF7EC-0226-4E85-A85B-B84EC768197D}.Debug|x64.Build.0 = Debug|Any CPU {958FF7EC-0226-4E85-A85B-B84EC768197D}.Debug|x64.Build.0 = Debug|Any CPU
{958FF7EC-0226-4E85-A85B-B84EC768197D}.Debug|x86.ActiveCfg = Debug|Any CPU {958FF7EC-0226-4E85-A85B-B84EC768197D}.Debug|x86.ActiveCfg = Debug|Any CPU
{958FF7EC-0226-4E85-A85B-B84EC768197D}.Debug|x86.Build.0 = Debug|Any CPU {958FF7EC-0226-4E85-A85B-B84EC768197D}.Debug|x86.Build.0 = Debug|Any CPU
{958FF7EC-0226-4E85-A85B-B84EC768197D}.Prerelease|Any CPU.ActiveCfg = Prerelease|Any CPU
{958FF7EC-0226-4E85-A85B-B84EC768197D}.Prerelease|Any CPU.Build.0 = Prerelease|Any CPU
{958FF7EC-0226-4E85-A85B-B84EC768197D}.Prerelease|Mixed Platforms.ActiveCfg = Prerelease|Any CPU
{958FF7EC-0226-4E85-A85B-B84EC768197D}.Prerelease|Mixed Platforms.Build.0 = Prerelease|Any CPU
{958FF7EC-0226-4E85-A85B-B84EC768197D}.Prerelease|x64.ActiveCfg = Prerelease|Any CPU
{958FF7EC-0226-4E85-A85B-B84EC768197D}.Prerelease|x64.Build.0 = Prerelease|Any CPU
{958FF7EC-0226-4E85-A85B-B84EC768197D}.Prerelease|x86.ActiveCfg = Prerelease|Any CPU
{958FF7EC-0226-4E85-A85B-B84EC768197D}.Prerelease|x86.Build.0 = Prerelease|Any CPU
{958FF7EC-0226-4E85-A85B-B84EC768197D}.Release|Any CPU.ActiveCfg = Release|Any CPU {958FF7EC-0226-4E85-A85B-B84EC768197D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{958FF7EC-0226-4E85-A85B-B84EC768197D}.Release|Any CPU.Build.0 = Release|Any CPU {958FF7EC-0226-4E85-A85B-B84EC768197D}.Release|Any CPU.Build.0 = Release|Any CPU
{958FF7EC-0226-4E85-A85B-B84EC768197D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {958FF7EC-0226-4E85-A85B-B84EC768197D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
@ -162,6 +218,14 @@ Global
{D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Debug|x64.Build.0 = Debug|Any CPU {D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Debug|x64.Build.0 = Debug|Any CPU
{D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Debug|x86.ActiveCfg = Debug|Any CPU {D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Debug|x86.ActiveCfg = Debug|Any CPU
{D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Debug|x86.Build.0 = Debug|Any CPU {D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Debug|x86.Build.0 = Debug|Any CPU
{D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Prerelease|Any CPU.ActiveCfg = Prerelease|Any CPU
{D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Prerelease|Any CPU.Build.0 = Prerelease|Any CPU
{D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Prerelease|Mixed Platforms.ActiveCfg = Prerelease|Any CPU
{D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Prerelease|Mixed Platforms.Build.0 = Prerelease|Any CPU
{D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Prerelease|x64.ActiveCfg = Prerelease|Any CPU
{D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Prerelease|x64.Build.0 = Prerelease|Any CPU
{D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Prerelease|x86.ActiveCfg = Prerelease|Any CPU
{D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Prerelease|x86.Build.0 = Prerelease|Any CPU
{D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Release|Any CPU.ActiveCfg = Release|Any CPU {D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Release|Any CPU.Build.0 = Release|Any CPU {D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Release|Any CPU.Build.0 = Release|Any CPU
{D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {D9F2ED28-6FA5-40CA-9912-E7A849147AB1}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
@ -178,6 +242,14 @@ Global
{F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Debug|x64.Build.0 = Debug|Any CPU {F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Debug|x64.Build.0 = Debug|Any CPU
{F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Debug|x86.ActiveCfg = Debug|Any CPU {F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Debug|x86.ActiveCfg = Debug|Any CPU
{F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Debug|x86.Build.0 = Debug|Any CPU {F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Debug|x86.Build.0 = Debug|Any CPU
{F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Prerelease|Any CPU.ActiveCfg = Prerelease|Any CPU
{F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Prerelease|Any CPU.Build.0 = Prerelease|Any CPU
{F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Prerelease|Mixed Platforms.ActiveCfg = Prerelease|Any CPU
{F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Prerelease|Mixed Platforms.Build.0 = Prerelease|Any CPU
{F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Prerelease|x64.ActiveCfg = Prerelease|Any CPU
{F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Prerelease|x64.Build.0 = Prerelease|Any CPU
{F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Prerelease|x86.ActiveCfg = Prerelease|Any CPU
{F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Prerelease|x86.Build.0 = Prerelease|Any CPU
{F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Release|Any CPU.ActiveCfg = Release|Any CPU {F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Release|Any CPU.Build.0 = Release|Any CPU {F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Release|Any CPU.Build.0 = Release|Any CPU
{F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU

View File

@ -27,6 +27,11 @@
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging> <EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Prerelease' ">
<DebugSymbols>true</DebugSymbols>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
<OutputPath>bin\Prerelease\</OutputPath>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="master\context\base.py"> <Compile Include="master\context\base.py">
<SubType>Code</SubType> <SubType>Code</SubType>
@ -52,6 +57,9 @@
<Compile Include="Master\resources\null.py"> <Compile Include="Master\resources\null.py">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="Master\resources\version.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="Master\resources\__init__.py"> <Compile Include="Master\resources\__init__.py">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
@ -76,6 +84,7 @@
<Folder Include="master\" /> <Folder Include="master\" />
<Folder Include="master\context\" /> <Folder Include="master\context\" />
<Folder Include="master\models\" /> <Folder Include="master\models\" />
<Folder Include="master\config\" />
<Folder Include="master\schema\" /> <Folder Include="master\schema\" />
<Folder Include="Master\resources\" /> <Folder Include="Master\resources\" />
<Folder Include="Master\static\" /> <Folder Include="Master\static\" />
@ -86,6 +95,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="FolderProfile.pubxml" /> <None Include="FolderProfile.pubxml" />
<Content Include="master\config\master.json" />
<Content Include="requirements.txt" /> <Content Include="requirements.txt" />
<Content Include="Master\static\content\bootstrap.css" /> <Content Include="Master\static\content\bootstrap.css" />
<Content Include="Master\static\content\bootstrap.min.css" /> <Content Include="Master\static\content\bootstrap.min.css" />

View File

@ -6,12 +6,15 @@ from flask import Flask
from flask_restful import Resource, Api from flask_restful import Resource, Api
from flask_jwt_extended import JWTManager from flask_jwt_extended import JWTManager
from master.context.base import Base from master.context.base import Base
import json
app = Flask(__name__) app = Flask(__name__)
app.config['JWT_SECRET_KEY'] = 'my key!' app.config['JWT_SECRET_KEY'] = 'my key!'
app.config['PROPAGATE_EXCEPTIONS'] = True
jwt = JWTManager(app) jwt = JWTManager(app)
api = Api(app) api = Api(app)
ctx = Base() ctx = Base()
config = json.load(open('./master/config/master.json'))
import master.routes import master.routes
import master.views import master.views

View File

@ -0,0 +1,4 @@
{
"current-version-stable": 2.0,
"current-version-prerelease": 2.0
}

View File

@ -23,7 +23,10 @@ class Base():
print('[_remove_staleinstances] removing stale instance {id}'.format(id=key)) print('[_remove_staleinstances] removing stale instance {id}'.format(id=key))
del self.instance_list[key] del self.instance_list[key]
del self.token_list[key] del self.token_list[key]
print('[_remove_staleinstances] {count} active instances'.format(count=len(self.instance_list))) print('[_remove_staleinstances] {count} active instances'.format(count=len(self.instance_list.items())))
def get_instances(self):
return self.instance_list.values()
def get_server_count(self): def get_server_count(self):
return self.server_list.count return self.server_list.count

View File

@ -2,6 +2,7 @@ from flask_restful import Resource
from flask import request, jsonify from flask import request, jsonify
from flask_jwt_extended import create_access_token from flask_jwt_extended import create_access_token
from master import app, ctx from master import app, ctx
import datetime
class Authenticate(Resource): class Authenticate(Resource):
@ -10,7 +11,7 @@ class Authenticate(Resource):
if ctx.get_token(instance_id) is not False: if ctx.get_token(instance_id) is not False:
return { 'message' : 'that id already has a token'}, 401 return { 'message' : 'that id already has a token'}, 401
else: else:
token = create_access_token(instance_id) expires = datetime.timedelta(days=1)
token = create_access_token(instance_id, expires_delta=expires)
ctx.add_token(instance_id, token) ctx.add_token(instance_id, token)
return { 'access_token' : token }, 200 return { 'access_token' : token }, 200

View File

@ -9,7 +9,7 @@ class Instance(Resource):
def get(self, id=None): def get(self, id=None):
if id is None: if id is None:
schema = InstanceSchema(many=True) schema = InstanceSchema(many=True)
instances = schema.dump(ctx.instance_list.values()) instances = schema.dump(ctx.get_instances())
return instances return instances
else: else:
try: try:
@ -25,13 +25,13 @@ class Instance(Resource):
except ValidationError as err: except ValidationError as err:
return {'message' : err.messages }, 400 return {'message' : err.messages }, 400
ctx.update_instance(instance) ctx.update_instance(instance)
return InstanceSchema().dump(instance) return { 'message' : 'instance updated successfully' }, 200
@jwt_required @jwt_required
def post(self): def post(self):
try: try:
instance = InstanceSchema().load(request.json) instance = InstanceSchema().load(request.json)
except ValidationError as err: except ValidationError as err:
return err.messages return {'message' : err.messages }, 400
ctx.add_instance(instance) ctx.add_instance(instance)
return InstanceSchema().dump(instance) return { 'message' : 'instance added successfully' }, 200

View File

@ -0,0 +1,9 @@
from flask_restful import Resource
from master import config
class Version(Resource):
def get(self):
return {
'current-version-stable' : config['current-version-stable'],
'current-version-prerelease' : config['current-version-prerelease']
}, 200

View File

@ -3,8 +3,9 @@ from master import api
from master.resources.null import Null from master.resources.null import Null
from master.resources.instance import Instance from master.resources.instance import Instance
from master.resources.authenticate import Authenticate from master.resources.authenticate import Authenticate
from master.resources.version import Version
api.add_resource(Null, '/null') api.add_resource(Null, '/null')
api.add_resource(Instance, '/instance/', '/instance/<string:id>') api.add_resource(Instance, '/instance/', '/instance/<string:id>')
api.add_resource(Version, '/version')
api.add_resource(Authenticate, '/authenticate') api.add_resource(Authenticate, '/authenticate')

View File

@ -9,6 +9,7 @@
<Authors>RaidMax</Authors> <Authors>RaidMax</Authors>
<Company>Forever None</Company> <Company>Forever None</Company>
<Product>Login Plugin for IW4MAdmin</Product> <Product>Login Plugin for IW4MAdmin</Product>
<Configurations>Debug;Release;Prerelease</Configurations>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -11,6 +11,7 @@
<Product>Profanity Determent for IW4MAdmin</Product> <Product>Profanity Determent for IW4MAdmin</Product>
<Description>Warns and kicks players for using profanity</Description> <Description>Warns and kicks players for using profanity</Description>
<Copyright>2018</Copyright> <Copyright>2018</Copyright>
<Configurations>Debug;Release;Prerelease</Configurations>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -11,6 +11,7 @@
<Product>Client Statistics</Product> <Product>Client Statistics</Product>
<Description>Client Statistics Plugin for IW4MAdmin</Description> <Description>Client Statistics Plugin for IW4MAdmin</Description>
<Copyright>2018</Copyright> <Copyright>2018</Copyright>
<Configurations>Debug;Release;Prerelease</Configurations>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -11,6 +11,7 @@
<Product>Welcome Plugin for IW4MAdmin</Product> <Product>Welcome Plugin for IW4MAdmin</Product>
<Description>Welcome plugin for IW4MAdmin welcomes clients to the server</Description> <Description>Welcome plugin for IW4MAdmin welcomes clients to the server</Description>
<Copyright>2018</Copyright> <Copyright>2018</Copyright>
<Configurations>Debug;Release;Prerelease</Configurations>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -314,7 +314,8 @@ namespace SharedLibraryCore.Commands
bool found = false; bool found = false;
foreach (Command C in E.Owner.Manager.GetCommands()) foreach (Command C in E.Owner.Manager.GetCommands())
{ {
if (C.Name == cmd.ToLower()) if (C.Name == cmd.ToLower() ||
C.Alias == cmd.ToLower())
{ {
await E.Origin.Tell("[^3" + C.Name + "^7] " + C.Description); await E.Origin.Tell("[^3" + C.Name + "^7] " + C.Description);
await E.Origin.Tell(C.Syntax); await E.Origin.Tell(C.Syntax);

View File

@ -16,6 +16,7 @@ namespace SharedLibraryCore.Configuration
public string CustomSayName { get; set; } public string CustomSayName { get; set; }
public string DiscordInviteCode { get; set; } public string DiscordInviteCode { get; set; }
public string IPHubAPIKey { get; set; } public string IPHubAPIKey { get; set; }
public string WebfrontBindUrl { get; set; }
public string Id { get; set; } public string Id { get; set; }
public List<ServerConfiguration> Servers { get; set; } public List<ServerConfiguration> Servers { get; set; }
public int AutoMessagePeriod { get; set; } public int AutoMessagePeriod { get; set; }
@ -31,6 +32,8 @@ namespace SharedLibraryCore.Configuration
EnableSteppedHierarchy = Utilities.PromptBool("Enable stepped privilege hierarchy"); EnableSteppedHierarchy = Utilities.PromptBool("Enable stepped privilege hierarchy");
EnableCustomSayName = Utilities.PromptBool("Enable custom say name"); EnableCustomSayName = Utilities.PromptBool("Enable custom say name");
WebfrontBindUrl = "http://127.0.0.1:1624";
if (EnableCustomSayName) if (EnableCustomSayName)
CustomSayName = Utilities.PromptString("Enter custom say name"); CustomSayName = Utilities.PromptString("Enter custom say name");

View File

@ -0,0 +1,19 @@
using SharedLibraryCore.Interfaces;
using System;
using System.Collections.Generic;
using System.Text;
namespace SharedLibraryCore.Configuration
{
public class DefaultConfiguration : IBaseConfiguration
{
public int AutoMessagePeriod { get; set; }
public List<string> AutoMessages { get; set; }
public List<string> GlobalRules { get; set; }
public List<MapConfiguration> Maps { get; set; }
public IBaseConfiguration Generate() => this;
public string Name() => "DefaultConfiguration";
}
}

View File

@ -93,7 +93,7 @@ namespace SharedLibraryCore.Database
library = Assembly.LoadFrom(dllPath); library = Assembly.LoadFrom(dllPath);
} }
// not a valid assembly, ie plugin files // not a valid assembly, ie plugin support files
catch (Exception) catch (Exception)
{ {
continue; continue;

View File

@ -9,6 +9,7 @@
<Version>2.0.0</Version> <Version>2.0.0</Version>
<Authors>RaidMax</Authors> <Authors>RaidMax</Authors>
<Company>Forever None</Company> <Company>Forever None</Company>
<Configurations>Debug;Release;Prerelease</Configurations>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -17,15 +17,12 @@ namespace WebfrontCore
public static void Init(IManager mgr) public static void Init(IManager mgr)
{ {
Manager = mgr; Manager = mgr;
BuildWebHost().Run(); BuildWebHost().Run();
} }
public static IWebHost BuildWebHost() public static IWebHost BuildWebHost()
{ {
var config = new ConfigurationBuilder() var config = new ConfigurationBuilder()
.AddJsonFile("WebfrontSettings.json", optional: false, reloadOnChange: false)
.AddEnvironmentVariables() .AddEnvironmentVariables()
.Build(); .Build();
@ -35,7 +32,7 @@ namespace WebfrontCore
#else #else
.UseContentRoot(Directory.GetCurrentDirectory()) .UseContentRoot(Directory.GetCurrentDirectory())
#endif #endif
.UseUrls(config["Web:Address"]) .UseUrls(Manager.GetApplicationSettings().Configuration().WebfrontBindUrl)
.UseKestrel() .UseKestrel()
.UseStartup<Startup>() .UseStartup<Startup>()
.Build(); .Build();

View File

@ -20,7 +20,6 @@ namespace WebfrontCore
{ {
var builder = new ConfigurationBuilder() var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath) .SetBasePath(env.ContentRootPath)
.AddJsonFile("WebfrontSettings.json", optional: false, reloadOnChange: false)
.AddEnvironmentVariables(); .AddEnvironmentVariables();
Configuration = builder.Build(); Configuration = builder.Build();
@ -42,17 +41,16 @@ namespace WebfrontCore
options.AccessDeniedPath = "/"; options.AccessDeniedPath = "/";
options.LoginPath = "/"; options.LoginPath = "/";
}); });
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{ {
loggerFactory.AddConsole(Configuration.GetSection("Logging")); //loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment()) if (env.IsDevelopment())
{ {
loggerFactory.AddDebug();
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();
app.UseBrowserLink(); app.UseBrowserLink();
} }

View File

@ -19,6 +19,7 @@
<ApplicationIcon /> <ApplicationIcon />
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<StartupObject /> <StartupObject />
<Configurations>Debug;Release;Prerelease</Configurations>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
@ -55,12 +56,6 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions>
<Content Update="WebfrontSettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties WebfrontSettings_1json__JSONSchema="http://json.schemastore.org/appsettings" /></VisualStudio></ProjectExtensions>
</Project> </Project>

View File

@ -1,13 +0,0 @@
{
"Logging": {
"IncludeScopes": false,
"LogLevel": {
"Default": "Trace",
"System": "Information",
"Microsoft": "None"
}
},
"Web": {
"Address": "http://127.0.0.1:5000"
}
}

View File

@ -25,6 +25,11 @@
} }
$(document).ready(function () { $(document).ready(function () {
if ($('#console_command_button').length === 0) {
return false;
}
$('#console_command_button').click(function (e) { $('#console_command_button').click(function (e) {
executeCommand(); executeCommand();
}); });

View File

@ -49,7 +49,7 @@ if ($('#penalty_table').length === 1) {
.off('scroll', ScrollHandler) .off('scroll', ScrollHandler)
.on('scroll', ScrollHandler); .on('scroll', ScrollHandler);
$('#load_penalties_button').hover(function () { $('#load_penalties_button').click(function () {
loadMorePenalties(); loadMorePenalties();
}); });
}); });

View File

@ -168,7 +168,7 @@ function loadMeta(meta) {
// it's a penalty // it's a penalty
if (meta.class.includes("Penalty")) { if (meta.class.includes("Penalty")) {
if (meta.value.punisherId !== clientInfo.clientId) { if (meta.value.punisherId !== clientInfo.clientId) {
const timeRemaining = meta.value.type == 'TempBan' && meta.value.timeRemaining.length > 0 ? const timeRemaining = meta.value.type === 'TempBan' && meta.value.timeRemaining.length > 0 ?
`(${meta.value.timeRemaining} remaining)` : `(${meta.value.timeRemaining} remaining)` :
''; '';
eventString = `<div><span class="penalties-color-${meta.value.type.toLowerCase()}">${penaltyToName(meta.value.type)}</span> by <span class="text-highlight"> <a class="link-inverse" href="${meta.value.punisherId}">${meta.value.punisherName}</a></span > for <span style="color: white; ">${meta.value.offense}</span><span class="text-muted"> ${timeRemaining}</span></div>`; eventString = `<div><span class="penalties-color-${meta.value.type.toLowerCase()}">${penaltyToName(meta.value.type)}</span> by <span class="text-highlight"> <a class="link-inverse" href="${meta.value.punisherId}">${meta.value.punisherName}</a></span > for <span style="color: white; ">${meta.value.offense}</span><span class="text-muted"> ${timeRemaining}</span></div>`;