parent
9a25ee86e8
commit
b7f44b5215
Binary file not shown.
|
|
@ -79,10 +79,10 @@ namespace Lobbies
|
||||||
public void HostLobby(Guid gameId, string name, int gameMode, int maxPlayerCount, string? password, int port)
|
public void HostLobby(Guid gameId, string name, int gameMode, int maxPlayerCount, string? password, int port)
|
||||||
{
|
{
|
||||||
udpEchoServer.Start(0);
|
udpEchoServer.Start(0);
|
||||||
|
_ = Task.Run(async () => {
|
||||||
byte[]? hash = null, salt = null;
|
byte[]? hash = null, salt = null;
|
||||||
|
|
||||||
if(!string.IsNullOrEmpty(password))
|
if (!string.IsNullOrEmpty(password))
|
||||||
{
|
{
|
||||||
(hash, salt) = PasswordHash.Hash(password);
|
(hash, salt) = PasswordHash.Hash(password);
|
||||||
}
|
}
|
||||||
|
|
@ -103,13 +103,15 @@ namespace Lobbies
|
||||||
|
|
||||||
byte[] messageData = bufferRental.Rent();
|
byte[] messageData = bufferRental.Rent();
|
||||||
var len = lobbyCreate.Serialize(messageData);
|
var len = lobbyCreate.Serialize(messageData);
|
||||||
_ = Task.Run(async () => { await tcpClient.Send(messageData, 0, len); bufferRental.Return(messageData); });
|
await tcpClient.Send(messageData, 0, len); bufferRental.Return(messageData);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RequestLobbyHostInfo(Guid lobbyId, string? password)
|
public void RequestLobbyHostInfo(Guid lobbyId, string? password)
|
||||||
{
|
{
|
||||||
|
_ = Task.Run(async () => {
|
||||||
byte[]? passwordHash = null;
|
byte[]? passwordHash = null;
|
||||||
if(!string.IsNullOrEmpty(password) && lobbyInformation.ContainsKey(lobbyId) && lobbyInformation[lobbyId].PasswordSalt != null)
|
if (!string.IsNullOrEmpty(password) && lobbyInformation.ContainsKey(lobbyId) && lobbyInformation[lobbyId].PasswordSalt != null)
|
||||||
passwordHash = PasswordHash.Hash(password, lobbyInformation[lobbyId].PasswordSalt!);
|
passwordHash = PasswordHash.Hash(password, lobbyInformation[lobbyId].PasswordSalt!);
|
||||||
|
|
||||||
var lobbyCreate = new LobbyRequestHostInfo()
|
var lobbyCreate = new LobbyRequestHostInfo()
|
||||||
|
|
@ -120,7 +122,8 @@ namespace Lobbies
|
||||||
|
|
||||||
byte[] messageData = bufferRental.Rent();
|
byte[] messageData = bufferRental.Rent();
|
||||||
var len = lobbyCreate.Serialize(messageData);
|
var len = lobbyCreate.Serialize(messageData);
|
||||||
_ = Task.Run(async () => { await tcpClient.Send(messageData, 0, len); bufferRental.Return(messageData); });
|
await tcpClient.Send(messageData, 0, len); bufferRental.Return(messageData);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -142,13 +145,13 @@ namespace Lobbies
|
||||||
/// <param name="password">Optional password of lobby</param>
|
/// <param name="password">Optional password of lobby</param>
|
||||||
/// <param name="sendUdpToGetExternalPortMappingCallback">A callback to send udp data if you have a udp game client ready and bound</param>
|
/// <param name="sendUdpToGetExternalPortMappingCallback">A callback to send udp data if you have a udp game client ready and bound</param>
|
||||||
public void RequestLobbyNatPunch(Guid lobbyId, string? password, SendUdpMessageCallback sendUdpToGetExternalPortMappingCallback)
|
public void RequestLobbyNatPunch(Guid lobbyId, string? password, SendUdpMessageCallback sendUdpToGetExternalPortMappingCallback)
|
||||||
|
{
|
||||||
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
byte[]? passwordHash = null;
|
byte[]? passwordHash = null;
|
||||||
if (!string.IsNullOrEmpty(password) && lobbyInformation.ContainsKey(lobbyId) && lobbyInformation[lobbyId].PasswordSalt != null)
|
if (!string.IsNullOrEmpty(password) && lobbyInformation.ContainsKey(lobbyId) && lobbyInformation[lobbyId].PasswordSalt != null)
|
||||||
passwordHash = PasswordHash.Hash(password, lobbyInformation[lobbyId].PasswordSalt!);
|
passwordHash = PasswordHash.Hash(password, lobbyInformation[lobbyId].PasswordSalt!);
|
||||||
|
|
||||||
Task.Run(() =>
|
|
||||||
{
|
|
||||||
QueryExternalIpAndPort(sendUdpToGetExternalPortMappingCallback);
|
QueryExternalIpAndPort(sendUdpToGetExternalPortMappingCallback);
|
||||||
var lobbyRequestNatPunch = new LobbyRequestNatPunch()
|
var lobbyRequestNatPunch = new LobbyRequestNatPunch()
|
||||||
{
|
{
|
||||||
|
|
@ -179,15 +182,15 @@ namespace Lobbies
|
||||||
if(port < 0 && port > 65535)
|
if(port < 0 && port > 65535)
|
||||||
throw new ArgumentOutOfRangeException(nameof(port));
|
throw new ArgumentOutOfRangeException(nameof(port));
|
||||||
|
|
||||||
byte[]? passwordHash = null;
|
|
||||||
if (!string.IsNullOrEmpty(password) && lobbyInformation.ContainsKey(lobbyId) && lobbyInformation[lobbyId].PasswordSalt != null)
|
|
||||||
passwordHash = PasswordHash.Hash(password, lobbyInformation[lobbyId].PasswordSalt!);
|
|
||||||
|
|
||||||
var udpEchoServer = new UdpEchoServer();
|
var udpEchoServer = new UdpEchoServer();
|
||||||
udpEchoServer.Start(port);
|
udpEchoServer.Start(port);
|
||||||
|
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
|
byte[]? passwordHash = null;
|
||||||
|
if (!string.IsNullOrEmpty(password) && lobbyInformation.ContainsKey(lobbyId) && lobbyInformation[lobbyId].PasswordSalt != null)
|
||||||
|
passwordHash = PasswordHash.Hash(password, lobbyInformation[lobbyId].PasswordSalt!);
|
||||||
|
|
||||||
QueryExternalIpAndPort(udpEchoServer.Send);
|
QueryExternalIpAndPort(udpEchoServer.Send);
|
||||||
udpEchoServer.Dispose();
|
udpEchoServer.Dispose();
|
||||||
var lobbyRequestNatPunch = new LobbyRequestNatPunch()
|
var lobbyRequestNatPunch = new LobbyRequestNatPunch()
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ namespace Lobbies
|
||||||
{
|
{
|
||||||
const int keySize = 64;
|
const int keySize = 64;
|
||||||
const int saltSize = 16;
|
const int saltSize = 16;
|
||||||
const int iterations = 350000;
|
const int iterations = 100000;
|
||||||
static HashAlgorithmName hashAlgorithm = HashAlgorithmName.SHA512;
|
static HashAlgorithmName hashAlgorithm = HashAlgorithmName.SHA512;
|
||||||
|
|
||||||
static internal (byte[] hash, byte[] salt) Hash(string text)
|
static internal (byte[] hash, byte[] salt) Hash(string text)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue