feat: added server address in relay.config.json

This commit is contained in:
2024-08-15 23:20:23 +03:00
parent bdf7d4f94a
commit 211b24fe2b
7 changed files with 9 additions and 5 deletions
+1
View File
@@ -63,6 +63,7 @@ namespace Ragon.Relay
Protocol = configuration.Protocol, Protocol = configuration.Protocol,
ServerKey = configuration.ServerKey, ServerKey = configuration.ServerKey,
ServerTickRate = configuration.ServerTickRate, ServerTickRate = configuration.ServerTickRate,
ServerAddress = configuration.ServerAddress,
}; };
var relay = new RagonServer(networkServer, plugin, serverConfiguration); var relay = new RagonServer(networkServer, plugin, serverConfiguration);
@@ -7,6 +7,7 @@ namespace Ragon.Relay
{ {
public string ServerKey; public string ServerKey;
public string ServerType; public string ServerType;
public string ServerAddress;
public ushort ServerTickRate; public ushort ServerTickRate;
public string Protocol; public string Protocol;
public ushort Port; public ushort Port;
+1
View File
@@ -1,6 +1,7 @@
{ {
"serverKey": "defaultkey", "serverKey": "defaultkey",
"serverType": "enet", "serverType": "enet",
"serverAddress": "*",
"serverTickRate": 30, "serverTickRate": 30,
"protocol": "1.0.0", "protocol": "1.0.0",
"port": 5000, "port": 5000,
@@ -49,7 +49,7 @@ namespace Ragon.Server.ENetServer
_host.Create(address, _connections.Length, 2, 0, 0, 1024 * 1024); _host.Create(address, _connections.Length, 2, 0, 0, 1024 * 1024);
var protocolDecoded = RagonVersion.Parse(_protocol); 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}"); _logger.Info($"Protocol: {protocolDecoded}");
} }
@@ -146,13 +146,13 @@ public class WebSocketServer : INetworkServer
_connections = new WebSocketConnection[configuration.LimitConnections]; _connections = new WebSocketConnection[configuration.LimitConnections];
_httpListener = new HttpListener(); _httpListener = new HttpListener();
_httpListener.Prefixes.Add($"http://+:{configuration.Port}/"); _httpListener.Prefixes.Add($"http://{configuration.Address}:{configuration.Port}/");
_httpListener.Start(); _httpListener.Start();
_executor.Run(() => StartAccept(_cancellationTokenSource.Token)); _executor.Run(() => StartAccept(_cancellationTokenSource.Token));
var protocolDecoded = RagonVersion.Parse(configuration.Protocol); 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}"); _logger.Info($"Protocol: {protocolDecoded}");
} }
+2 -2
View File
@@ -118,7 +118,7 @@ public class RagonServer : IRagonServer, INetworkListener
{ {
LimitConnections = _configuration.LimitConnections, LimitConnections = _configuration.LimitConnections,
Protocol = RagonVersion.Parse(_configuration.Protocol), Protocol = RagonVersion.Parse(_configuration.Protocol),
Address = "0.0.0.0", Address = _configuration.ServerAddress,
Port = _configuration.Port, Port = _configuration.Port,
}; };
@@ -290,7 +290,7 @@ public class RagonServer : IRagonServer, INetworkListener
private void CopyrightInfo() private void CopyrightInfo()
{ {
_logger.Info($"Ragon Server Version: {ServerVersion}"); _logger.Info($"Server Version: {ServerVersion}");
_logger.Info($"Machine Name: {Environment.MachineName}"); _logger.Info($"Machine Name: {Environment.MachineName}");
_logger.Info($"OS: {Environment.OSVersion}"); _logger.Info($"OS: {Environment.OSVersion}");
_logger.Info($"Processors: {Environment.ProcessorCount}"); _logger.Info($"Processors: {Environment.ProcessorCount}");
@@ -26,6 +26,7 @@ public enum ServerType
public struct RagonServerConfiguration public struct RagonServerConfiguration
{ {
public string ServerKey; public string ServerKey;
public string ServerAddress;
public ushort ServerTickRate; public ushort ServerTickRate;
public string Protocol; public string Protocol;
public ushort Port; public ushort Port;