mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
started work on T6M parsing rest api
fixed bug in login program preventing regular users from executing commands make log reading async and changed encoding to UTF7
This commit is contained in:
@ -36,6 +36,7 @@ namespace SharedLibraryCore
|
||||
// FROM GAME
|
||||
Script,
|
||||
Kill,
|
||||
Damage,
|
||||
Death,
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ using System.Text;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SharedLibraryCore
|
||||
{
|
||||
@ -23,12 +24,6 @@ namespace SharedLibraryCore
|
||||
FileCache = cl.GetStringAsync(Location).Result.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
|
||||
public override string[] Tail(int lineCount)
|
||||
{
|
||||
// Retrieve();
|
||||
return FileCache;
|
||||
}
|
||||
|
||||
public override long Length()
|
||||
{
|
||||
Retrieve();
|
||||
@ -44,7 +39,8 @@ namespace SharedLibraryCore
|
||||
if (fileName != string.Empty)
|
||||
{
|
||||
Name = fileName;
|
||||
Handle = new StreamReader(new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
|
||||
Handle = new StreamReader(new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, 4096, true), Encoding.UTF7);
|
||||
|
||||
sze = Handle.BaseStream.Length;
|
||||
}
|
||||
}
|
||||
@ -70,20 +66,20 @@ namespace SharedLibraryCore
|
||||
return Handle?.ReadToEnd();
|
||||
}
|
||||
|
||||
public virtual String[] Tail(int lineCount)
|
||||
public virtual async Task<String[]> Tail(int lineCount)
|
||||
{
|
||||
var buffer = new List<string>(lineCount);
|
||||
string line;
|
||||
for (int i = 0; i < lineCount; i++)
|
||||
{
|
||||
line = Handle.ReadLine();
|
||||
line = await Handle.ReadLineAsync();
|
||||
if (line == null) return buffer.ToArray();
|
||||
buffer.Add(line);
|
||||
}
|
||||
|
||||
int lastLine = lineCount - 1; //The index of the last line read from the buffer. Everything > this index was read earlier than everything <= this indes
|
||||
|
||||
while (null != (line = Handle.ReadLine()))
|
||||
while (null != (line = await Handle.ReadLineAsync()))
|
||||
{
|
||||
lastLine++;
|
||||
if (lastLine == lineCount) lastLine = 0;
|
||||
|
@ -77,7 +77,8 @@ namespace SharedLibraryCore.Objects
|
||||
public int Score { get; set; }
|
||||
[NotMapped]
|
||||
public IList<Dtos.ProfileMeta> Meta { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public bool IsBot { get; set; }
|
||||
private int _ipaddress;
|
||||
public override int IPAddress
|
||||
{
|
||||
|
@ -34,8 +34,8 @@ namespace SharedLibraryCore.RCon
|
||||
|
||||
public class Connection
|
||||
{
|
||||
IPEndPoint Endpoint;
|
||||
string RConPassword;
|
||||
public IPEndPoint Endpoint { get; private set; }
|
||||
public string RConPassword { get; private set; }
|
||||
Socket ServerConnection;
|
||||
ILogger Log;
|
||||
int FailedSends;
|
||||
|
@ -331,7 +331,8 @@ namespace SharedLibraryCore
|
||||
Level = client.Level,
|
||||
LastConnection = client.LastConnection == DateTime.MinValue ? DateTime.UtcNow : client.LastConnection,
|
||||
CurrentAlias = client.CurrentAlias,
|
||||
CurrentAliasId = client.CurrentAlias.AliasId
|
||||
CurrentAliasId = client.CurrentAlias.AliasId,
|
||||
IsBot = client.NetworkId == -1
|
||||
};
|
||||
}
|
||||
|
||||
@ -366,13 +367,13 @@ namespace SharedLibraryCore
|
||||
return pID;
|
||||
}
|
||||
|
||||
public static async Task<Dvar<T>> GetDvarAsync<T>(this Server server, string dvarName) => await server.RconParser.GetDvarAsync<T>(server.RemoteConnection, dvarName);
|
||||
public static Task<Dvar<T>> GetDvarAsync<T>(this Server server, string dvarName) => server.RconParser.GetDvarAsync<T>(server.RemoteConnection, dvarName);
|
||||
|
||||
public static async Task SetDvarAsync(this Server server, string dvarName, object dvarValue) => await server.RconParser.SetDvarAsync(server.RemoteConnection, dvarName, dvarValue);
|
||||
public static Task SetDvarAsync(this Server server, string dvarName, object dvarValue) => server.RconParser.SetDvarAsync(server.RemoteConnection, dvarName, dvarValue);
|
||||
|
||||
public static async Task<string[]> ExecuteCommandAsync(this Server server, string commandName) => await server.RconParser.ExecuteCommandAsync(server.RemoteConnection, commandName);
|
||||
public static Task<string[]> ExecuteCommandAsync(this Server server, string commandName) => server.RconParser.ExecuteCommandAsync(server.RemoteConnection, commandName);
|
||||
|
||||
public static async Task<List<Player>> GetStatusAsync(this Server server) => await server.RconParser.GetStatusAsync(server.RemoteConnection);
|
||||
public static Task<List<Player>> GetStatusAsync(this Server server) => server.RconParser.GetStatusAsync(server.RemoteConnection);
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user