From 573c4be436f07a295adce8c06f45264d1c18fc1d Mon Sep 17 00:00:00 2001 From: prozacx Date: Tue, 19 Jul 2005 05:19:48 +0000 Subject: [PATCH] Added global vhosts and getters/setters for ISpoof* git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@453 726aef4b-f618-498e-8847-2d620e286838 --- znc.cpp | 23 +++++++++++++++++++++++ znc.h | 11 +++++++++++ 2 files changed, 34 insertions(+) diff --git a/znc.cpp b/znc.cpp index 9c877b8b..bd6a0921 100644 --- a/znc.cpp +++ b/znc.cpp @@ -324,6 +324,10 @@ bool CZNC::WriteConfig() { if (!m_sPidFile.empty()) { File.Write("PidFile = " + m_sPidFile + "\r\n"); } if (!m_sStatusPrefix.empty()) { File.Write("StatusPrefix = " + m_sStatusPrefix + "\r\n"); } + for (unsigned int v = 0; v < m_vsVHosts.size(); v++) { + File.Write("VHost = " + m_vsVHosts[v] + "\r\n"); + } + #ifdef _MODULES CGlobalModules& Mods = GetModules(); @@ -975,6 +979,9 @@ bool CZNC::ParseConfig(const CString& sConfig) { } else if (sName.CaseCmp("ISpoofFile") == 0) { m_sISpoofFile = sValue; continue; + } else if (sName.CaseCmp("VHost") == 0) { + AddVHost(sValue); + continue; } else if (sName.CaseCmp("PidFile") == 0) { if (!sValue.empty() && sValue[0] != '/') { m_sPidFile = GetZNCPath() + "/" + sValue; @@ -1008,6 +1015,22 @@ bool CZNC::ParseConfig(const CString& sConfig) { return true; } +bool CZNC::AddVHost(const CString& sHost) { + for (unsigned int a = 0; a < m_vsVHosts.size(); a++) { + if (m_vsVHosts[a].CaseCmp(sHost) == 0) { + return false; + } + } + + m_vsVHosts.push_back(sHost); + return true; +} + +bool CZNC::RemVHost(const CString& sHost) { + // @todo + return true; +} + CString CZNC::FindModPath(const CString& sModule) const { CString sModPath = GetCurPath() + "/modules/" + sModule; sModPath += (sModule.find(".") == CString::npos) ? ".so" : ""; diff --git a/znc.h b/znc.h index 40dd2ae7..609229cf 100644 --- a/znc.h +++ b/znc.h @@ -35,6 +35,13 @@ public: bool WriteConfig(); static CString GetTag(bool bIncludeVersion = true); CString FindModPath(const CString& sModule) const; + bool AddVHost(const CString& sHost); + bool RemVHost(const CString& sHost); + + // Setters + void SetISpoofFile(const CString& s) { m_sISpoofFile = s; } + void SetISpoofFormat(const CString& s) { m_sISpoofFormat = s; } + // !Setters // Getters TSocketManager& GetManager() { return m_Manager; } @@ -50,6 +57,9 @@ public: const CString& GetConfBackupPath() const { if (!CFile::Exists(m_sConfBackupPath)) { CUtils::MakeDir(m_sConfBackupPath); } return m_sConfBackupPath; } const CString& GetUserPath() const { if (!CFile::Exists(m_sUserPath)) { CUtils::MakeDir(m_sUserPath); } return m_sUserPath; } CString GetPemLocation() const { return GetZNCPath() + "/znc.pem"; } + const CString& GetISpoofFile() const { return m_sISpoofFile; } + const CString& GetISpoofFormat() const { return m_sISpoofFormat; } + const VCString& GetVHosts() const { return m_vsVHosts; } bool IsSSL() const { #ifdef HAVE_LIBSSL @@ -91,6 +101,7 @@ protected: CString m_sOrigISpoof; CString m_sISpoofFormat; CString m_sPidFile; + VCString m_vsVHosts; CLockFile m_LockFile; bool m_bISpoofLocked; bool m_bSSL;