aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Server/ServerLogManager.h
blob: 1d4abfb5bde810b3f5bee8aacb1ff80af23333b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#pragma once

#include <string>
#include <stdarg.h>

#include "..\Minecraft.World\DisconnectPacket.h"

namespace ServerRuntime
{
    namespace ServerLogManager
    {
        /**
         * Identifies why the dedicated server rejected a TCP connection before login completed
         * ログイン完了前にTCP接続を拒否した理由
         */
        enum ETcpRejectReason
        {
            eTcpRejectReason_BannedIp = 0,
            eTcpRejectReason_GameNotReady,
            eTcpRejectReason_ServerFull
        };

        /**
         * Identifies why the dedicated server rejected a player during login validation
         * ログイン検証中にプレイヤーを拒否した理由
         */
        enum ELoginRejectReason
        {
            eLoginRejectReason_BannedXuid = 0,
            eLoginRejectReason_NotWhitelisted,
            eLoginRejectReason_DuplicateXuid,
            eLoginRejectReason_DuplicateName
        };

        /**
         * Returns `true` when client-side debug logs should be redirected into the dedicated server logger
         * dedicated server時にclient側デバッグログを転送すかどうか
         */
        bool ShouldForwardClientDebugLogs();

        /**
         * Formats and forwards `CMinecraftApp::DebugPrintf` output through the dedicated server logger
         * CMinecraftApp::DebugPrintf の出力を専用サーバーロガーへ転送
         */
        void ForwardClientAppDebugLogV(const char *format, va_list args);

        /**
         * Formats and forwards `CMinecraftApp::DebugPrintf(int user, ...)` output through the dedicated server logger
         * CMinecraftApp::DebugPrintf(int user, ...) の出力を専用サーバーロガーへ転送
         */
        void ForwardClientUserDebugLogV(int user, const char *format, va_list args);

        /**
         * Formats and forwards legacy `DebugSpew` output through the dedicated server logger
         * 従来の DebugSpew 出力を専用サーバーロガーへ転送
         */
        void ForwardClientDebugSpewLogV(const char *format, va_list args);

        /**
         * Clears cached connection metadata before the dedicated server starts accepting players
         * 接続ログ管理用のキャッシュを初期化
         */
        void Initialize();

        /**
         * Releases cached connection metadata after the dedicated server stops
         * 接続ログ管理用のキャッシュを停止時に破棄
         */
        void Shutdown();

        /**
         * **Log Incoming TCP Connection**
         *
         * Emits a named log for a raw TCP accept before smallId assignment finishes
         * smallId割り当て前のTCP接続を記録
         */
        void OnIncomingTcpConnection(const char *ip);

        /**
         * Emits a named log for a TCP connection rejected before login starts
         * ログイン開始前に拒否したTCP接続を記録
         */
        void OnRejectedTcpConnection(const char *ip, ETcpRejectReason reason);

        /**
         * Stores the remote IP for the assigned smallId and logs the accepted transport connection
         * 割り当て済みsmallIdに対接続IPを保存して記録
         */
        void OnAcceptedTcpConnection(unsigned char smallId, const char *ip);

        /**
         * Associates a player name with the connection and emits the accepted login log
         * 接続にプレイヤー名を関連付けてログイン成功を記録
         */
        void OnAcceptedPlayerLogin(unsigned char smallId, const std::wstring &playerName);

        /**
         * Emits a named login rejection log and clears cached metadata for that smallId
         * ログイン拒否を記録し対象smallIdのキャッシュを破棄
         */
        void OnRejectedPlayerLogin(unsigned char smallId, const std::wstring &playerName, ELoginRejectReason reason);

        /**
         * Emits a named disconnect log using cached connection metadata and then clears that entry
         * 接続キャッシュを使って切断ログを出しその後で破棄
         */
        void OnPlayerDisconnected(
            unsigned char smallId,
            const std::wstring &playerName,
            DisconnectPacket::eDisconnectReason reason,
            bool initiatedByServer);

        /**
         * Reads the cached remote IP for a live smallId without consuming the entry
         * Eventually, this should be implemented in a separate class or on the `Minecraft.Client` side instead.
         * 
         * 指定smallIdの接続IPをキャッシュから参照する
         */
        bool TryGetConnectionRemoteIp(unsigned char smallId, std::string *outIp);

        /**
         * Removes any remembered IP or player name for the specified smallId
         * 指定smallIdに紐づく接続キャッシュを消去
         */
        void ClearConnection(unsigned char smallId);
    }
}