rcon command formatted to work in linux

fixes to work with mono
This commit is contained in:
RaidMax 2018-04-07 14:49:00 -05:00
parent 6f2e0bfff1
commit 164f121d22
9 changed files with 30 additions and 73 deletions

View File

@ -230,7 +230,6 @@ namespace StatsPlugin
MetaService.AddMeta(getMessages);
// todo: is this fast? make async?
string totalKills()
{
var serverStats = new GenericRepository<EFServerStatistics>();

View File

@ -13,7 +13,7 @@ namespace SharedLibrary.Plugins
public static bool Load(IManager Manager)
{
string[] dllFileNames = Directory.GetFiles(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\plugins", "*.dll");
string[] dllFileNames = Directory.GetFiles($"{Utilities.OperatingDirectory}Plugins{Path.DirectorySeparatorChar}", "*.dll");
if (dllFileNames.Length == 0)
{

View File

@ -1,6 +1,7 @@
using SharedLibrary.Exceptions;
using SharedLibrary.Interfaces;
using System;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
@ -180,7 +181,7 @@ namespace SharedLibrary.RCon
break;
}
byte[] payload = Encoding.Default.GetBytes(queryString);
byte[] payload = queryString.Select(Convert.ToByte).ToArray();
retrySend:
try

View File

@ -258,7 +258,6 @@ namespace SharedLibrary
/// <summary>
/// Initialize the messages to be broadcasted
/// todo: this needs to be a serialized file
/// </summary>
protected void InitializeAutoMessages()
{

View File

@ -625,10 +625,6 @@ namespace IW4MAdmin
await this.SetDvarAsync("sv_kickbantime", 60);
// I don't think this belongs in an admin tool
/*await this.SetDvarAsync("sv_network_fps", 1000);
await this.SetDvarAsync("com_maxfps", 1000);*/
if (logsync.Value == 0 || logfile.Value == string.Empty)
{
// this DVAR isn't set until the a map is loaded
@ -641,14 +637,7 @@ namespace IW4MAdmin
}
CustomCallback = await ScriptLoaded();
#if DEBUG
{
basepath.Value = (GameName == Game.IW4) ?
@"D:\" :
@"\\tsclient\G\Program Files (x86)\Steam\SteamApps\common\Call of Duty 4";
}
#endif
string mainPath = (GameName == Game.IW4 && onelog.Value >= 0) ? "userraw" : "main";
// patch for T5M:V2 log path
mainPath = (GameName == Game.T5M) ? "rzodemo" : mainPath;
@ -657,6 +646,12 @@ namespace IW4MAdmin
$"{basepath.Value.Replace('\\', Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}{mainPath}{Path.DirectorySeparatorChar}{logfile.Value}" :
$"{basepath.Value.Replace('\\', Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}{game.Value.Replace('/', Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}{logfile.Value}";
// fix to prevent wine drive prefix when running in mono
if (Utilities.IsRunningOnMono())
{
logPath = Regex.Replace(logPath, @"[A-Z]:", "");
}
if (!File.Exists(logPath))
{
Logger.WriteError($"Gamelog {logPath} does not exist!");
@ -666,15 +661,13 @@ namespace IW4MAdmin
}
else
{
//#if !DEBUG
LogFile = new IFile(logPath);
//#else
}
Logger.WriteInfo($"Log file is {logPath}");
#if DEBUG
//LogFile = new RemoteFile("https://raidmax.org/IW4MAdmin/getlog.php");
#endif
Logger.WriteInfo($"Log file is {logPath}");
#if !DEBUG
#else
await Broadcast("IW4M Admin is now ^2ONLINE");
#endif
}
@ -693,18 +686,6 @@ namespace IW4MAdmin
if (E.Origin.Level > Player.Permission.Moderator)
await E.Origin.Tell($"There are ^5{Reports.Count} ^7recent reports");
/*// give trusted rank
if (Manager.GetApplicationSettings().Configuration().EnableSteppedHierarchy &&
E.Origin.TotalConnectionTime / 60.0 >= 2880 &&
E.Origin.Level < Player.Permission.Trusted &&
E.Origin.Level != Player.Permission.Flagged)
{
E.Origin.Level = Player.Permission.Trusted;
await E.Origin.Tell("Congratulations, you are now a ^5trusted ^7player! Type ^5!help ^7to view new commands");
await E.Origin.Tell("You earned this by playing for ^53 ^7full days");
await Manager.GetClientService().Update(E.Origin);
}*/
}
else if (E.Type == Event.GType.Disconnect)
@ -786,39 +767,6 @@ namespace IW4MAdmin
string mapname = this.GetDvarAsync<string>("mapname").Result.Value;
CurrentMap = Maps.Find(m => m.Name == mapname) ?? new Map() { Alias = mapname, Name = mapname };
// todo: make this more efficient
/*((ApplicationManager)(Manager)).PrivilegedClients = new Dictionary<int, Player>();
var ClientSvc = new ClientService();
var ipList = (await ClientSvc.Find(c => c.Level > Player.Permission.Trusted))
.Select(c => new
{
c.Password,
c.PasswordSalt,
c.ClientId,
c.Level,
c.Name
});
foreach (var a in ipList)
{
try
{
((ApplicationManager)(Manager)).PrivilegedClients.Add(a.ClientId, new Player()
{
Name = a.Name,
ClientId = a.ClientId,
Level = a.Level,
PasswordSalt = a.PasswordSalt,
Password = a.Password
});
}
catch (ArgumentException)
{
continue;
}
}*/
}
if (E.Type == Event.GType.MapEnd)
@ -975,7 +923,7 @@ namespace IW4MAdmin
Target.Level = Player.Permission.Banned;
#if !DEBUG
await Target.CurrentServer.ExecuteCommandAsync($"clientkick {Target.ClientNumber} \"Player Banned: ^5{Message} ^7(appeal at {Website}) ^7\"");
#else
#else
await Target.CurrentServer.RemovePlayer(Target.ClientNumber);
#endif
}

View File

@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
@ -15,12 +16,19 @@ namespace WebfrontCore
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.UseUrls(config["Web:Address"])
.Build();
host.Run();
if (!SharedLibrary.Utilities.IsRunningOnMono())
{
host.Run();
}
else
{
Console.ReadLine();
}
}
}
}

View File

@ -17,7 +17,6 @@ namespace WebfrontCore
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
.AddEnvironmentVariables();
Configuration = builder.Build();
// fixme: this is really really terrible
if (!SharedLibrary.Utilities.IsRunningOnMono())
@ -63,11 +62,11 @@ namespace WebfrontCore
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AccessDeniedPath = "/Account/Login/",
AccessDeniedPath = "/",
AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme,
AutomaticAuthenticate = true,
AutomaticChallenge = true,
LoginPath = "/Account/Login/",
LoginPath = "/",
ExpireTimeSpan = TimeSpan.FromDays(30),
});

View File

@ -85,6 +85,9 @@
</ItemGroup>
<ItemGroup>
<Content Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Update="IW4MAdminSettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

View File

@ -12,6 +12,6 @@
},
"ConnectionStrings": {
"WindowsConnection": "Data Source=|DataDirectory|\\Database.sdf",
"LinuxConnection": "server=server;user=user;database=db;password=pass"
"LinuxConnection": "Server=127.0.0.1;User=user;Database=IW4MAdmin;Password=password"
}
}