Implemented an option to restict access to only known players.

This commit is contained in:
Sebastian Joseph 2016-04-11 23:18:12 +02:00
parent ed1b5d942e
commit 58478a241a
3 changed files with 11 additions and 0 deletions

View File

@ -124,6 +124,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("max_users", "20"); settings->setDefault("max_users", "20");
settings->setDefault("strict_protocol_version_checking", "false"); settings->setDefault("strict_protocol_version_checking", "false");
settings->setDefault("disallow_empty_passwords","false"); settings->setDefault("disallow_empty_passwords","false");
settings->setDefault("disallow_unknown_users","false");
settings->setDefault("fixed_map_seed", ""); settings->setDefault("fixed_map_seed", "");
settings->setDefault("default_password", ""); settings->setDefault("default_password", "");
settings->setDefault("default_privs", "build, shout"); settings->setDefault("default_privs", "build, shout");

View File

@ -1856,6 +1856,14 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
SendAccessDenied(m_con, peer_id, L"Empty passwords are not allowed on this server."); SendAccessDenied(m_con, peer_id, L"Empty passwords are not allowed on this server.");
return; return;
} }
if (g_settings->getBool("disallow_unknown_users") &&
!m_authmanager.exists(playername)) {
infostream<<"Server: unknown player "<<playername
<<" was blocked"<<std::endl;
SendAccessDenied(m_con, peer_id, L"No unkown players allowed.");
return;
}
std::string checkpwd; std::string checkpwd;
if (m_authmanager.exists(playername)) { if (m_authmanager.exists(playername)) {

View File

@ -212,6 +212,8 @@
#default_password = #default_password =
# Don't let players join with an empty password # Don't let players join with an empty password
#disallow_empty_passwords = false #disallow_empty_passwords = false
# Don't let players join without a entry on the auth.txt (should be used with disallow_empty_passwords = true)
#disallow_unknown_users = false
# Available privileges: build, teleport, settime, privs, shout # Available privileges: build, teleport, settime, privs, shout
#default_privs = build, shout #default_privs = build, shout
# enable a static spawnpoint (default unset) # enable a static spawnpoint (default unset)