/Client/bin/account.xml
/Client/bin/config.json
/Client/bin/Log.txt
-/Client/bin/server
/Server/server_key.pub
/Server/server_key
/Server/Debug
/server/buildversion.hpp
/server/Release
/ServerLauncher
-/client/bin/server
/client/bin/tool
/client/bin/widgets
/client/bin/models
(uint16_t)MMO_PROTOCOL_VERSION,
session->udp_port()
));
+
+ session->Send(network::ServerRequestedFullServerInfo());
}
}
break;
}
break;
+ // サーバーデータ受信
+ case ClientReceiveFullServerInfo:
+ {
+ std::string xml;
+ network::Utils::Deserialize(command.body(), &xml);
+ }
+ break;
+
case ClientReceiveJSON:
// case ClientReceiveChatLog:
{
"status":
{
"name": "Status",
+ "trip": "Tripcode",
"nickname": "Nickname",
"modelname": "Model",
"user_id": "UserID",
"status":
{
"name": "ステータス",
+ "trip": "トリップ",
"nickname": "ニックネーム",
"modelname": "モデル名",
"user_id": "ユーザーID",
// チャットメッセージ受信
var even_line = false;
Network.onReceive = function (info, msg) {
+
+ if (msg.type && msg.type != "chat") {
+ return;
+ }
+
var trip = ""
if (info.player.trip()) {
trip = "《" + info.player.trip() + "》"
// システム
case "system":
- var msgObject = { system: args.trim() };
+ var msgObject = { type: "system", system: args.trim() };
Network.sendAll(msgObject);
break;
// プライベート
case "private":
var msgObject = {
+ type: "chat",
private: [
Player.myself().id(),
Player.getFromName([args.trim()]).id()
} else {
// コマンドでない場合はそのままチャットメッセージとして送信
- var msgObject = { body: text };
+ var msgObject = { type: "chat", body: text };
Network.sendAll(msgObject);
}
body_ = Utils::Serialize(user_id);
}
-ServerStartEncryptedSession::ServerStartEncryptedSession() :
- Command(header::ServerStartEncryptedSession, "")
-{
-
-}
-
-ClientStartEncryptedSession::ClientStartEncryptedSession() :
- Command(header::ClientStartEncryptedSession, "")
-{
-
-}
-
ServerReceivePublicKey::ServerReceivePublicKey(const std::string& key) :
Command(header::ServerReceivePublicKey, key)
{
-
}
ClientReceiveCommonKey::ClientReceiveCommonKey(const std::string& key,
}
-ClientRequestedPublicKey::ClientRequestedPublicKey() :
- Command(header::ClientRequestedPublicKey, "")
-{
-
-}
-
-ClientRequestedClientInfo::ClientRequestedClientInfo() :
- Command(header::ClientRequestedClientInfo, "")
-{
-
-}
-
ServerRequestedAccountRevisionPatch::ServerRequestedAccountRevisionPatch(uint32_t user_id, int revision) :\r
Command(header::ServerRequestedAccountRevisionPatch,
Utils::Serialize(user_id, revision))
{
}
-ClientReceiveServerCrowdedError::ClientReceiveServerCrowdedError() :
- Command(header::ClientReceiveServerCrowdedError, "")
-{
-
-}
-
ClientReceiveUnsupportVersionError::ClientReceiveUnsupportVersionError(uint32_t require_version) :
Command(header::ClientReceiveUnsupportVersionError, Utils::Serialize(require_version))
{
}
+ClientReceiveFullServerInfo::ClientReceiveFullServerInfo(const std::string& xml) :
+ Command(header::ClientReceiveFullServerInfo, Utils::Serialize(xml))
+{
+
+}
+
}
boost::asio::ip::udp::endpoint udp_endpoint_;
};
+ template<header::CommandHeader Header>
+ class CommandTemplate : public Command {
+ public:
+ CommandTemplate() :
+ Command(Header, "") {}
+ };
+
+ typedef CommandTemplate<header::ServerStartEncryptedSession> ServerStartEncryptedSession;
+ typedef CommandTemplate<header::ClientStartEncryptedSession> ClientStartEncryptedSession;
+ typedef CommandTemplate<header::ClientRequestedPublicKey> ClientRequestedPublicKey;
+ typedef CommandTemplate<header::ClientRequestedClientInfo> ClientRequestedClientInfo;
+ typedef CommandTemplate<header::ClientReceiveServerCrowdedError> ClientReceiveServerCrowdedError;
+ typedef CommandTemplate<header::ServerRequestedFullServerInfo> ServerRequestedFullServerInfo;
+
// コネクションの切断
class FatalConnectionError : public Command {
public:
FatalConnectionError(uint32_t user_id);\r
};
- // 暗号化通信を開始
- class ServerStartEncryptedSession : public Command {
- public:
- ServerStartEncryptedSession();
- };
-
- // 暗号化通信を開始
- class ClientStartEncryptedSession : public Command {
- public:
- ClientStartEncryptedSession();
- };
-
// クライアントからの公開鍵を受信
class ServerReceivePublicKey : public Command {
public:
ServerReceiveClientInfo(const std::string& key, uint16_t version, uint16_t udp_port);
};
- // 公開鍵を要求された
- class ClientRequestedPublicKey : public Command {
- public:
- ClientRequestedPublicKey();
- };
-
- // クライアントの情報を要求された
- class ClientRequestedClientInfo : public Command {
- public:
- ClientRequestedClientInfo();
- };
-
class ServerRequestedAccountRevisionPatch : public Command {
public:
ServerRequestedAccountRevisionPatch(uint32_t user_id, int revision);\r
ClientReceiveWriteAverageLimitUpdate(uint16_t byte);\r
};
- class ClientReceiveServerCrowdedError : public Command {
- public:
- ClientReceiveServerCrowdedError();
- };
-
class ClientReceiveUnsupportVersionError : public Command {
public:
ClientReceiveUnsupportVersionError(uint32_t require_version);
ClientReceiveServerInfo(const std::string& stage);
};
+ class ClientReceiveFullServerInfo : public Command {
+ public:
+ ClientReceiveFullServerInfo(const std::string& xml);
+ };
+
}
ServerUpdateAccountProperty = 0x13,
ServerReceiveJSON = 0x14,
ClientReceiveJSON = 0x15,
+ ServerRequestedFullServerInfo = 0x16,
+ ClientReceiveFullServerInfo = 0x17,
ServerReceiveWriteLimit = 0x20,
ServerRequstedStatus = 0xE0,
zip.write(os.path.join(base_dir, 'license.txt'), 'license.txt')
zip.write(os.path.join(base_dir, 'mmd.txt'), 'mmd.txt')
- zip.write(os.path.join(base_dir, 'server/config.json'), 'server/config.json')
+ zip.write(os.path.join(bin_path, 'server/config.json'), 'server/config.json')
zip.write(os.path.join(bin_path, 'config.json'), 'config.json')
zip.write(os.path.join(bin_path, 'server/server.exe'), 'server/server.exe')
zip = zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED)
zip.write(os.path.join(base_dir, 'license.txt'), 'license.txt')
- zip.write(os.path.join(base_dir, 'server/config.json'), 'config.json')
zip.write(os.path.join(base_dir, 'server/readme.txt'), 'readme.txt')
bin_path = os.path.join(base_dir, 'client/bin/')
zip.write(os.path.join(bin_path, 'server/server.exe'), 'server.exe')
+ zip.write(os.path.join(bin_path, 'server/config.json'), 'config.json')
zip.close()
void Config::Load()
{
- using boost::property_tree::ptree;
- ptree pt;
-
- try {
- read_json(std::ifstream(CONFIG_JSON), pt);
- } catch(std::exception& e) {
+ try {
+ read_json(std::ifstream(CONFIG_JSON), pt_);
+ } catch(std::exception& e) {
Logger::Error(unicode::ToTString(e.what()));
- }
+ }
- port_ = pt.get<uint16_t>("port", 39390);\r
- server_name_ = pt.get<std::string>("server_name", "MMO Server");
- stage_ = pt.get<std::string>("stage", "stage:ケロリン町");
- capacity_ = pt.get<int>("capacity", 20);
+ port_ = pt_.get<uint16_t>("port", 39390);\r
+ server_name_ = pt_.get<std::string>("server_name", "MMO Server");
+ stage_ = pt_.get<std::string>("stage", unicode::sjis2utf8("stage:ケロリン町"));
+ capacity_ = pt_.get<int>("capacity", 20);
- public_ = pt.get<bool>("public", false);
+ public_ = pt_.get<bool>("public", false);
- receive_limit_1_ = pt.get<int>("receive_limit_1", 60);
- receive_limit_2_ = pt.get<int>("receive_limit_2", 100);
+ receive_limit_1_ = pt_.get<int>("receive_limit_1", 60);
+ receive_limit_2_ = pt_.get<int>("receive_limit_2", 100);
- auto patterns = pt.get_child("blocking_address_patterns", ptree());
+ auto patterns = pt_.get_child("blocking_address_patterns", ptree());
BOOST_FOREACH(const auto& item, patterns) {
blocking_address_patterns_.push_back(item.second.get_value<std::string>());
}
- timestamp_ = last_write_time(CONFIG_JSON);
+ if (exists(CONFIG_JSON)) {
+ timestamp_ = last_write_time(CONFIG_JSON);
+ }
}
void Config::Reload()
{
- if (timestamp_ < last_write_time(CONFIG_JSON)) {
+ if (exists(CONFIG_JSON) &&
+ timestamp_ < last_write_time(CONFIG_JSON)) {
Config::Load();
Logger::Info(_T("Configuration reloaded."));
}
const std::list<std::string>& Config::blocking_address_patterns() const
{
return blocking_address_patterns_;
+}
+
+const boost::property_tree::ptree& Config::pt() const
+{
+ return pt_;
}
\ No newline at end of file
\r
std::list<std::string> blocking_address_patterns_;\r
\r
+ boost::property_tree::ptree pt_;\r
+\r
public:\r
uint16_t port() const;\r
const std::string& server_name() const;\r
\r
const std::list<std::string>& blocking_address_patterns() const;\r
\r
+ const boost::property_tree::ptree& pt() const;\r
+\r
private:\r
static const char* CONFIG_JSON;\r
time_t timestamp_;\r
return msg;\r
}\r
\r
+ std::string Server::GetFullStatus() const\r
+ {\r
+ using namespace boost::property_tree;\r
+ ptree xml_ptree;\r
+\r
+ xml_ptree.put_child("config", config_.pt());\r
+\r
+ std::stringstream stream;\r
+ write_xml(stream, xml_ptree);\r
+ return stream.str();\r
+ }\r
+\r
bool Server::Empty() const\r
{\r
return GetUserCount() == 0;\r
config_.Reload();\r
\r
const auto address = session->tcp_socket().remote_endpoint().address();\r
+\r
+ // 拒否IPでないか判定\r
if(IsBlockedAddress(address)) {\r
Logger::Info("Blocked IP Address: %s", address);\r
session->Close();\r
\r
- } else if (GetUserCount() >= config_.capacity()) {\r
- Logger::Info("Refused Session");\r
- session->SyncSend(ClientReceiveServerCrowdedError());\r
- session->Close();\r
-\r
- } else {\r
+ } else {\r
session->set_on_receive(callback_);\r
session->Start();\r
sessions_.push_back(SessionWeakPtr(session));\r
\r
bool Empty() const;\r
std::string GetStatusJSON() const;\r
+ std::string GetFullStatus() const;\r
\r
int GetSessionReadAverageLimit();\r
int GetUserCount() const;\r
#include "Config.hpp"\r
#include "Account.hpp"\r
#include "version.hpp"\r
+\r
#ifdef __linux__\r
#include "ServerSigHandler.hpp"\r
#include <csignal>\r
\r
switch (c.header()) {\r
\r
+ // フルステータス要求\r
+ case network::header::ServerRequestedFullServerInfo:\r
+ {\r
+ if (auto session = c.session().lock()) {\r
+ session->Send(network::ClientReceiveFullServerInfo(server.GetFullStatus()));\r
+ }\r
+ }\r
+ break;\r
+\r
// ステータス要求\r
case network::header::ServerRequstedStatus:\r
{\r
{\r
if (auto session = c.session().lock()) {\r
\r
+ // 最大接続数を超えていないか判定\r
+ if (server.GetUserCount() >= config.capacity()) {\r
+ Logger::Info("Refused Session");\r
+ session->SyncSend(network::ClientReceiveServerCrowdedError());\r
+ session->Close();\r
+\r
+ }\r
+\r
session->ResetReadByteAverage();\r
\r
std::string finger_print;\r