-added !ip command (prints a client's external IP)

-fixed up the findall command
-moved aliases to the manager
-added admins page to view privileged users
-fixed refactoring mistake with messages
This commit is contained in:
RaidMax 2017-08-17 18:28:08 -05:00
parent 7c0ad5c021
commit 6a94882d20
15 changed files with 276 additions and 105 deletions

View File

@ -158,6 +158,9 @@
<Content Include="version.txt"> <Content Include="version.txt">
<CopyToOutputDirectory>Always</CopyToOutputDirectory> <CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content> </Content>
<Content Include="webfront\admins.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="webfront\bans.html"> <Content Include="webfront\bans.html">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>

View File

@ -45,6 +45,9 @@ namespace IW4MAdmin
querySet = System.Web.HttpUtility.ParseQueryString(SharedLibrary.Utilities.StripIllegalCharacters(request.QueryString)); querySet = System.Web.HttpUtility.ParseQueryString(SharedLibrary.Utilities.StripIllegalCharacters(request.QueryString));
querySet.Set("IP", IP); querySet.Set("IP", IP);
try
{
SharedLibrary.HttpResponse requestedPage = WebService.GetPage(request.Path, querySet, request.Headers); SharedLibrary.HttpResponse requestedPage = WebService.GetPage(request.Path, querySet, request.Headers);
var headers = new HttpResponseHead() var headers = new HttpResponseHead()
@ -63,6 +66,21 @@ namespace IW4MAdmin
response.OnResponse(headers, new BufferedProducer(requestedPage.content)); response.OnResponse(headers, new BufferedProducer(requestedPage.content));
} }
catch (Exception e)
{
ApplicationManager.GetInstance().Logger.WriteError($"Webfront error during request: {e.Message}");
response.OnResponse(new HttpResponseHead()
{
Status = "500 Internal Server Error",
Headers = new Dictionary<string, string>()
{
{ "Content-Type", "text/html" },
{ "Content-Length", "0"},
}
}, new BufferedProducer(""));
}
}
} }
class BufferedProducer : IDataProducer class BufferedProducer : IDataProducer

View File

@ -161,6 +161,7 @@ namespace IW4MAdmin
Commands.Add(new CExecuteRCON("rcon", "send rcon command to server. syntax: !rcon <command>", "rcon", Player.Permission.Owner, 1, false)); Commands.Add(new CExecuteRCON("rcon", "send rcon command to server. syntax: !rcon <command>", "rcon", Player.Permission.Owner, 1, false));
Commands.Add(new CFindAllPlayers("findall", "find a player by their aliase(s). syntax: !findall <player>", "fa", Player.Permission.Moderator, 1, false)); Commands.Add(new CFindAllPlayers("findall", "find a player by their aliase(s). syntax: !findall <player>", "fa", Player.Permission.Moderator, 1, false));
Commands.Add(new CPlugins("plugins", "view all loaded plugins. syntax: !plugins", "p", Player.Permission.Administrator, 0, false)); Commands.Add(new CPlugins("plugins", "view all loaded plugins. syntax: !plugins", "p", Player.Permission.Administrator, 0, false));
Commands.Add(new CIP("ip", "view your external IP address. syntax: !ip", "getexternalip", Player.Permission.User, 0, false));
foreach (Command C in SharedLibrary.Plugins.PluginImporter.ActiveCommands) foreach (Command C in SharedLibrary.Plugins.PluginImporter.ActiveCommands)
Commands.Add(C); Commands.Add(C);
@ -247,5 +248,49 @@ namespace IW4MAdmin
return ActiveClients; return ActiveClients;
} }
public IList<Player> GetAliasClients(Player Origin)
{
List<int> databaseIDs = new List<int>();
foreach (Aliases A in GetAliases(Origin))
databaseIDs.Add(A.Number);
return GetClientDatabase().GetPlayers(databaseIDs);
}
public IList<Aliases> GetAliases(Player Origin)
{
List<Aliases> allAliases = new List<Aliases>();
if (Origin == null)
return allAliases;
Aliases currentIdentityAliases = GetAliasesDatabase().GetPlayerAliases(Origin.DatabaseID);
if (currentIdentityAliases == null)
return allAliases;
GetAliases(allAliases, currentIdentityAliases);
if (Origin.Alias != null)
allAliases.Add(Origin.Alias);
return allAliases;
}
private void GetAliases(List<Aliases> returnAliases, Aliases currentAlias)
{
foreach (String IP in currentAlias.IPS)
{
List<Aliases> Matching = GetAliasesDatabase().GetPlayerAliases(IP);
foreach (Aliases I in Matching)
{
if (!returnAliases.Contains(I) && returnAliases.Find(x => x.Number == I.Number) == null)
{
returnAliases.Add(I);
GetAliases(returnAliases, I);
}
}
}
}
} }
} }

View File

@ -15,40 +15,6 @@ namespace IW4MAdmin
{ {
public IW4MServer(IManager mgr, ServerConfiguration cfg) : base(mgr, cfg) { } public IW4MServer(IManager mgr, ServerConfiguration cfg) : base(mgr, cfg) { }
private void GetAliases(List<Aliases> returnAliases, Aliases currentAlias)
{
foreach(String IP in currentAlias.IPS)
{
List<Aliases> Matching = Manager.GetAliasesDatabase().GetPlayerAliases(IP);
foreach(Aliases I in Matching)
{
if (!returnAliases.Contains(I) && returnAliases.Find(x => x.Number == I.Number) == null)
{
returnAliases.Add(I);
GetAliases(returnAliases, I);
}
}
}
}
public override List<Aliases> GetAliases(Player Origin)
{
List<Aliases> allAliases = new List<Aliases>();
if (Origin == null)
return allAliases;
Aliases currentIdentityAliases = Manager.GetAliasesDatabase().GetPlayerAliases(Origin.DatabaseID);
if (currentIdentityAliases == null)
return allAliases;
GetAliases(allAliases, currentIdentityAliases);
if (Origin.Alias != null)
allAliases.Add(Origin.Alias);
return allAliases;
}
override public async Task<bool> AddPlayer(Player P) override public async Task<bool> AddPlayer(Player P)
{ {
if (P.ClientID < 0 || P.ClientID > (Players.Count-1) || P.Ping < 1 || P.Ping == 999) // invalid index if (P.ClientID < 0 || P.ClientID > (Players.Count-1) || P.Ping < 1 || P.Ping == 999) // invalid index
@ -123,7 +89,7 @@ namespace IW4MAdmin
return true; return true;
} }
var newPlayerAliases = GetPlayerAliases(NewPlayer); var newPlayerAliases = Manager.GetAliasClients(NewPlayer);
foreach (Player aP in newPlayerAliases) // lets check their aliases foreach (Player aP in newPlayerAliases) // lets check their aliases
{ {
@ -153,7 +119,6 @@ namespace IW4MAdmin
if (NewPlayer.Level > Player.Permission.Moderator) if (NewPlayer.Level > Player.Permission.Moderator)
await NewPlayer.Tell("There are ^5" + Reports.Count + " ^7recent reports!"); await NewPlayer.Tell("There are ^5" + Reports.Count + " ^7recent reports!");
ClientNum++;
return true; return true;
} }
@ -168,7 +133,7 @@ namespace IW4MAdmin
//Remove player by CLIENT NUMBER //Remove player by CLIENT NUMBER
override public async Task RemovePlayer(int cNum) override public async Task RemovePlayer(int cNum)
{ {
if (cNum >= 0 && cNum < Players.Count) if (cNum >= 0)
{ {
Player Leaving = Players[cNum]; Player Leaving = Players[cNum];
Leaving.Connections++; Leaving.Connections++;
@ -177,8 +142,6 @@ namespace IW4MAdmin
Logger.WriteInfo($"Client {Leaving.Name}::{Leaving.NetworkID} disconnecting..."); Logger.WriteInfo($"Client {Leaving.Name}::{Leaving.NetworkID} disconnecting...");
await ExecuteEvent(new Event(Event.GType.Disconnect, "", Leaving, null, this)); await ExecuteEvent(new Event(Event.GType.Disconnect, "", Leaving, null, this));
Players[cNum] = null; Players[cNum] = null;
ClientNum--;
} }
} }
@ -315,7 +278,7 @@ namespace IW4MAdmin
} }
} }
async Task PollPlayersAsync() async Task<int> PollPlayersAsync()
{ {
var CurrentPlayers = await this.GetStatusAsync(); var CurrentPlayers = await this.GetStatusAsync();
@ -327,6 +290,8 @@ namespace IW4MAdmin
foreach (var P in CurrentPlayers) foreach (var P in CurrentPlayers)
await AddPlayer(P); await AddPlayer(P);
return CurrentPlayers.Count;
} }
long l_size = -1; long l_size = -1;
@ -349,7 +314,7 @@ namespace IW4MAdmin
try try
{ {
await PollPlayersAsync(); ClientNum = await PollPlayersAsync();
if (ConnectionErrors > 0) if (ConnectionErrors > 0)
{ {
@ -389,10 +354,10 @@ namespace IW4MAdmin
playerCountStart = DateTime.Now; playerCountStart = DateTime.Now;
} }
if (LastMessage.TotalSeconds > MessageTime && BroadcastMessages.Count > 0 && Players.Count > 0) if (LastMessage.TotalSeconds > MessageTime && BroadcastMessages.Count > 0 && ClientNum > 0)
{ {
await Broadcast(Utilities.ProcessMessageToken(Manager.GetMessageTokens(), BroadcastMessages[NextMessage])); Console.WriteLine(Utilities.ProcessMessageToken(Manager.GetMessageTokens(), BroadcastMessages[NextMessage]));
NextMessage = NextMessage == (BroadcastMessages.Count - 1) ? 0 : NextMessage++; NextMessage = NextMessage == (BroadcastMessages.Count - 1) ? 0 : NextMessage + 1;
start = DateTime.Now; start = DateTime.Now;
} }

View File

@ -29,6 +29,8 @@ namespace IW4MAdmin
SharedLibrary.WebService.PageList.Add(new WebConsole()); SharedLibrary.WebService.PageList.Add(new WebConsole());
SharedLibrary.WebService.PageList.Add(new ConsoleJSON()); SharedLibrary.WebService.PageList.Add(new ConsoleJSON());
SharedLibrary.WebService.PageList.Add(new PubbansJSON()); SharedLibrary.WebService.PageList.Add(new PubbansJSON());
SharedLibrary.WebService.PageList.Add(new AdminsJSON());
SharedLibrary.WebService.PageList.Add(new Admins());
Thread scheduleThread = new Thread(() => { ScheduleThreadStart(webScheduler, webService); }) Thread scheduleThread = new Thread(() => { ScheduleThreadStart(webScheduler, webService); })
{ {
@ -521,6 +523,69 @@ namespace IW4MAdmin
} }
} }
class Admins : HTMLPage
{
public override string GetName()
{
return "Admins";
}
public override string GetPath()
{
return "/Admins";
}
public override string GetContent(System.Collections.Specialized.NameValueCollection querySet, IDictionary<string, string> headers)
{
StringBuilder S = new StringBuilder();
S.Append(LoadHeader());
IFile admins = new IFile("webfront\\admins.html");
S.Append(admins.GetText());
admins.Close();
S.Append(LoadFooter());
return S.ToString();
}
}
class AdminsJSON : IPage
{
public string GetName()
{
return "Admins Json";
}
public string GetPath()
{
return "/GetAdmins";
}
public HttpResponse GetPage(System.Collections.Specialized.NameValueCollection querySet, IDictionary<string, string> headers)
{
var Admins = ApplicationManager.GetInstance().GetClientDatabase().GetAdmins().OrderByDescending(a => a.Level);
HttpResponse resp = new HttpResponse()
{
contentType = GetContentType(),
content = Newtonsoft.Json.JsonConvert.SerializeObject(Admins, Newtonsoft.Json.Formatting.Indented),
additionalHeaders = new Dictionary<string, string>()
};
return resp;
}
public string GetContentType()
{
return "application/json";
}
public bool Visible()
{
return false;
}
}
class PubbansJSON : IPage class PubbansJSON : IPage
{ {
public string GetName() public string GetName()
@ -631,7 +696,8 @@ namespace IW4MAdmin
contentType = GetContentType(), contentType = GetContentType(),
additionalHeaders = new Dictionary<string, string>() additionalHeaders = new Dictionary<string, string>()
}; };
bool authed = ApplicationManager.GetInstance().GetClientDatabase().GetAdmins().FindAll(x => x.IP == querySet["IP"]).Count > 0; bool authed = ApplicationManager.GetInstance().GetClientDatabase().GetAdmins().FindAll(x => x.IP == querySet["IP"] && x.Level > Player.Permission.Trusted).Count > 0
|| querySet["IP"] == "127.0.0.1";
bool recent = false; bool recent = false;
if (querySet["id"] != null) if (querySet["id"] != null)
@ -675,7 +741,7 @@ namespace IW4MAdmin
if (!recent) if (!recent)
{ {
foreach (var a in ApplicationManager.GetInstance().Servers.First().GetAliases(pp)) foreach (var a in ApplicationManager.GetInstance().GetAliases(pp))
{ {
eachPlayer.playerAliases = a.Names; eachPlayer.playerAliases = a.Names;
eachPlayer.playerIPs = a.IPS; eachPlayer.playerIPs = a.IPS;
@ -765,4 +831,11 @@ namespace IW4MAdmin
{ {
public List<string> Result; public List<string> Result;
} }
[Serializable]
class PrivilegedUsers
{
public Player.Permission Permission { get; set; }
public List<Player> Players { get; set; }
}
} }

Binary file not shown.

View File

@ -3,8 +3,13 @@ CHANGELOG:
-works: with COD, WaW, MW3, BO1 (preliminary without extensive testing) -works: with COD, WaW, MW3, BO1 (preliminary without extensive testing)
-fixed the issue with webfront chat history -fixed the issue with webfront chat history
-fixed console issue of spamming 'polling rate decreased' when server goes offline -fixed console issue of spamming 'polling rate decreased' when server goes offline
-'unknown' admin in webfront defaults to 'IW4MAdmin' -'unknown' admin in webfront defaults to 'IW4MAdmin' (refactoring mistake)
-streamlined the async server initialization -streamlined the async server initialization
-added !ip command (prints a client's external IP)
-fixed up the findall command
-moved aliases to the manager
-added admins page to view privileged users
-fixed refactoring mistake with messages
VERSION 1.3 VERSION 1.3

View File

@ -0,0 +1,71 @@
<script>
function printPlayer(player, i)
{
var p = "";
p +=
"<div class=\"playerInfo table alternate_" + i % 2 + "\"> \
<div class=\"tableCell\"><a href=\"/players?id=" + player['playerID'] + "\">" + player['playerName'] + "</a></div> \
<div class=\"tableCell\">" + formatHidden(player['playerAliases'], player.authed) + "</div> \
<div class=\"tableCell\">" + formatHidden(player['playerIPs'], player.authed) + "</div> \
<div class=\"tableCell\">" + getColorForLevel(player['playerLevel'], player['playerLevel']) + "</div> \
<div class=\"tableCell\">" + player['playerConnections'] + "</div>";
if (player.showV2Features)
{
p +=
"<div class=\"tableCell actionButton\" style='width: 2em;'> \
<a target=\"_blank\" href='http://server.nbsclan.org/screen.php?id=" + player.forumID + "&name=" + player.playerName + "'> \
<i class=\"fa fa-camera\" aria-hidden=\"true\"></i> \
</a> \
<a target=\"_blank\" href='https://v2.mcsebi.ru/memberlist.php?mode=viewprofile&u=" + player.forumID + "'> \
<i class=\"fa fa-user tableCell\" aria-hidden=\"true\"></i> \
</a> \
</div> ";
}
else
{
p+=
"<div class=\"tableCell\" style='width: 2em;'><i class=\"fa fa-ban\" aria-hidden=\"true\"></i></div>"
}
p +=
"<div class=\"tableCell alignRight\">" + checkJustNow(player['lastSeen']) + "</div> \
</div>";
$("#playersTable").append(p);
}
function getAdmins() {
$.getJSON('/GetAdmins', function(result) {
$.each(result, function(i, player) {
printPlayer(player, i);
});
}).done(function (data) { $(".loader").fadeOut(); });
}
$( document ).ready(function() {
getAdmins();
});
</script>
<div class="playerSearchWrap">
<input type="button" class="searchButton" name="Search" value="Search"/>
<input type="text" class="search" placeholder="Player Name..."/>
</div>
<div class="contentHeader table">
<div class="contentColumn tableCell">Name</div>
<div class="contentColumn tableCell">Aliases</div>
<div class="contentColumn tableCell">IP</div>
<div class="contentColumn tableCell">Level</div>
<div class="contentColumn tableCell">Connections</div>
<div class="contentColumn tableCell" style="width: 1em;">V2</div>
<div class="contentColumn tableCell alignRight">Last Seen</div>
</div>
<div id="playersTable">
</div>
<hr/>

View File

@ -1,6 +1,6 @@
# <span style="color: #007ACC;">IW4MAdmin</span> # <span style="color: #007ACC;">IW4MAdmin</span>
### <span style="color: #007ACC; opacity:0.75;">Quick Start Guide</span> ### <span style="color: #007ACC; opacity:0.75;">Quick Start Guide</span>
### Version 1.2 ### Version 1.4
_______ _______
### Setup ### Setup
@ -46,7 +46,6 @@ ___
|owner |claim ownership of your server | False | 0 | None | |owner |claim ownership of your server | False | 0 | None |
|setlevel |set player to specified administration level | True | 2 | Owner | |setlevel |set player to specified administration level | True | 2 | Owner |
|rcon |send rcon command to server | False | 1 | Owner | |rcon |send rcon command to server | False | 1 | Owner |
|reserve |give player reserved status to join on full server | True | 1 | Owner |
|ban |permanently ban a player from the server | True | 2 | SeniorAdmin | |ban |permanently ban a player from the server | True | 2 | SeniorAdmin |
|unban |unban player by database id | True | 1 | SeniorAdmin | |unban |unban player by database id | True | 1 | SeniorAdmin |
|find |find player in the database | False | 1 | SeniorAdmin | |find |find player in the database | False | 1 | SeniorAdmin |

View File

@ -434,7 +434,7 @@ namespace SharedLibrary.Commands
Player Current = E.Owner.Manager.GetClientDatabase().GetPlayer(P.Number); Player Current = E.Owner.Manager.GetClientDatabase().GetPlayer(P.Number);
if (Current != null) if (Current != null && Current.Name != lookingFor)
{ {
String mesg = String.Format("^1{0} ^7now goes by ^5{1}^7 [^3{2}^7]", lookingFor, Current.Name, Current.DatabaseID); String mesg = String.Format("^1{0} ^7now goes by ^5{1}^7 [^3{2}^7]", lookingFor, Current.Name, Current.DatabaseID);
await E.Origin.Tell(mesg); await E.Origin.Tell(mesg);
@ -705,5 +705,16 @@ namespace SharedLibrary.Commands
} }
} }
} }
public class CIP : Command
{
public CIP(String N, String D, String U, Player.Permission P, int args, bool nT) : base(N, D, U, P, args, nT) { }
public override async Task ExecuteAsync(Event E)
{
await E.Origin.Tell($"Your external IP is ^5{E.Origin.IP}");
}
}
} }

View File

@ -485,11 +485,11 @@ namespace SharedLibrary
public List<Player> GetAdmins() public List<Player> GetAdmins()
{ {
List<Player> Admins = new List<Player>(); List<Player> Admins = new List<Player>();
String Query = String.Format("SELECT * FROM CLIENTS WHERE Level >= '{0}'", (int)Player.Permission.Moderator); String Query = String.Format("SELECT * FROM CLIENTS WHERE Level >= '{0}' ORDER BY Name", (int)Player.Permission.Trusted);
DataTable Result = GetDataTable(Query); DataTable Result = GetDataTable(Query);
foreach (DataRow P in Result.Rows) foreach (DataRow P in Result.Rows)
Admins.Add(new Player(P["Name"].ToString(), P["npID"].ToString(), (Player.Permission)P["Level"], P["IP"].ToString(), P["UID"].ToString())); Admins.Add(new Player(P["Name"].ToString(), P["npID"].ToString(), (Player.Permission)P["Level"], P["IP"].ToString(), P["UID"].ToString(), Convert.ToInt32(P["Number"].ToString())));
return Admins; return Admins;
} }
@ -634,8 +634,8 @@ namespace SharedLibrary
{ {
CommandText = "SELECT * FROM ALIASES WHERE NAMES LIKE @name OR IPS LIKE @ip LIMIT 15" CommandText = "SELECT * FROM ALIASES WHERE NAMES LIKE @name OR IPS LIKE @ip LIMIT 15"
}; };
cmd.Parameters.AddWithValue("@name", name); cmd.Parameters.AddWithValue("@name", '%' + name + '%');
cmd.Parameters.AddWithValue("@ip", DefaultIP); cmd.Parameters.AddWithValue("@ip", '%' + DefaultIP + '%');
var Result = GetDataTable(cmd); var Result = GetDataTable(cmd);

View File

@ -15,5 +15,7 @@ namespace SharedLibrary.Interfaces
AliasesDB GetAliasesDatabase(); AliasesDB GetAliasesDatabase();
IList<Helpers.MessageToken> GetMessageTokens(); IList<Helpers.MessageToken> GetMessageTokens();
IList<Player> GetActiveClients(); IList<Player> GetActiveClients();
IList<Player> GetAliasClients(Player player);
IList<Aliases> GetAliases(Player player);
} }
} }

View File

@ -69,7 +69,7 @@ namespace SharedLibrary
LastConnection = DateTime.Now; LastConnection = DateTime.Now;
} }
public Player(String n, String id, Player.Permission P, String I, String UID) public Player(String n, String id, Player.Permission P, String I, String UID, int dbid)
{ {
Name = n; Name = n;
NetworkID = id; NetworkID = id;
@ -77,6 +77,7 @@ namespace SharedLibrary
IP = I; IP = I;
ClientID = -1; ClientID = -1;
this.UID = UID; this.UID = UID;
DatabaseID = dbid;
} }
public Player(string n, string id, int num, Player.Permission l, int cind, String lo, int con, String IP2) public Player(string n, string id, int num, Player.Permission l, int cind, String lo, int con, String IP2)

View File

@ -22,9 +22,6 @@ namespace SharedLibrary.Network
static string[] SendQuery(QueryType Type, Server QueryServer, string Parameters = "") static string[] SendQuery(QueryType Type, Server QueryServer, string Parameters = "")
{ {
if (QueryServer.Throttled)
throw new Exceptions.DvarException("Server is RCON throttled");
var ServerOOBConnection = new UdpClient(); var ServerOOBConnection = new UdpClient();
ServerOOBConnection.Client.SendTimeout = 1000; ServerOOBConnection.Client.SendTimeout = 1000;
ServerOOBConnection.Client.ReceiveTimeout = 1000; ServerOOBConnection.Client.ReceiveTimeout = 1000;
@ -97,9 +94,6 @@ namespace SharedLibrary.Network
public static async Task<DVAR<T>> GetDvarAsync<T>(this Server server, string dvarName) public static async Task<DVAR<T>> GetDvarAsync<T>(this Server server, string dvarName)
{ {
if (server.Throttled)
throw new Exceptions.DvarException("Server is RCON throttled");
string[] LineSplit = await Task.FromResult(SendQuery(QueryType.DVAR, server, dvarName)); string[] LineSplit = await Task.FromResult(SendQuery(QueryType.DVAR, server, dvarName));
if (LineSplit.Length != 3) if (LineSplit.Length != 3)
@ -113,7 +107,7 @@ namespace SharedLibrary.Network
if (ValueSplit.Length != 5) if (ValueSplit.Length != 5)
{ {
var e = new Exceptions.DvarException("DVAR does not exist"); var e = new Exceptions.DvarException($"DVAR \"{dvarName}\" does not exist");
e.Data["dvar_name"] = dvarName; e.Data["dvar_name"] = dvarName;
throw e; throw e;
} }
@ -127,25 +121,16 @@ namespace SharedLibrary.Network
public static async Task SetDvarAsync(this Server server, string dvarName, object dvarValue) public static async Task SetDvarAsync(this Server server, string dvarName, object dvarValue)
{ {
if (server.Throttled)
throw new Exceptions.DvarException("Server is RCON throttled");
await Task.FromResult(SendQuery(QueryType.DVAR, server, $"set {dvarName} {dvarValue}")); await Task.FromResult(SendQuery(QueryType.DVAR, server, $"set {dvarName} {dvarValue}"));
} }
public static async Task<string[]> ExecuteCommandAsync(this Server server, string commandName) public static async Task<string[]> ExecuteCommandAsync(this Server server, string commandName)
{ {
if (server.Throttled)
throw new Exceptions.DvarException("Server is RCON throttled");
return await Task.FromResult(SendQuery(QueryType.COMMAND, server, commandName).Skip(1).ToArray()); return await Task.FromResult(SendQuery(QueryType.COMMAND, server, commandName).Skip(1).ToArray());
} }
public static async Task<List<Player>> GetStatusAsync(this Server server) public static async Task<List<Player>> GetStatusAsync(this Server server)
{ {
if (server.Throttled)
throw new Exceptions.DvarException("Server is RCON throttled");
string[] response = await Task.FromResult(SendQuery(QueryType.DVAR, server, "status")); string[] response = await Task.FromResult(SendQuery(QueryType.DVAR, server, "status"));
return Utilities.PlayersFromStatus(response); return Utilities.PlayersFromStatus(response);
} }

View File

@ -63,23 +63,6 @@ namespace SharedLibrary
return Players.FindAll(x => x != null); return Players.FindAll(x => x != null);
} }
/// <summary>
/// Get any know aliases ( name or ip based ) from the database
/// </summary>
/// <param name="Origin">Player to scan for aliases</param>
abstract public List<Aliases> GetAliases(Player Origin);
public List<Player> GetPlayerAliases(Player Origin)
{
List<int> databaseIDs = new List<int>();
foreach (Aliases A in GetAliases(Origin))
databaseIDs.Add(A.Number);
return Manager.GetClientDatabase().GetPlayers(databaseIDs);
}
/// <summary> /// <summary>
/// Add a player to the server's player list /// Add a player to the server's player list
/// </summary> /// </summary>
@ -135,6 +118,16 @@ namespace SharedLibrary
return null; return null;
} }
/// <summary>
/// Legacy method for the alias command
/// </summary>
/// <param name="P"></param>
/// <returns></returns>
public IList<Aliases> GetAliases(Player P)
{
return Manager.GetAliases(P);
}
/// <summary> /// <summary>
/// Process any server event /// Process any server event
/// </summary> /// </summary>