Created by
Leslie Krause
last modified
| diff --git a/builtin/game/register.lua b/builtin/game/register.lua
index f330491..51d93d5 100644
--- a/builtin/game/register.lua
+++ b/builtin/game/register.lua
@@ -510,6 +510,7 @@ core.registered_craft_predicts, core.register_craft_predict = make_registration(
core.registered_on_protection_violation, core.register_on_protection_violation = make_registration()
core.registered_on_item_eats, core.register_on_item_eat = make_registration()
core.registered_on_punchplayers, core.register_on_punchplayer = make_registration()
+core.registered_on_auth_fail, core.register_on_auth_fail = make_registration()
--
-- Compatibility for on_mapgen_init()
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp
index 1bcb78a..7ebdc38 100644
--- a/src/network/serverpackethandler.cpp
+++ b/src/network/serverpackethandler.cpp
@@ -572,6 +572,7 @@ void Server::handleCommand_Init_Legacy(NetworkPacket* pkt)
<< " at " << addr_s
<< " supplied wrong password (auth mechanism: legacy)."
<< std::endl;
+ m_script->on_auth_failure(playername, addr_s);
DenyAccess_Legacy(pkt->getPeerId(), L"Wrong password");
return;
}
@@ -2020,10 +2021,12 @@ void Server::handleCommand_SrpBytesM(NetworkPacket* pkt)
DenySudoAccess(pkt->getPeerId());
return;
} else {
+ std::string ip = getPeerAddress(pkt->getPeerId()).serializeString();
actionstream << "Server: User " << client->getName()
- << " at " << getPeerAddress(pkt->getPeerId()).serializeString()
+ << " at " << ip
<< " supplied wrong password (auth mechanism: SRP)."
<< std::endl;
+ m_script->on_auth_failure(client->getName(), ip);
DenyAccess(pkt->getPeerId(), SERVER_ACCESSDENIED_WRONG_PASSWORD);
return;
}
diff --git a/src/script/cpp_api/s_player.cpp b/src/script/cpp_api/s_player.cpp
index 8074306..bab29ee 100644
--- a/src/script/cpp_api/s_player.cpp
+++ b/src/script/cpp_api/s_player.cpp
@@ -190,8 +190,17 @@ void ScriptApiPlayer::on_playerReceiveFields(ServerActiveObject *player,
runCallbacks(3, RUN_CALLBACKS_MODE_OR_SC);
}
-ScriptApiPlayer::~ScriptApiPlayer()
+void ScriptApiPlayer::on_auth_failure(const std::string &name, const std::string &ip)
{
+ SCRIPTAPI_PRECHECKHEADER
+ // Get core.registered_on_auth_failure
+ lua_getglobal(L, "core");
+ lua_getfield(L, -1, "registered_on_auth_fail");
+ lua_pushstring(L, name.c_str());
+ lua_pushstring(L, ip.c_str());
+ runCallbacks(2, RUN_CALLBACKS_MODE_FIRST);
}
-
+ScriptApiPlayer::~ScriptApiPlayer()
+{
+}
diff --git a/src/script/cpp_api/s_player.h b/src/script/cpp_api/s_player.h
index 2e4dc22..5fb1d61 100644
--- a/src/script/cpp_api/s_player.h
+++ b/src/script/cpp_api/s_player.h
@@ -46,6 +46,7 @@ class ScriptApiPlayer
s16 on_player_hpchange(ServerActiveObject *player, s16 hp_change);
void on_playerReceiveFields(ServerActiveObject *player,
const std::string &formname, const StringMap &fields);
+ void on_auth_failure(const std::string &name, const std::string &ip);
};
|
| diff --git a/builtin/game/register.lua b/builtin/game/register.lua
index 90f095e..364989a 100644
--- a/builtin/game/register.lua
+++ b/builtin/game/register.lua
@@ -553,6 +553,7 @@ core.registered_craft_predicts, core.register_craft_predict = make_registration(
core.registered_on_protection_violation, core.register_on_protection_violation = make_registration()
core.registered_on_item_eats, core.register_on_item_eat = make_registration()
core.registered_on_punchplayers, core.register_on_punchplayer = make_registration()
+core.registered_on_auth_fail, core.register_on_auth_fail = make_registration()
--
-- Compatibility for on_mapgen_init()
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp
index dca9aab..00106bd 100644
--- a/src/network/serverpackethandler.cpp
+++ b/src/network/serverpackethandler.cpp
@@ -572,6 +572,7 @@ void Server::handleCommand_Init_Legacy(NetworkPacket* pkt)
<< " at " << addr_s
<< " supplied wrong password (auth mechanism: legacy)."
<< std::endl;
+ m_script->on_auth_failure(playername, addr_s);
DenyAccess_Legacy(pkt->getPeerId(), L"Wrong password");
return;
}
@@ -2046,10 +2047,12 @@ void Server::handleCommand_SrpBytesM(NetworkPacket* pkt)
DenySudoAccess(pkt->getPeerId());
return;
} else {
+ std::string ip = getPeerAddress(pkt->getPeerId()).serializeString();
actionstream << "Server: User " << client->getName()
- << " at " << getPeerAddress(pkt->getPeerId()).serializeString()
+ << " at " << ip
<< " supplied wrong password (auth mechanism: SRP)."
<< std::endl;
+ m_script->on_auth_failure(client->getName(), ip);
DenyAccess(pkt->getPeerId(), SERVER_ACCESSDENIED_WRONG_PASSWORD);
return;
}
diff --git a/src/script/cpp_api/s_player.cpp b/src/script/cpp_api/s_player.cpp
index a8c0747..211efdc 100644
--- a/src/script/cpp_api/s_player.cpp
+++ b/src/script/cpp_api/s_player.cpp
@@ -192,8 +192,17 @@ void ScriptApiPlayer::on_playerReceiveFields(ServerActiveObject *player,
runCallbacks(3, RUN_CALLBACKS_MODE_OR_SC);
}
-ScriptApiPlayer::~ScriptApiPlayer()
+void ScriptApiPlayer::on_auth_failure(const std::string &name, const std::string &ip)
{
+ SCRIPTAPI_PRECHECKHEADER
+ // Get core.registered_on_auth_failure
+ lua_getglobal(L, "core");
+ lua_getfield(L, -1, "registered_on_auth_fail");
+ lua_pushstring(L, name.c_str());
+ lua_pushstring(L, ip.c_str());
+ runCallbacks(2, RUN_CALLBACKS_MODE_FIRST);
}
-
+ScriptApiPlayer::~ScriptApiPlayer()
+{
+}
diff --git a/src/script/cpp_api/s_player.h b/src/script/cpp_api/s_player.h
index 86ee1b0..5d0c80d 100644
--- a/src/script/cpp_api/s_player.h
+++ b/src/script/cpp_api/s_player.h
@@ -46,6 +46,7 @@ class ScriptApiPlayer
s16 on_player_hpchange(ServerActiveObject *player, s16 hp_change);
void on_playerReceiveFields(ServerActiveObject *player,
const std::string &formname, const StringMap &fields);
+ void on_auth_failure(const std::string &name, const std::string &ip);
};
|
| diff --git a/builtin/game/register.lua b/builtin/game/register.lua
index ec6f280..2a3301d 100644
--- a/builtin/game/register.lua
+++ b/builtin/game/register.lua
@@ -553,6 +553,7 @@ core.registered_craft_predicts, core.register_craft_predict = make_registration(
core.registered_on_protection_violation, core.register_on_protection_violation = make_registration()
core.registered_on_item_eats, core.register_on_item_eat = make_registration()
core.registered_on_punchplayers, core.register_on_punchplayer = make_registration()
+core.registered_on_auth_fail, core.register_on_auth_fail = make_registration()
--
-- Compatibility for on_mapgen_init()
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp
index 5b026bb..5782595 100644
--- a/src/network/serverpackethandler.cpp
+++ b/src/network/serverpackethandler.cpp
@@ -573,6 +573,7 @@ void Server::handleCommand_Init_Legacy(NetworkPacket* pkt)
<< " at " << addr_s
<< " supplied wrong password (auth mechanism: legacy)."
<< std::endl;
+ m_script->on_auth_failure(playername, addr_s);
DenyAccess_Legacy(pkt->getPeerId(), L"Wrong password");
return;
}
@@ -2022,10 +2023,12 @@ void Server::handleCommand_SrpBytesM(NetworkPacket* pkt)
DenySudoAccess(pkt->getPeerId());
return;
} else {
+ std::string ip = getPeerAddress(pkt->getPeerId()).serializeString();
actionstream << "Server: User " << client->getName()
- << " at " << getPeerAddress(pkt->getPeerId()).serializeString()
+ << " at " << ip
<< " supplied wrong password (auth mechanism: SRP)."
<< std::endl;
+ m_script->on_auth_failure(client->getName(), ip);
DenyAccess(pkt->getPeerId(), SERVER_ACCESSDENIED_WRONG_PASSWORD);
return;
}
diff --git a/src/script/cpp_api/s_player.cpp b/src/script/cpp_api/s_player.cpp
index a8c0747..167bf33 100644
--- a/src/script/cpp_api/s_player.cpp
+++ b/src/script/cpp_api/s_player.cpp
@@ -192,6 +192,17 @@ void ScriptApiPlayer::on_playerReceiveFields(ServerActiveObject *player,
runCallbacks(3, RUN_CALLBACKS_MODE_OR_SC);
}
+void ScriptApiPlayer::on_auth_failure(const std::string &name, const std::string &ip)
+{
+ SCRIPTAPI_PRECHECKHEADER
+ // Get core.registered_on_auth_failure
+ lua_getglobal(L, "core");
+ lua_getfield(L, -1, "registered_on_auth_fail");
+ lua_pushstring(L, name.c_str());
+ lua_pushstring(L, ip.c_str());
+ runCallbacks(2, RUN_CALLBACKS_MODE_FIRST);
+}
+
ScriptApiPlayer::~ScriptApiPlayer()
{
}
diff --git a/src/script/cpp_api/s_player.h b/src/script/cpp_api/s_player.h
index 9b4611f..9cd5251 100644
--- a/src/script/cpp_api/s_player.h
+++ b/src/script/cpp_api/s_player.h
@@ -45,6 +45,7 @@ class ScriptApiPlayer : virtual public ScriptApiBase
s16 on_player_hpchange(ServerActiveObject *player, s16 hp_change);
void on_playerReceiveFields(ServerActiveObject *player,
const std::string &formname, const StringMap &fields);
+ void on_auth_failure(const std::string &name, const std::string &ip);
};
#endif /* S_PLAYER_H_ */
|
| diff --git a/builtin/game/register.lua b/builtin/game/register.lua
index 25af24e..9f81d24 100644
--- a/builtin/game/register.lua
+++ b/builtin/game/register.lua
@@ -561,6 +561,7 @@ core.registered_craft_predicts, core.register_craft_predict = make_registration(
core.registered_on_protection_violation, core.register_on_protection_violation = make_registration()
core.registered_on_item_eats, core.register_on_item_eat = make_registration()
core.registered_on_punchplayers, core.register_on_punchplayer = make_registration()
+core.registered_on_auth_fail, core.register_on_auth_fail = make_registration()
--
-- Compatibility for on_mapgen_init()
diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp
index fc64c14..43575f9 100644
--- a/src/network/serverpackethandler.cpp
+++ b/src/network/serverpackethandler.cpp
@@ -573,6 +573,7 @@ void Server::handleCommand_Init_Legacy(NetworkPacket* pkt)
<< " at " << addr_s
<< " supplied wrong password (auth mechanism: legacy)."
<< std::endl;
+ m_script->on_auth_failure(playername, addr_s);
DenyAccess_Legacy(pkt->getPeerId(), L"Wrong password");
return;
}
@@ -2045,10 +2046,12 @@ void Server::handleCommand_SrpBytesM(NetworkPacket* pkt)
DenySudoAccess(pkt->getPeerId());
return;
} else {
+ std::string ip = getPeerAddress(pkt->getPeerId()).serializeString();
actionstream << "Server: User " << client->getName()
- << " at " << getPeerAddress(pkt->getPeerId()).serializeString()
+ << " at " << ip
<< " supplied wrong password (auth mechanism: SRP)."
<< std::endl;
+ m_script->on_auth_failure(client->getName(), ip);
DenyAccess(pkt->getPeerId(), SERVER_ACCESSDENIED_WRONG_PASSWORD);
return;
}
diff --git a/src/script/cpp_api/s_player.cpp b/src/script/cpp_api/s_player.cpp
index a8c0747..211efdc 100644
--- a/src/script/cpp_api/s_player.cpp
+++ b/src/script/cpp_api/s_player.cpp
@@ -192,8 +192,17 @@ void ScriptApiPlayer::on_playerReceiveFields(ServerActiveObject *player,
runCallbacks(3, RUN_CALLBACKS_MODE_OR_SC);
}
-ScriptApiPlayer::~ScriptApiPlayer()
+void ScriptApiPlayer::on_auth_failure(const std::string &name, const std::string &ip)
{
+ SCRIPTAPI_PRECHECKHEADER
+ // Get core.registered_on_auth_failure
+ lua_getglobal(L, "core");
+ lua_getfield(L, -1, "registered_on_auth_fail");
+ lua_pushstring(L, name.c_str());
+ lua_pushstring(L, ip.c_str());
+ runCallbacks(2, RUN_CALLBACKS_MODE_FIRST);
}
-
+ScriptApiPlayer::~ScriptApiPlayer()
+{
+}
diff --git a/src/script/cpp_api/s_player.h b/src/script/cpp_api/s_player.h
index 9b4611f..9cd5251 100644
--- a/src/script/cpp_api/s_player.h
+++ b/src/script/cpp_api/s_player.h
@@ -45,6 +45,7 @@ class ScriptApiPlayer : virtual public ScriptApiBase
s16 on_player_hpchange(ServerActiveObject *player, s16 hp_change);
void on_playerReceiveFields(ServerActiveObject *player,
const std::string &formname, const StringMap &fields);
+ void on_auth_failure(const std::string &name, const std::string &ip);
};
#endif /* S_PLAYER_H_ */
|