Skip to content

Commit

Permalink
Update local changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
crowbarmaster committed Dec 18, 2021
2 parents 0728fb3 + 1ba154d commit 2513c27
Show file tree
Hide file tree
Showing 190 changed files with 11,714 additions and 3,407 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F146D5E8-EF1F-4785-9150-182631F059B7}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BedrockService.Shared</RootNamespace>
<AssemblyName>BedrockService.Shared</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>2</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.IO.Compression.FileSystem" />
<Reference Include="System.IO.Compression.ZipFile, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\System.IO.Compression.ZipFile.4.3.0\lib\net46\System.IO.Compression.ZipFile.dll</HintPath>
<Private>True</Private>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Classes\ClientSideServiceConfiguration.cs" />
<Compile Include="Classes\CommsKeyContainer.cs" />
<Compile Include="Interfaces\IClientSideServiceConfiguration.cs" />
<Compile Include="Interfaces\IConfiguration.cs" />
<Compile Include="Interfaces\ILogger.cs" />
<Compile Include="Interfaces\IPlayer.cs" />
<Compile Include="Interfaces\IServerConfiguration.cs" />
<Compile Include="Interfaces\IServiceConfiguration.cs" />
<Compile Include="Interfaces\IProcessInfo.cs" />
<Compile Include="Classes\NetworkEnums.cs" />
<Compile Include="PackParser\MinecraftKnownPacksClass.cs" />
<Compile Include="PackParser\MinecraftPackParser.cs" />
<Compile Include="Classes\Player.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Classes\Property.cs" />
<Compile Include="Classes\ServerInfo.cs" />
<Compile Include="Classes\ServerLogger.cs" />
<Compile Include="Classes\ServiceInfo.cs" />
<Compile Include="Classes\ServiceProcessInfo.cs" />
<Compile Include="Classes\StartCmdEntry.cs" />
<Compile Include="Utilities\FileUtils.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using BedrockService.Shared.Interfaces;

namespace BedrockService.Shared.Classes
{
public class ClientSideServiceConfiguration : IClientSideServiceConfiguration
{
private readonly string _hostName;
private readonly string _address;
private readonly string _port;
private readonly string _displayName;

public ClientSideServiceConfiguration(string hostName, string address, string port)
{
this._hostName = hostName;
this._address = address;
this._port = port;
_displayName = $@"{hostName}@{address}:{port}";
}

public string GetHostName() => _hostName;

public string GetAddress() => _address;

public string GetPort() => _port;

public string GetDisplayName() => _displayName;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
using System;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BedrockService.Shared.Classes
{
[Serializable]
public class RSAContainer
{
public byte[] D;
public byte[] DP;
public byte[] DQ;
public byte[] Exponent;
public byte[] InverseQ;
public byte[] Modulus;
public byte[] P;
public byte[] Q;

public RSAContainer(RSAParameters input)
{
D = input.D;
P = input.DP;
DP = input.DP;
Q = input.DQ;
DQ = input.DQ;
InverseQ = input.InverseQ;
Modulus = input.Modulus;
Exponent = input.Exponent;
}

public RSAParameters GetPrivateKey()
{
return new RSAParameters()
{
D = this.D,
P = this.P,
DP = this.DP,
Q = this.Q,
DQ = this.DQ,
InverseQ = this.InverseQ,
Exponent = this.Exponent,
Modulus = this.Modulus
};
}

public RSAParameters GetPublicKey()
{
return new RSAParameters()
{
Modulus = this.Modulus,
Exponent = this.Exponent
};
}

public void SetPrivateKey(RSAParameters privateKey)
{
this.D = privateKey.D;
this.DP = privateKey.DP;
this.P = privateKey.P;
this.DQ = privateKey.DQ;
this.Q = privateKey.Q;
this.InverseQ = privateKey.InverseQ;
this.Modulus = privateKey.Modulus;
this.Exponent = privateKey.Exponent;
}

public void SetPublicKey(RSAParameters publicKey)
{
this.Exponent = publicKey.Exponent;
this.Modulus = publicKey.Modulus;
}
}

[Serializable]
public class CommsKeyContainer
{
public RSAContainer LocalPrivateKey = new RSAContainer(new RSAParameters());
public RSAContainer RemotePublicKey = new RSAContainer(new RSAParameters());
public byte[] AesKey;
public byte[] AesIV;

public CommsKeyContainer() { }

public CommsKeyContainer (RSAParameters priv, RSAParameters pub, byte[] key, byte[] IV)
{
LocalPrivateKey = new RSAContainer(priv);
RemotePublicKey = new RSAContainer(pub);
AesKey = key;
AesIV = IV;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
namespace BedrockService.Shared.Classes
{
public enum NetworkMessageSource
{
Client,
Server,
Service
}


public enum NetworkMessageDestination
{
Client,
Server,
Service
}

public enum NetworkMessageTypes
{
Connect,
AddNewServer,
RemoveServer,
ConsoleLogUpdate,
PropUpdate,
PlayersRequest,
PlayersUpdate,
StartCmdUpdate,
CheckUpdates,
PackFile,
PackList,
LevelEditRequest,
LevelEditFile,
RemovePack,
Command,
Backup,
BackupRollback,
BackupAll,
DelBackups,
EnumBackups,
Restart,
Heartbeat,
Disconnect,
UICallback
}

public enum NetworkMessageFlags
{
Failed,
Passed,
RemoveBackups,
RemoveSrv,
RemovePlayers,
RemoveBckSrv,
RemoveBckPly,
RemovePlySrv,
RemoveAll,
None
}
}
124 changes: 124 additions & 0 deletions BedrockService.backup/BedrockService.Shared/Classes/Player.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
using BedrockService.Shared.Interfaces;
using Newtonsoft.Json;
using System;

namespace BedrockService.Shared.Classes
{
public class Player : IPlayer
{
[JsonProperty]
private string Username { get; set; }
[JsonProperty]
private string XUID { get; set; }
[JsonProperty]
private string PermissionLevel;
[JsonProperty]
private string FirstConnectedTime { get; set; }
[JsonProperty]
private string LastConnectedTime { get; set; }
[JsonProperty]
private string LastDisconnectTime { get; set; }
[JsonProperty]
private string ServerDefaultPerm { get; set; }
[JsonProperty]
private bool Whitelisted { get; set; }
[JsonProperty]
private bool IgnorePlayerLimits { get; set; }
[JsonProperty]
private bool FromConfig { get; set; }

[JsonConstructor]
public Player(string xuid, string username, string firstConn, string lastConn, string lastDiscon, bool whtlist, string perm, bool ignoreLimit)
{
Username = username;
XUID = xuid;
FirstConnectedTime = firstConn;
LastConnectedTime = lastConn;
LastDisconnectTime = lastDiscon;
Whitelisted = whtlist;
PermissionLevel = perm;
IgnorePlayerLimits = ignoreLimit;
}

public Player(string serverDefaultPermission)
{
ServerDefaultPerm = serverDefaultPermission;
PermissionLevel = serverDefaultPermission;
}

public void Initialize(string xuid, string username)
{
XUID = xuid;
Username = username;
}

public string GetUsername() => Username;

public string SearchForProperty(string input)
{
if (input == "name" || input == "username" || input == "un")
return Username;
if (input == "xuid" || input == "id")
return XUID;
if (input == "perm" || input == "permission" || input == "pl")
return PermissionLevel;
if (input == "whitelist" || input == "white" || input == "wl")
return Whitelisted.ToString();
if (input == "ignoreslimit" || input == "il")
return IgnorePlayerLimits.ToString();
return null;
}

public string GetXUID() => XUID;

public void UpdateTimes(string lastConn, string lastDiscon)
{
if (FirstConnectedTime == "")
FirstConnectedTime = DateTime.Now.Ticks.ToString();
LastConnectedTime = lastConn;
LastDisconnectTime = lastDiscon;
}

public void UpdateRegistration(string whtlist, string perm, string ignoreLimit)
{
Whitelisted = bool.Parse(whtlist);
PermissionLevel = perm;
IgnorePlayerLimits = bool.Parse(ignoreLimit);
}

public string[] GetTimes()
{
return new string[] { FirstConnectedTime, LastConnectedTime, LastDisconnectTime };
}

public string[] GetRegistration()
{
return new string[] { Whitelisted.ToString(), PermissionLevel, IgnorePlayerLimits.ToString() };
}

public bool IsDefaultRegistration()
{
return Whitelisted == false && IgnorePlayerLimits == false && PermissionLevel == ServerDefaultPerm;
}

public string ToString(string format)
{
if (format == "Known")
{
return $"{XUID},{Username},{FirstConnectedTime},{LastConnectedTime},{LastDisconnectTime}";
}
if (format == "Registered")
{
return $"{XUID},{Username},{PermissionLevel},{Whitelisted},{IgnorePlayerLimits}";
}
return null;
}

public bool IsPlayerWhitelisted() => Whitelisted;

public bool PlayerIgnoresLimit() => IgnorePlayerLimits;

public string GetPermissionLevel() => PermissionLevel;
}

}
Loading

0 comments on commit 2513c27

Please sign in to comment.