mirror of
https://github.com/znc/znc.git
synced 2026-07-03 16:31:49 +02:00
Q module: Add web config.
Move Cloak() from the Set command to SetUseCloakedHost() so that the web config can use it also.
This commit is contained in:
+60
-3
@@ -45,7 +45,7 @@ public:
|
||||
m_bRequestPerms = GetNV("RequestPerms").ToBool();
|
||||
m_bJoinOnInvite = (sTmp = GetNV("JoinOnInvite")).empty() ? true : sTmp.ToBool();
|
||||
|
||||
// Make sure NVs are stored in config. Note: SetCloakedHost() is called further down.
|
||||
// Make sure NVs are stored in config. Note: SetUseCloakedHost() is called further down.
|
||||
SetUseChallenge(m_bUseChallenge);
|
||||
SetRequestPerms(m_bRequestPerms);
|
||||
SetJoinOnInvite(m_bJoinOnInvite);
|
||||
@@ -168,8 +168,6 @@ public:
|
||||
} else if (sSetting == "usecloakedhost") {
|
||||
SetUseCloakedHost(sValue.ToBool());
|
||||
PutModule("UseCloakedHost set");
|
||||
if (m_bUseCloakedHost && IsIRCConnected())
|
||||
Cloak();
|
||||
} else if (sSetting == "usechallenge") {
|
||||
SetUseChallenge(sValue.ToBool());
|
||||
PutModule("UseChallenge set");
|
||||
@@ -280,6 +278,62 @@ public:
|
||||
return CONTINUE;
|
||||
}
|
||||
|
||||
virtual CString GetWebMenuTitle() { return "Q"; }
|
||||
|
||||
virtual bool OnWebRequest(CWebSock& WebSock, const CString& sPageName, CTemplate& Tmpl) {
|
||||
if (sPageName == "index") {
|
||||
bool bSubmitted = (WebSock.GetParam("submitted").ToInt() != 0);
|
||||
|
||||
if (bSubmitted) {
|
||||
CString FormUsername = WebSock.GetParam("user");
|
||||
if (!FormUsername.empty())
|
||||
SetUsername(FormUsername);
|
||||
|
||||
CString FormPassword = WebSock.GetParam("password");
|
||||
if (!FormPassword.empty())
|
||||
SetPassword(FormPassword);
|
||||
|
||||
SetUseCloakedHost(WebSock.GetParam("usecloakedhost").ToBool());
|
||||
SetUseChallenge(WebSock.GetParam("usechallenge").ToBool());
|
||||
SetRequestPerms(WebSock.GetParam("requestperms").ToBool());
|
||||
SetJoinOnInvite(WebSock.GetParam("joinoninvite").ToBool());
|
||||
}
|
||||
|
||||
Tmpl["Username"] = m_sUsername;
|
||||
|
||||
CTemplate& o1 = Tmpl.AddRow("OptionLoop");
|
||||
o1["Name"] = "usecloakedhost";
|
||||
o1["DisplayName"] = "UseCloakedHost";
|
||||
o1["Tooltip"] = "Whether to cloak your hostname (+x) automatically on connect.";
|
||||
o1["Checked"] = CString(m_bUseCloakedHost);
|
||||
|
||||
CTemplate& o2 = Tmpl.AddRow("OptionLoop");
|
||||
o2["Name"] = "usechallenge";
|
||||
o2["DisplayName"] = "UseChallenge";
|
||||
o2["Tooltip"] = "Whether to use the CHALLENGEAUTH mechanism to avoid sending passwords in cleartext.";
|
||||
o2["Checked"] = CString(m_bUseChallenge);
|
||||
|
||||
CTemplate& o3 = Tmpl.AddRow("OptionLoop");
|
||||
o3["Name"] = "requestperms";
|
||||
o3["DisplayName"] = "RequestPerms";
|
||||
o3["Tooltip"] = "Whether to request voice/op from Q on join/devoice/deop.";
|
||||
o3["Checked"] = CString(m_bRequestPerms);
|
||||
|
||||
CTemplate& o4 = Tmpl.AddRow("OptionLoop");
|
||||
o4["Name"] = "joinoninvite";
|
||||
o4["DisplayName"] = "JoinOnInvite";
|
||||
o4["Tooltip"] = "Whether to join channels when Q invites you.";
|
||||
o4["Checked"] = CString(m_bJoinOnInvite);
|
||||
|
||||
if (bSubmitted) {
|
||||
WebSock.GetSession()->AddSuccess("Changes have been saved!");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_bCloaked;
|
||||
@@ -518,6 +572,9 @@ private:
|
||||
void SetUseCloakedHost(const bool bUseCloakedHost) {
|
||||
m_bUseCloakedHost = bUseCloakedHost;
|
||||
SetNV("UseCloakedHost", CString(bUseCloakedHost));
|
||||
|
||||
if (!m_bCloaked && m_bUseCloakedHost && IsIRCConnected())
|
||||
Cloak();
|
||||
}
|
||||
|
||||
void SetUseChallenge(const bool bUseChallenge) {
|
||||
|
||||
Reference in New Issue
Block a user