Add minetest.get_player_ip()
parent
3d4d0cb574
commit
4a9b8aae5e
|
@ -1002,6 +1002,7 @@ minetest.auth_reload()
|
||||||
^ These call the authentication handler
|
^ These call the authentication handler
|
||||||
minetest.check_player_privs(name, {priv1=true,...}) -> bool, missing_privs
|
minetest.check_player_privs(name, {priv1=true,...}) -> bool, missing_privs
|
||||||
^ A quickhand for checking privileges
|
^ A quickhand for checking privileges
|
||||||
|
minetest.get_player_ip(name) -> IP address string
|
||||||
|
|
||||||
Chat:
|
Chat:
|
||||||
minetest.chat_send_all(text)
|
minetest.chat_send_all(text)
|
||||||
|
|
|
@ -788,6 +788,31 @@ static int l_get_player_privs(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get_player_ip()
|
||||||
|
static int l_get_player_ip(lua_State *L)
|
||||||
|
{
|
||||||
|
const char * name = luaL_checkstring(L, 1);
|
||||||
|
Player *player = get_env(L)->getPlayer(name);
|
||||||
|
if(player == NULL)
|
||||||
|
{
|
||||||
|
lua_pushnil(L); // no such player
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Address addr = get_server(L)->getPeerAddress(get_env(L)->getPlayer(name)->peer_id);
|
||||||
|
std::string ip_str = addr.serializeString();
|
||||||
|
lua_pushstring(L, ip_str.c_str());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
catch(con::PeerNotFoundException) // unlikely
|
||||||
|
{
|
||||||
|
dstream << __FUNCTION_NAME << ": peer was not found" << std::endl;
|
||||||
|
lua_pushnil(L); // error
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// get_ban_list()
|
// get_ban_list()
|
||||||
static int l_get_ban_list(lua_State *L)
|
static int l_get_ban_list(lua_State *L)
|
||||||
{
|
{
|
||||||
|
@ -1084,6 +1109,7 @@ static const struct luaL_Reg minetest_f [] = {
|
||||||
{"chat_send_all", l_chat_send_all},
|
{"chat_send_all", l_chat_send_all},
|
||||||
{"chat_send_player", l_chat_send_player},
|
{"chat_send_player", l_chat_send_player},
|
||||||
{"get_player_privs", l_get_player_privs},
|
{"get_player_privs", l_get_player_privs},
|
||||||
|
{"get_player_ip", l_get_player_ip},
|
||||||
{"get_ban_list", l_get_ban_list},
|
{"get_ban_list", l_get_ban_list},
|
||||||
{"get_ban_description", l_get_ban_description},
|
{"get_ban_description", l_get_ban_description},
|
||||||
{"ban_player", l_ban_player},
|
{"ban_player", l_ban_player},
|
||||||
|
|
Loading…
Reference in New Issue