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
{
static IMasterApi api;
public static async Task Send(ApplicationManager mgr, bool firstHeartbeat = false)
{
var api = Endpoint.Get();
if (firstHeartbeat)
{
api = RestClient.For<IMasterApi>("http://127.0.0.1");
var token = await api.Authenticate(new AuthenticationId()
{
Id = mgr.GetApplicationSettings().Configuration().Id
@ -48,12 +46,12 @@ namespace IW4MAdmin.Application.API.Master
if (firstHeartbeat)
{
instance = await api.AddInstance(instance);
var message = await api.AddInstance(instance);
}
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 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")]
public interface IMasterApi
{
@ -29,9 +53,12 @@ namespace IW4MAdmin.Application.API.Master
Task<TokenId> Authenticate([Body] AuthenticationId Id);
[Post("instance/")]
Task<ApiInstance> AddInstance([Body] ApiInstance instance);
Task<ResultMessage> AddInstance([Body] ApiInstance instance);
[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>
<ApplicationIcon />
<AssemblyName>IW4MAdmin</AssemblyName>
<Configurations>Debug;Release;Prerelease</Configurations>
</PropertyGroup>
<ItemGroup>
<None Remove="IW4MAdminSettings.json" />
</ItemGroup>
<ItemGroup>
<Content Include="IW4MAdminSettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="RestEase" Version="1.4.5" />
</ItemGroup>
@ -44,6 +34,12 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Update="DefaultSettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="call $(ProjectDir)BuildScripts\PreBuild.bat $(SolutionDir) $(ProjectDir) $(TargetDir) $(OutDir)" />
</Target>

View File

@ -1,4 +1,4 @@
{
{
"AutoMessagePeriod": 60,
"AutoMessages": [
"This server uses ^5IW4M Admin v{{VERSION}} ^7get it at ^5raidmax.org/IW4MAdmin",
@ -361,6 +361,34 @@
{
"Alias": "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(" IW4M ADMIN");
Console.WriteLine(" by RaidMax ");
Console.WriteLine($" Version {Version}");
Console.WriteLine($" Version {Version.ToString("0.0")}");
Console.WriteLine("=====================================================");
try
@ -36,9 +36,63 @@ namespace IW4MAdmin.Application
CheckDirectories();
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();
Task.Run(() =>
var consoleTask = Task.Run(() =>
{
String userInput;
Player Origin = ServerManager.GetClientService().Get(1).Result.AsPlayer();
@ -51,10 +105,13 @@ namespace IW4MAdmin.Application
ServerManager.Stop();
if (ServerManager.Servers.Count == 0)
return;
{
Console.WriteLine("No servers are currently being monitored");
continue;
}
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);
Console.Write('>');
@ -73,12 +130,12 @@ namespace IW4MAdmin.Application
catch (Exception e)
{
Console.WriteLine($"Fatal Error during initialization: {e.Message}");
Console.WriteLine($"Fatal Error during initialization");
while (e.InnerException != null)
{
e = e.InnerException;
Console.WriteLine($"Inner exception: {e.Message}");
}
Console.WriteLine($"Exception: {e.Message}");
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}

View File

@ -121,27 +121,41 @@ namespace IW4MAdmin.Application
#region CONFIG
var config = ConfigHandler.Configuration();
if (config?.Servers == null)
{
var newConfig = (ApplicationConfiguration)ConfigHandler.Configuration().Generate();
ConfigHandler.Set(newConfig);
newConfig.AutoMessagePeriod = config.AutoMessagePeriod;
newConfig.AutoMessages = config.AutoMessages;
newConfig.GlobalRules = config.GlobalRules;
newConfig.Maps = config.Maps;
newConfig.Servers = ConfigurationGenerator.GenerateServerConfig(new List<ServerConfiguration>());
config = newConfig;
await ConfigHandler.Save();
// copy over default config if it doesn't exist
if (config == null)
{
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>());
config = newConfig;
await ConfigHandler.Save();
}
}
else if(config != null)
else if (config != null)
{
if (string.IsNullOrEmpty(config.Id))
{
config.Id = Guid.NewGuid().ToString();
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)

View File

@ -36,6 +36,10 @@ Global
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|x64 = Debug|x64
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|Mixed Platforms = Release|Mixed Platforms
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|x86.ActiveCfg = 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.Build.0 = Release-Stable|Any CPU
{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|x86.ActiveCfg = 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.Build.0 = 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|x86.ActiveCfg = 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.Build.0 = 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|x86.ActiveCfg = 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.Build.0 = 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|x86.ActiveCfg = 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.Build.0 = 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|x86.ActiveCfg = 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.Build.0 = 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|x86.ActiveCfg = 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.Build.0 = 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|x86.ActiveCfg = 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.Build.0 = 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|x86.ActiveCfg = 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.Build.0 = Release|Any CPU
{F5051A32-6BD0-4128-ABBA-C202EE15FC5C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU

View File

@ -27,6 +27,11 @@
<DebugSymbols>true</DebugSymbols>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Prerelease' ">
<DebugSymbols>true</DebugSymbols>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
<OutputPath>bin\Prerelease\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Compile Include="master\context\base.py">
<SubType>Code</SubType>
@ -52,6 +57,9 @@
<Compile Include="Master\resources\null.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="Master\resources\version.py">
<SubType>Code</SubType>
</Compile>
<Compile Include="Master\resources\__init__.py">
<SubType>Code</SubType>
</Compile>
@ -76,6 +84,7 @@
<Folder Include="master\" />
<Folder Include="master\context\" />
<Folder Include="master\models\" />
<Folder Include="master\config\" />
<Folder Include="master\schema\" />
<Folder Include="Master\resources\" />
<Folder Include="Master\static\" />
@ -86,6 +95,7 @@
</ItemGroup>
<ItemGroup>
<None Include="FolderProfile.pubxml" />
<Content Include="master\config\master.json" />
<Content Include="requirements.txt" />
<Content Include="Master\static\content\bootstrap.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_jwt_extended import JWTManager
from master.context.base import Base
import json
app = Flask(__name__)
app.config['JWT_SECRET_KEY'] = 'my key!'
app.config['PROPAGATE_EXCEPTIONS'] = True
jwt = JWTManager(app)
api = Api(app)
ctx = Base()
config = json.load(open('./master/config/master.json'))
import master.routes
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))
del self.instance_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):
return self.server_list.count

View File

@ -2,6 +2,7 @@ from flask_restful import Resource
from flask import request, jsonify
from flask_jwt_extended import create_access_token
from master import app, ctx
import datetime
class Authenticate(Resource):
@ -10,7 +11,7 @@ class Authenticate(Resource):
if ctx.get_token(instance_id) is not False:
return { 'message' : 'that id already has a token'}, 401
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)
return { 'access_token' : token }, 200

View File

@ -9,7 +9,7 @@ class Instance(Resource):
def get(self, id=None):
if id is None:
schema = InstanceSchema(many=True)
instances = schema.dump(ctx.instance_list.values())
instances = schema.dump(ctx.get_instances())
return instances
else:
try:
@ -25,13 +25,13 @@ class Instance(Resource):
except ValidationError as err:
return {'message' : err.messages }, 400
ctx.update_instance(instance)
return InstanceSchema().dump(instance)
return { 'message' : 'instance updated successfully' }, 200
@jwt_required
def post(self):
try:
instance = InstanceSchema().load(request.json)
except ValidationError as err:
return err.messages
return {'message' : err.messages }, 400
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.instance import Instance
from master.resources.authenticate import Authenticate
from master.resources.version import Version
api.add_resource(Null, '/null')
api.add_resource(Instance, '/instance/', '/instance/<string:id>')
api.add_resource(Version, '/version')
api.add_resource(Authenticate, '/authenticate')

View File

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

View File

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

View File

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

View File

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

View File

@ -314,7 +314,8 @@ namespace SharedLibraryCore.Commands
bool found = false;
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(C.Syntax);

View File

@ -16,6 +16,7 @@ namespace SharedLibraryCore.Configuration
public string CustomSayName { get; set; }
public string DiscordInviteCode { get; set; }
public string IPHubAPIKey { get; set; }
public string WebfrontBindUrl { get; set; }
public string Id { get; set; }
public List<ServerConfiguration> Servers { get; set; }
public int AutoMessagePeriod { get; set; }
@ -31,6 +32,8 @@ namespace SharedLibraryCore.Configuration
EnableSteppedHierarchy = Utilities.PromptBool("Enable stepped privilege hierarchy");
EnableCustomSayName = Utilities.PromptBool("Enable custom say name");
WebfrontBindUrl = "http://127.0.0.1:1624";
if (EnableCustomSayName)
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);
}
// not a valid assembly, ie plugin files
// not a valid assembly, ie plugin support files
catch (Exception)
{
continue;

View File

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

View File

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

View File

@ -20,7 +20,6 @@ namespace WebfrontCore
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("WebfrontSettings.json", optional: false, reloadOnChange: false)
.AddEnvironmentVariables();
Configuration = builder.Build();
@ -42,17 +41,16 @@ namespace WebfrontCore
options.AccessDeniedPath = "/";
options.LoginPath = "/";
});
}
// 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)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
//loggerFactory.AddConsole(Configuration.GetSection("Logging"));
if (env.IsDevelopment())
{
loggerFactory.AddDebug();
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}

View File

@ -19,6 +19,7 @@
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
<Configurations>Debug;Release;Prerelease</Configurations>
</PropertyGroup>
<ItemGroup>
@ -55,12 +56,6 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Update="WebfrontSettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties WebfrontSettings_1json__JSONSchema="http://json.schemastore.org/appsettings" /></VisualStudio></ProjectExtensions>
<ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions>
</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 () {
if ($('#console_command_button').length === 0) {
return false;
}
$('#console_command_button').click(function (e) {
executeCommand();
});

View File

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

View File

@ -168,7 +168,7 @@ function loadMeta(meta) {
// it's a penalty
if (meta.class.includes("Penalty")) {
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)` :
'';
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>`;