Added Motd; simple refactoring
This commit is contained in:
parent
4c5126e5da
commit
53482f0adf
@ -46,7 +46,6 @@ namespace DiIiS_NA.LoginServer.Battle
|
||||
public readonly object ServiceLock = new();
|
||||
public object MessageLock = new();
|
||||
private ulong _listenerId; // last targeted rpc object.
|
||||
public bool MotdSent { get; private set; }
|
||||
private ConcurrentDictionary<ulong, ulong> MappedObjects { get; set; }
|
||||
public bool GuildChannelsRevealed = false;
|
||||
public string GameTeamTag = "";
|
||||
@ -139,9 +138,8 @@ namespace DiIiS_NA.LoginServer.Battle
|
||||
SocketConnection = socketChannel;
|
||||
Services = new Dictionary<uint, uint>();
|
||||
MappedObjects = new ConcurrentDictionary<ulong, ulong>();
|
||||
MotdSent = false;
|
||||
if (SocketConnection.Active)
|
||||
Logger.Trace("Client - {0} - successfully encrypted the connection", socketChannel.RemoteAddress);
|
||||
Logger.Trace("Client - $[green]$ {0} $[/]$ - successfully encrypted the connection", socketChannel.RemoteAddress);
|
||||
}
|
||||
|
||||
protected override void ChannelRead0(IChannelHandlerContext ctx, BNetPacket msg)
|
||||
@ -263,16 +261,9 @@ namespace DiIiS_NA.LoginServer.Battle
|
||||
ListenerId = 0
|
||||
};
|
||||
#if DEBUG
|
||||
if (method.Name == "KeepAlive")
|
||||
{
|
||||
Logger.Debug(
|
||||
$"Call: $[olive]${service.GetType().Name}$[/]$, Service hash: $[olive]${header.ServiceHash}$[/]$, Method: $[olive]${method.Name}$[/]$, ID: $[olive]${header.MethodId}$[/]$");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Trace(
|
||||
$"Call: $[olive]${service.GetType().Name}$[/]$, Service hash: $[olive]${header.ServiceHash}$[/]$, Method: $[olive]${method.Name}$[/]$, ID: $[olive]${header.MethodId}$[/]$");
|
||||
}
|
||||
$"Call: $[underline white]${service.GetType().Name}$[/]$, Service hash: $[underline white]${header.ServiceHash}$[/]$, Method: $[underline white]${method.Name}$[/]$, ID: $[olive]${header.MethodId}$[/]$");
|
||||
|
||||
#endif
|
||||
|
||||
service.CallMethod(method, controller, message,
|
||||
@ -281,7 +272,7 @@ namespace DiIiS_NA.LoginServer.Battle
|
||||
}
|
||||
catch (NotImplementedException)
|
||||
{
|
||||
Logger.Warn("Unimplemented service method: {0}.{1}", service.GetType().Name, method.Name);
|
||||
Logger.Warn("Unimplemented service method:$[red]$ {0}.{1} $[/]$", service.GetType().Name, method.Name);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -391,7 +382,8 @@ namespace DiIiS_NA.LoginServer.Battle
|
||||
{
|
||||
if (SocketConnection == null || !SocketConnection.Active) return;
|
||||
var listenerId = GetRemoteObjectId(targetObject.DynamicId);
|
||||
Logger.Debug("[RPC: {0}] Method: {1} Target: {2} [localId: {3}, remoteId: {4}].", GetType().Name, rpc.Method.Name,
|
||||
Logger.Debug("[$[underline yellow]$RPC: {0}$[/]$] Method: $[underline white]${1}$[/]$ Target: $[underline white]${2}$[/]$ " +
|
||||
"[localId: $[underline white]${3}$[/]$, remoteId: $[underline white]${4}$[/]$].", GetType().Name, rpc.Method.Name,
|
||||
targetObject.ToString(), targetObject.DynamicId, listenerId);
|
||||
|
||||
rpc(listenerId);
|
||||
@ -409,7 +401,7 @@ namespace DiIiS_NA.LoginServer.Battle
|
||||
try
|
||||
{
|
||||
if (SocketConnection == null || !SocketConnection.Active) return;
|
||||
Logger.Debug("[RPC: {0}] Method: {1} Target: N/A", GetType().Name, rpc.Method.Name);
|
||||
Logger.Debug("[$[underline yellow]$RPC: {0}$[/]$] Method: $[underline yellow]${1}$[/]$ Target: $[underline red]$N/A$[/]$", GetType().Name, rpc.Method.Name);
|
||||
rpc(0);
|
||||
}
|
||||
catch { }
|
||||
@ -429,17 +421,17 @@ namespace DiIiS_NA.LoginServer.Battle
|
||||
|
||||
if (!Services.ContainsKey(serviceHash))
|
||||
{
|
||||
Logger.Warn("Service not found for client {0} [0x{1}].", serviceName, serviceHash.ToString("X8"));
|
||||
Logger.Warn("Service not found for client {0} [$[underline blue]$0x{1}$[/]$].", serviceName, serviceHash.ToString("X8"));
|
||||
// in english: "Service not found for client {0} [0x{1}]."
|
||||
return;
|
||||
}
|
||||
|
||||
uint status = 0;
|
||||
|
||||
if (controller is HandlerController)
|
||||
if (controller is HandlerController handlerController)
|
||||
{
|
||||
status = ((HandlerController) controller).Status;
|
||||
_listenerId = ((HandlerController) controller).ListenerId;
|
||||
status = handlerController.Status;
|
||||
_listenerId = handlerController.ListenerId;
|
||||
}
|
||||
|
||||
var serviceId = Services[serviceHash];
|
||||
@ -514,13 +506,10 @@ namespace DiIiS_NA.LoginServer.Battle
|
||||
}
|
||||
public void SendMotd()
|
||||
{
|
||||
if (MotdSent)
|
||||
if (string.IsNullOrWhiteSpace(Config.Instance.Motd) || !Config.Instance.MotdEnabled)
|
||||
return;
|
||||
|
||||
var motd = "Welcome to BlizzLess.Net Alpha-Build Server!";
|
||||
|
||||
SendServerWhisper(motd);
|
||||
MotdSent = true;
|
||||
Logger.Debug($"Motd sent to {Account.BattleTag}.");
|
||||
SendServerWhisper(Config.Instance.Motd);
|
||||
}
|
||||
|
||||
public override void ChannelInactive(IChannelHandlerContext context)
|
||||
|
||||
@ -114,9 +114,9 @@ namespace DiIiS_NA.LoginServer.ChannelSystem
|
||||
|
||||
|
||||
#region
|
||||
string GAME_SERVER_IP = Program.GAMESERVERIP;
|
||||
string gameServerIp = Program.GameServerIp;
|
||||
if (GameServer.NATConfig.Instance.Enabled)
|
||||
GAME_SERVER_IP = Program.PUBLICGAMESERVERIP;
|
||||
gameServerIp = Program.PublicGameServerIp;
|
||||
uint GAME_SERVER_PORT = 2001;
|
||||
|
||||
var member = bgs.protocol.account.v1.GameAccountHandle.CreateBuilder();
|
||||
@ -124,7 +124,7 @@ namespace DiIiS_NA.LoginServer.ChannelSystem
|
||||
|
||||
var notification = bgs.protocol.matchmaking.v1.MatchmakingResultNotification.CreateBuilder();
|
||||
var connectInfo = bgs.protocol.matchmaking.v1.ConnectInfo.CreateBuilder();
|
||||
connectInfo.SetAddress(Address.CreateBuilder().SetAddress_(GAME_SERVER_IP).SetPort(GAME_SERVER_PORT));
|
||||
connectInfo.SetAddress(Address.CreateBuilder().SetAddress_(gameServerIp).SetPort(GAME_SERVER_PORT));
|
||||
connectInfo.AddAttribute(bgs.protocol.v2.Attribute.CreateBuilder().SetName("GameAccount").SetValue(bgs.protocol.v2.Variant.CreateBuilder().SetBlobValue(member.Build().ToByteString())));
|
||||
connectInfo.AddAttribute(bgs.protocol.v2.Attribute.CreateBuilder().SetName("Token").SetValue(bgs.protocol.v2.Variant.CreateBuilder().SetUintValue(0xEEF4364684EE186E))); // FIXME
|
||||
//connectInfo.AddAttribute(AttributeOfServer); // Game settings
|
||||
|
||||
@ -9,14 +9,60 @@ namespace DiIiS_NA.LoginServer
|
||||
{
|
||||
public sealed class Config : Core.Config.Config
|
||||
{
|
||||
public bool Enabled { get { return this.GetBoolean("Enabled", true); } set { this.Set("Enabled", value); } }
|
||||
public string BindIP { get { return this.GetString("BindIP", "127.0.0.1"); } set { this.Set("BindIP", value); } }
|
||||
public int WebPort { get { return this.GetInt("WebPort", 9000); } set { this.Set("WebPort", value); } }
|
||||
public int Port { get { return this.GetInt("Port", 1119); } set { this.Set("Port", value); } }
|
||||
public string BindIPv6 { get { return this.GetString("BindIPv6", "::1"); } set { this.Set("BindIPv6", value); } }
|
||||
public bool Enabled
|
||||
{
|
||||
get => GetBoolean(nameof(Enabled), true);
|
||||
set => Set(nameof(Enabled), value);
|
||||
}
|
||||
|
||||
private static readonly Config _instance = new Config();
|
||||
public static Config Instance { get { return _instance; } }
|
||||
private Config() : base("Battle-Server") { }
|
||||
public string BindIP
|
||||
{
|
||||
get => GetString(nameof(BindIP), "127.0.0.1");
|
||||
set => Set(nameof(BindIP), value);
|
||||
}
|
||||
|
||||
public int WebPort
|
||||
{
|
||||
get => GetInt(nameof(WebPort), 9000);
|
||||
set => Set(nameof(WebPort), value);
|
||||
}
|
||||
|
||||
public int Port
|
||||
{
|
||||
get => GetInt(nameof(Port), 1119);
|
||||
set => Set(nameof(Port), value);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public string BindIPv6
|
||||
{
|
||||
get => GetString(nameof(BindIPv6), "::1");
|
||||
set => Set(nameof(BindIPv6), value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Whether Motd should be displayed on login.
|
||||
/// </summary>
|
||||
public bool MotdEnabled
|
||||
{
|
||||
get => GetBoolean(nameof(MotdEnabled), true);
|
||||
set => Set(nameof(MotdEnabled), value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Motd text
|
||||
/// </summary>
|
||||
public string Motd
|
||||
{
|
||||
get => GetString(nameof(Motd),
|
||||
$"Welcome to Blizzless Server Build {Program.Build} - Stage: {Program.Stage} [{Program.TypeBuild}]!");
|
||||
set => Set(nameof(Motd), value);
|
||||
}
|
||||
|
||||
public static Config Instance => new();
|
||||
|
||||
private Config() : base("Battle-Server")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,10 +119,10 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
|
||||
builder.SetPayloadType("web_auth_url");
|
||||
if (REST.Config.Instance.Public)
|
||||
builder.SetPayload(ByteString.CopyFromUtf8(
|
||||
$"http://{REST.Config.Instance.PublicIP}:{REST.Config.Instance.PORT}/battlenet/login"));
|
||||
$"http://{REST.Config.Instance.PublicIP}:{REST.Config.Instance.Port}/battlenet/login"));
|
||||
else
|
||||
builder.SetPayload(ByteString.CopyFromUtf8(
|
||||
$"http://{Program.RESTSERVERIP}:{REST.Config.Instance.PORT}/battlenet/login"));
|
||||
$"http://{Program.RestServerIp}:{REST.Config.Instance.Port}/battlenet/login"));
|
||||
|
||||
((HandlerController)controller).Client.MakeRpc((lid) => ChallengeListener.CreateStub(((HandlerController)controller).Client).OnExternalChallenge(controller, builder.Build(), callback => { }));
|
||||
#endregion
|
||||
|
||||
@ -84,9 +84,9 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
|
||||
#endregion
|
||||
|
||||
|
||||
string gameServerIp = Program.GAMESERVERIP;
|
||||
string gameServerIp = Program.GameServerIp;
|
||||
if (GameServer.NATConfig.Instance.Enabled)
|
||||
gameServerIp = Program.PUBLICGAMESERVERIP;
|
||||
gameServerIp = Program.PublicGameServerIp;
|
||||
uint gameServerPort = 2001;
|
||||
|
||||
MatchmakingResultNotification.Builder notification = MatchmakingResultNotification.CreateBuilder();
|
||||
@ -94,7 +94,7 @@ namespace DiIiS_NA.LoginServer.ServicesSystem.Services
|
||||
connectInfo.SetAddress(Address.CreateBuilder().SetAddress_(gameServerIp).SetPort(gameServerPort));
|
||||
connectInfo.AddAttribute(bgs.protocol.v2.Attribute.CreateBuilder().SetName("GameAccount").SetValue(bgs.protocol.v2.Variant.CreateBuilder().SetBlobValue(member.Build().ToByteString())));
|
||||
connectInfo.AddAttribute(bgs.protocol.v2.Attribute.CreateBuilder().SetName("Token").SetValue(bgs.protocol.v2.Variant.CreateBuilder().SetUintValue(0xEEF4364684EE186E))); // FIXME
|
||||
connectInfo.AddAttribute(attributeOfServer); // Настройки игры
|
||||
connectInfo.AddAttribute(attributeOfServer); // GameCreateParams
|
||||
|
||||
GameHandle.Builder gh = GameHandle.CreateBuilder();
|
||||
gh.SetMatchmaker(MatchmakerHandle.CreateBuilder()
|
||||
|
||||
@ -35,8 +35,8 @@ namespace DiIiS_NA.GameServer.ClientSystem
|
||||
{
|
||||
int Port = 2001;
|
||||
|
||||
if (!Listen(Program.GAMESERVERIP, Port)) return;
|
||||
Logger.Info("Game Server Started - {0}:{1}...", Program.GAMESERVERIP, Port);
|
||||
if (!Listen(Program.GameServerIp, Port)) return;
|
||||
Logger.Info("Game Server Started - {0}:{1}...", Program.GameServerIp, Port);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ namespace DiIiS_NA
|
||||
public static BattleBackend BattleBackend { get; set; }
|
||||
public bool GameServersAvailable = true;
|
||||
|
||||
public static int MaxLevel = 70;
|
||||
public const int MaxLevel = 70;
|
||||
|
||||
public static GameServer.ClientSystem.GameServer GameServer;
|
||||
public static Watchdog Watchdog;
|
||||
@ -54,24 +54,24 @@ namespace DiIiS_NA
|
||||
public static Thread GameServerThread;
|
||||
public static Thread WatchdogThread;
|
||||
|
||||
public static string LOGINSERVERIP = DiIiS_NA.LoginServer.Config.Instance.BindIP;
|
||||
public static string GAMESERVERIP = DiIiS_NA.GameServer.Config.Instance.BindIP;
|
||||
public static string RESTSERVERIP = DiIiS_NA.REST.Config.Instance.IP;
|
||||
public static string PUBLICGAMESERVERIP = DiIiS_NA.GameServer.NATConfig.Instance.PublicIP;
|
||||
public static string LoginServerIp = DiIiS_NA.LoginServer.Config.Instance.BindIP;
|
||||
public static string GameServerIp = DiIiS_NA.GameServer.Config.Instance.BindIP;
|
||||
public static string RestServerIp = DiIiS_NA.REST.Config.Instance.IP;
|
||||
public static string PublicGameServerIp = DiIiS_NA.GameServer.NATConfig.Instance.PublicIP;
|
||||
|
||||
public static int Build = 30;
|
||||
private static readonly int Stage = 1;
|
||||
private static readonly string TypeBuild = "BETA";
|
||||
public static int Build => 30;
|
||||
public static int Stage => 1;
|
||||
public static string TypeBuild => "BETA";
|
||||
private static bool D3CoreEnabled = DiIiS_NA.GameServer.Config.Instance.CoreActive;
|
||||
|
||||
|
||||
static async Task LoginServer()
|
||||
{
|
||||
AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
|
||||
|
||||
#if DEBUG
|
||||
D3CoreEnabled = true;
|
||||
#endif
|
||||
DbProviderFactories.RegisterFactory("Npgsql", NpgsqlFactory.Instance);
|
||||
AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionHandler;
|
||||
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
|
||||
|
||||
string name = $"Blizzless: Build {Build}, Stage: {Stage} - {TypeBuild}";
|
||||
@ -192,13 +192,13 @@ namespace DiIiS_NA
|
||||
}
|
||||
|
||||
var restSocketServer = new SocketManager<RestSession>();
|
||||
if (!restSocketServer.StartNetwork(RESTSERVERIP, REST.Config.Instance.PORT))
|
||||
if (!restSocketServer.StartNetwork(RestServerIp, REST.Config.Instance.Port))
|
||||
{
|
||||
Logger.Fatal("REST socket server can't start.");
|
||||
Shutdown();
|
||||
return;
|
||||
}
|
||||
Logger.Success($"REST server started - {REST.Config.Instance.IP}:{REST.Config.Instance.PORT}");
|
||||
Logger.Success($"REST server started - {REST.Config.Instance.IP}:{REST.Config.Instance.Port}");
|
||||
|
||||
|
||||
//BGS
|
||||
|
||||
@ -14,7 +14,7 @@ namespace DiIiS_NA.REST.Manager
|
||||
|
||||
public bool Initialize()
|
||||
{
|
||||
int _port = Config.Instance.PORT;
|
||||
int _port = Config.Instance.Port;
|
||||
if (_port < 0 || _port > 0xFFFF)
|
||||
{
|
||||
_port = 8081;
|
||||
|
||||
Loading…
Reference in New Issue
user.block.title