rcon command formatted to work in linux
fixes to work with mono
This commit is contained in:
parent
6f2e0bfff1
commit
164f121d22
@ -230,7 +230,6 @@ namespace StatsPlugin
|
|||||||
|
|
||||||
MetaService.AddMeta(getMessages);
|
MetaService.AddMeta(getMessages);
|
||||||
|
|
||||||
// todo: is this fast? make async?
|
|
||||||
string totalKills()
|
string totalKills()
|
||||||
{
|
{
|
||||||
var serverStats = new GenericRepository<EFServerStatistics>();
|
var serverStats = new GenericRepository<EFServerStatistics>();
|
||||||
|
@ -13,7 +13,7 @@ namespace SharedLibrary.Plugins
|
|||||||
|
|
||||||
public static bool Load(IManager Manager)
|
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)
|
if (dllFileNames.Length == 0)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using SharedLibrary.Exceptions;
|
using SharedLibrary.Exceptions;
|
||||||
using SharedLibrary.Interfaces;
|
using SharedLibrary.Interfaces;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -180,7 +181,7 @@ namespace SharedLibrary.RCon
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] payload = Encoding.Default.GetBytes(queryString);
|
byte[] payload = queryString.Select(Convert.ToByte).ToArray();
|
||||||
|
|
||||||
retrySend:
|
retrySend:
|
||||||
try
|
try
|
||||||
|
@ -258,7 +258,6 @@ namespace SharedLibrary
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initialize the messages to be broadcasted
|
/// Initialize the messages to be broadcasted
|
||||||
/// todo: this needs to be a serialized file
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void InitializeAutoMessages()
|
protected void InitializeAutoMessages()
|
||||||
{
|
{
|
||||||
|
@ -625,10 +625,6 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
await this.SetDvarAsync("sv_kickbantime", 60);
|
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)
|
if (logsync.Value == 0 || logfile.Value == string.Empty)
|
||||||
{
|
{
|
||||||
// this DVAR isn't set until the a map is loaded
|
// this DVAR isn't set until the a map is loaded
|
||||||
@ -641,14 +637,7 @@ namespace IW4MAdmin
|
|||||||
}
|
}
|
||||||
|
|
||||||
CustomCallback = await ScriptLoaded();
|
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";
|
string mainPath = (GameName == Game.IW4 && onelog.Value >= 0) ? "userraw" : "main";
|
||||||
// patch for T5M:V2 log path
|
// patch for T5M:V2 log path
|
||||||
mainPath = (GameName == Game.T5M) ? "rzodemo" : mainPath;
|
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}{mainPath}{Path.DirectorySeparatorChar}{logfile.Value}" :
|
||||||
$"{basepath.Value.Replace('\\', Path.DirectorySeparatorChar)}{Path.DirectorySeparatorChar}{game.Value.Replace('/', Path.DirectorySeparatorChar)}{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))
|
if (!File.Exists(logPath))
|
||||||
{
|
{
|
||||||
Logger.WriteError($"Gamelog {logPath} does not exist!");
|
Logger.WriteError($"Gamelog {logPath} does not exist!");
|
||||||
@ -666,15 +661,13 @@ namespace IW4MAdmin
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//#if !DEBUG
|
|
||||||
LogFile = new IFile(logPath);
|
LogFile = new IFile(logPath);
|
||||||
//#else
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.WriteInfo($"Log file is {logPath}");
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
//LogFile = new RemoteFile("https://raidmax.org/IW4MAdmin/getlog.php");
|
//LogFile = new RemoteFile("https://raidmax.org/IW4MAdmin/getlog.php");
|
||||||
#endif
|
#else
|
||||||
Logger.WriteInfo($"Log file is {logPath}");
|
|
||||||
#if !DEBUG
|
|
||||||
await Broadcast("IW4M Admin is now ^2ONLINE");
|
await Broadcast("IW4M Admin is now ^2ONLINE");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -693,18 +686,6 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
if (E.Origin.Level > Player.Permission.Moderator)
|
if (E.Origin.Level > Player.Permission.Moderator)
|
||||||
await E.Origin.Tell($"There are ^5{Reports.Count} ^7recent reports");
|
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)
|
else if (E.Type == Event.GType.Disconnect)
|
||||||
@ -786,39 +767,6 @@ namespace IW4MAdmin
|
|||||||
|
|
||||||
string mapname = this.GetDvarAsync<string>("mapname").Result.Value;
|
string mapname = this.GetDvarAsync<string>("mapname").Result.Value;
|
||||||
CurrentMap = Maps.Find(m => m.Name == mapname) ?? new Map() { Alias = mapname, Name = mapname };
|
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)
|
if (E.Type == Event.GType.MapEnd)
|
||||||
@ -975,7 +923,7 @@ namespace IW4MAdmin
|
|||||||
Target.Level = Player.Permission.Banned;
|
Target.Level = Player.Permission.Banned;
|
||||||
#if !DEBUG
|
#if !DEBUG
|
||||||
await Target.CurrentServer.ExecuteCommandAsync($"clientkick {Target.ClientNumber} \"Player Banned: ^5{Message} ^7(appeal at {Website}) ^7\"");
|
await Target.CurrentServer.ExecuteCommandAsync($"clientkick {Target.ClientNumber} \"Player Banned: ^5{Message} ^7(appeal at {Website}) ^7\"");
|
||||||
#else
|
#else
|
||||||
await Target.CurrentServer.RemovePlayer(Target.ClientNumber);
|
await Target.CurrentServer.RemovePlayer(Target.ClientNumber);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.IO;
|
using System;
|
||||||
|
using System.IO;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
@ -15,12 +16,19 @@ namespace WebfrontCore
|
|||||||
var host = new WebHostBuilder()
|
var host = new WebHostBuilder()
|
||||||
.UseKestrel()
|
.UseKestrel()
|
||||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||||
.UseIISIntegration()
|
|
||||||
.UseStartup<Startup>()
|
.UseStartup<Startup>()
|
||||||
.UseUrls(config["Web:Address"])
|
.UseUrls(config["Web:Address"])
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
host.Run();
|
if (!SharedLibrary.Utilities.IsRunningOnMono())
|
||||||
|
{
|
||||||
|
host.Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ namespace WebfrontCore
|
|||||||
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
|
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
|
||||||
.AddEnvironmentVariables();
|
.AddEnvironmentVariables();
|
||||||
|
|
||||||
|
|
||||||
Configuration = builder.Build();
|
Configuration = builder.Build();
|
||||||
// fixme: this is really really terrible
|
// fixme: this is really really terrible
|
||||||
if (!SharedLibrary.Utilities.IsRunningOnMono())
|
if (!SharedLibrary.Utilities.IsRunningOnMono())
|
||||||
@ -63,11 +62,11 @@ namespace WebfrontCore
|
|||||||
|
|
||||||
app.UseCookieAuthentication(new CookieAuthenticationOptions()
|
app.UseCookieAuthentication(new CookieAuthenticationOptions()
|
||||||
{
|
{
|
||||||
AccessDeniedPath = "/Account/Login/",
|
AccessDeniedPath = "/",
|
||||||
AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme,
|
AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme,
|
||||||
AutomaticAuthenticate = true,
|
AutomaticAuthenticate = true,
|
||||||
AutomaticChallenge = true,
|
AutomaticChallenge = true,
|
||||||
LoginPath = "/Account/Login/",
|
LoginPath = "/",
|
||||||
ExpireTimeSpan = TimeSpan.FromDays(30),
|
ExpireTimeSpan = TimeSpan.FromDays(30),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -85,6 +85,9 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Content Update="appsettings.json">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Update="IW4MAdminSettings.json">
|
<Content Update="IW4MAdminSettings.json">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
|
@ -12,6 +12,6 @@
|
|||||||
},
|
},
|
||||||
"ConnectionStrings": {
|
"ConnectionStrings": {
|
||||||
"WindowsConnection": "Data Source=|DataDirectory|\\Database.sdf",
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user