diff options
| author | 2019-03-30 22:06:19 +0000 | |
|---|---|---|
| committer | 2019-03-30 22:06:19 +0000 | |
| commit | 1fff2f7f87fa0e69494fe45902cfa315204d1e43 (patch) | |
| tree | b4f3eac01dc458cc7f3ab5b43a57c44d06044bed /src/configreader.cpp | |
| parent | Remove the flashpolicyd module. (diff) | |
| parent | Rename OnClientProtocolPopulateTags to OnPopulateTags. (diff) | |
Merge branch 'insp3' into master.
Diffstat (limited to 'src/configreader.cpp')
| -rw-r--r-- | src/configreader.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/src/configreader.cpp b/src/configreader.cpp index 675bc4721..b844be382 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -75,6 +75,8 @@ ServerConfig::~ServerConfig() static void ReadXLine(ServerConfig* conf, const std::string& tag, const std::string& key, XLineFactory* make) { + insp::flat_set<std::string> configlines; + ConfigTagList tags = conf->ConfTags(tag); for(ConfigIter i = tags.first; i != tags.second; ++i) { @@ -85,9 +87,12 @@ static void ReadXLine(ServerConfig* conf, const std::string& tag, const std::str std::string reason = ctag->getString("reason", "<Config>"); XLine* xl = make->Generate(ServerInstance->Time(), 0, "<Config>", reason, mask); xl->from_config = true; + configlines.insert(xl->Displayable()); if (!ServerInstance->XLines->AddLine(xl, NULL)) delete xl; } + + ServerInstance->XLines->ExpireRemovedConfigLines(make->GetType(), configlines); } typedef std::map<std::string, ConfigTag*> LocalIndex; @@ -310,6 +315,23 @@ void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) } } +static std::string GetServerName() +{ +#ifndef _WIN32 + char hostname[256]; + if (gethostname(hostname, sizeof(hostname)) == 0) + { + std::string name(hostname); + if (name.find('.') == std::string::npos) + name.push_back('.'); + + if (name.length() <= ServerInstance->Config->Limits.MaxHost && InspIRCd::IsHost(name)) + return name; + } +#endif + return "irc.example.com"; +} + void ServerConfig::Fill() { ConfigTag* options = ConfValue("options"); @@ -317,7 +339,7 @@ void ServerConfig::Fill() ConfigTag* server = ConfValue("server"); if (sid.empty()) { - ServerName = server->getString("name", "irc.example.com", InspIRCd::IsHost); + ServerName = server->getString("name", GetServerName(), InspIRCd::IsHost); sid = server->getString("id"); if (!sid.empty() && !InspIRCd::IsSID(sid)) @@ -374,7 +396,6 @@ void ServerConfig::Fill() SocketEngine::Close(socktest); } - ServerInstance->XLines->ClearConfigLines(); ReadXLine(this, "badip", "ipmask", ServerInstance->XLines->GetFactory("Z")); ReadXLine(this, "badnick", "nick", ServerInstance->XLines->GetFactory("Q")); ReadXLine(this, "badhost", "host", ServerInstance->XLines->GetFactory("K")); |
