Compare commits

...

3 Commits

Author SHA1 Message Date
edmand46 f7719e1bca chore: update server version 2024-08-15 23:27:53 +03:00
edmand46 211b24fe2b feat: added server address in relay.config.json 2024-08-15 23:20:23 +03:00
edmand46 bdf7d4f94a fix: connection key is invalid 2024-07-21 09:46:01 +03:00
8 changed files with 20 additions and 11 deletions
+1
View File
@@ -63,6 +63,7 @@ namespace Ragon.Relay
Protocol = configuration.Protocol,
ServerKey = configuration.ServerKey,
ServerTickRate = configuration.ServerTickRate,
ServerAddress = configuration.ServerAddress,
};
var relay = new RagonServer(networkServer, plugin, serverConfiguration);
@@ -7,6 +7,7 @@ namespace Ragon.Relay
{
public string ServerKey;
public string ServerType;
public string ServerAddress;
public ushort ServerTickRate;
public string Protocol;
public ushort Port;
+1
View File
@@ -1,6 +1,7 @@
{
"serverKey": "defaultkey",
"serverType": "enet",
"serverAddress": "*",
"serverTickRate": 30,
"protocol": "1.0.0",
"port": 5000,
@@ -49,7 +49,7 @@ namespace Ragon.Server.ENetServer
_host.Create(address, _connections.Length, 2, 0, 0, 1024 * 1024);
var protocolDecoded = RagonVersion.Parse(_protocol);
_logger.Info($"Listen at 127.0.0.1:{configuration.Port}");
_logger.Info($"Listen at {configuration.Address}:{configuration.Port}");
_logger.Info($"Protocol: {protocolDecoded}");
}
@@ -146,13 +146,13 @@ public class WebSocketServer : INetworkServer
_connections = new WebSocketConnection[configuration.LimitConnections];
_httpListener = new HttpListener();
_httpListener.Prefixes.Add($"http://+:{configuration.Port}/");
_httpListener.Prefixes.Add($"http://{configuration.Address}:{configuration.Port}/");
_httpListener.Start();
_executor.Run(() => StartAccept(_cancellationTokenSource.Token));
var protocolDecoded = RagonVersion.Parse(configuration.Protocol);
_logger.Info($"Listen at http://0.0.0.0:{configuration.Port}/");
_logger.Info($"Listen at http://{configuration.Address}:{configuration.Port}/");
_logger.Info($"Protocol: {protocolDecoded}");
}
@@ -75,6 +75,8 @@ namespace Ragon.Server.Handler
}
else
{
_logger.Warning($"Invalid key for connection {context.Connection.Id}");
Reject(context);
}
}
@@ -100,7 +102,7 @@ namespace Ragon.Server.Handler
var sendData = _writer.ToArray();
context.Connection.Reliable.Send(sendData);
_logger.Trace($"Connection {context.Connection.Id} as {playerId}|{context.LobbyPlayer.Name} authorized");
_logger.Trace($"Approved {context.Connection.Id} as {playerId}|{context.LobbyPlayer.Name}");
}
public void Reject(RagonContext context)
@@ -113,7 +115,7 @@ namespace Ragon.Server.Handler
context.Connection.Reliable.Send(sendData);
context.Connection.Close();
_logger.Trace($"Connection {context.Connection.Id}");
_logger.Trace($"Rejected Connectin:{context.Connection.Id}");
}
}
}
+7 -4
View File
@@ -27,7 +27,7 @@ namespace Ragon.Server;
public class RagonServer : IRagonServer, INetworkListener
{
private const string ServerVersion = "1.4.0";
private const string ServerVersion = "1.4.1";
private readonly IRagonLogger _logger = LoggerManager.GetLogger(nameof(RagonServer));
private readonly INetworkServer _server;
@@ -66,7 +66,6 @@ public class RagonServer : IRagonServer, INetworkListener
_timer = new Stopwatch();
var contextObserver = new RagonContextObserver(_contextsByPlayerId);
_scheduler.Run(new RagonActionTimer(SendRoomList, 2.0f));
_scheduler.Run(new RagonActionTimer(SendPlayerUserData, 0.1f));
_scheduler.Run(new RagonActionTimer(SendRoomUserData, 0.1f));
@@ -119,7 +118,7 @@ public class RagonServer : IRagonServer, INetworkListener
{
LimitConnections = _configuration.LimitConnections,
Protocol = RagonVersion.Parse(_configuration.Protocol),
Address = "0.0.0.0",
Address = _configuration.ServerAddress,
Port = _configuration.Port,
};
@@ -156,6 +155,8 @@ public class RagonServer : IRagonServer, INetworkListener
_lobby.RemoveIfEmpty(room);
}
if (context.ConnectionStatus == ConnectionStatus.Authorized)
_contextsByPlayerId.Remove(context.LobbyPlayer.Id);
_logger.Trace($"Disconnected: {connection.Id}");
@@ -176,6 +177,8 @@ public class RagonServer : IRagonServer, INetworkListener
room.DetachPlayer(context.RoomPlayer);
_lobby.RemoveIfEmpty(room);
}
if (context.ConnectionStatus == ConnectionStatus.Authorized)
_contextsByPlayerId.Remove(context.LobbyPlayer.Id);
_logger.Trace($"Timeout: {connection.Id}|{context.LobbyPlayer.Name}|{context.LobbyPlayer.Id}");
@@ -287,7 +290,7 @@ public class RagonServer : IRagonServer, INetworkListener
private void CopyrightInfo()
{
_logger.Info($"Ragon Server Version: {ServerVersion}");
_logger.Info($"Server Version: {ServerVersion}");
_logger.Info($"Machine Name: {Environment.MachineName}");
_logger.Info($"OS: {Environment.OSVersion}");
_logger.Info($"Processors: {Environment.ProcessorCount}");
@@ -26,6 +26,7 @@ public enum ServerType
public struct RagonServerConfiguration
{
public string ServerKey;
public string ServerAddress;
public ushort ServerTickRate;
public string Protocol;
public ushort Port;