Per-network bind hosts.

Fix #147
This commit is contained in:
Alexey Sokolov
2012-07-19 00:35:07 +07:00
parent 7951a50200
commit cebc093254
8 changed files with 146 additions and 9 deletions

View File

@@ -684,6 +684,38 @@ public:
}
}
// To change BindHosts be admin or don't have DenySetBindHost
if (spSession->IsAdmin() || !spSession->GetUser()->DenySetBindHost()) {
Tmpl["BindHostEdit"] = "true";
const VCString& vsBindHosts = CZNC::Get().GetBindHosts();
if (vsBindHosts.empty()) {
if (pNetwork) {
Tmpl["BindHost"] = pNetwork->GetBindHost();
}
} else {
bool bFoundBindHost = false;
for (unsigned int b = 0; b < vsBindHosts.size(); b++) {
const CString& sBindHost = vsBindHosts[b];
CTemplate& l = Tmpl.AddRow("BindHostLoop");
l["BindHost"] = sBindHost;
if (pNetwork && pNetwork->GetBindHost() == sBindHost) {
l["Checked"] = "true";
bFoundBindHost = true;
}
}
// If our current bindhost is not in the global list...
if (pNetwork && !bFoundBindHost && !pNetwork->GetBindHost().empty()) {
CTemplate& l = Tmpl.AddRow("BindHostLoop");
l["BindHost"] = pNetwork->GetBindHost();
l["Checked"] = "true";
}
}
}
if (pNetwork) {
Tmpl["Action"] = "editnetwork";
Tmpl["Edit"] = "true";
@@ -767,6 +799,12 @@ public:
pNetwork->SetIRCConnectEnabled(WebSock.GetParam("doconnect").ToBool());
sArg = WebSock.GetParam("bindhost");
// To change BindHosts be admin or don't have DenySetBindHost
if (spSession->IsAdmin() || !spSession->GetUser()->DenySetBindHost()) {
pNetwork->SetBindHost(WebSock.GetParam("bindhost"));
}
if (WebSock.GetParam("floodprotection").ToBool()) {
pNetwork->SetFloodRate(WebSock.GetParam("floodrate").ToDouble());
pNetwork->SetFloodBurst(WebSock.GetParam("floodburst").ToUInt());