Example #1
0
    void OnGetAvailableMods(set<CModInfo>& ssMods,
                            CModInfo::EModuleType eType) override {
        CDir Dir;
        CModules::ModDirList dirs = CModules::GetModDirs();

        while (!dirs.empty()) {
            set<CString> already;

            Dir.Fill(dirs.front().first);
            for (unsigned int a = 0; a < Dir.size(); a++) {
                CFile& File = *Dir[a];
                CString sName = File.GetShortName();
                CString sPath = File.GetLongName();
                sPath.TrimSuffix(sName);

                if (!File.IsDir()) {
                    if (sName.WildCmp("*.pyc")) {
                        sName.RightChomp(4);
                    } else if (sName.WildCmp("*.py") || sName.WildCmp("*.so")) {
                        sName.RightChomp(3);
                    } else {
                        continue;
                    }
                }

                TryAddModInfo(sPath, sName, ssMods, already, eType);
            }

            dirs.pop();
        }
    }
Example #2
0
	bool IsMatch(const CString& sChan, const CString& sHost) const {
		if (!sHost.WildCmp(m_sHostmaskWildcard))
			return false;
		if (!sChan.WildCmp(m_sChannelWildcard))
			return false;
		return true;
	}
Example #3
0
void CIncomingConnection::ReadLine(const CString& sLine) {
    bool bIsHTTP = (sLine.WildCmp("GET * HTTP/1.?\r\n") ||
                    sLine.WildCmp("POST * HTTP/1.?\r\n"));
    bool bAcceptHTTP = (m_eAcceptType == CListener::ACCEPT_ALL) ||
                       (m_eAcceptType == CListener::ACCEPT_HTTP);
    bool bAcceptIRC = (m_eAcceptType == CListener::ACCEPT_ALL) ||
                      (m_eAcceptType == CListener::ACCEPT_IRC);
    Csock* pSock = nullptr;

    if (!bIsHTTP) {
        // Let's assume it's an IRC connection

        if (!bAcceptIRC) {
            Write("ERROR :We don't take kindly to your types around here!\r\n");
            Close(CLT_AFTERWRITE);

            DEBUG("Refused IRC connection to non IRC port");
            return;
        }

        pSock = new CClient();
        CZNC::Get().GetManager().SwapSockByAddr(pSock, this);

        // And don't forget to give it some sane name / timeout
        pSock->SetSockName("USR::???");
    } else {
        // This is a HTTP request, let the webmods handle it

        if (!bAcceptHTTP) {
            Write(
                "HTTP/1.0 403 Access Denied\r\n\r\nWeb Access is not "
                "enabled.\r\n");
            Close(CLT_AFTERWRITE);

            DEBUG("Refused HTTP connection to non HTTP port");
            return;
        }

        pSock = new CWebSock(m_sURIPrefix);
        CZNC::Get().GetManager().SwapSockByAddr(pSock, this);

        // And don't forget to give it some sane name / timeout
        pSock->SetSockName("WebMod::Client");
    }

    // TODO can we somehow get rid of this?
    pSock->ReadLine(sLine);
    pSock->PushBuff("", 0, true);
}
Example #4
0
	bool IsAutoCycle(const CString& sChan) {
		for (unsigned int a = 0; a < m_vsNegChans.size(); a++) {
			if (sChan.WildCmp(m_vsNegChans[a])) {
				return false;
			}
		}

		for (unsigned int b = 0; b < m_vsChans.size(); b++) {
			if (sChan.WildCmp(m_vsChans[b])) {
				return true;
			}
		}

		return false;
	}
Example #5
0
File: User.cpp Project: johnfb/znc
bool CUser::IsHostAllowed(const CString& sHostMask) const {
	if (m_ssAllowedHosts.empty()) {
		return true;
	}

	for (set<CString>::const_iterator a = m_ssAllowedHosts.begin(); a != m_ssAllowedHosts.end(); ++a) {
		if (sHostMask.WildCmp(*a)) {
			return true;
		}
	}

	return false;
}
Example #6
0
File: Modules.cpp Project: md-5/znc
void CModule::HandleHelpCommand(const CString& sLine) {
	CString sFilter = sLine.Token(1).AsLower();
	CString::size_type  iFilterLength = sFilter.size();
	CTable Table;
	map<CString, CModCommand>::const_iterator it;

	CModCommand::InitHelp(Table);
	for (it = m_mCommands.begin(); it != m_mCommands.end(); ++it) {
		CString sCmd = it->second.GetCommand().AsLower();
		if (sFilter.empty() || (sCmd.Equals(sFilter, true, iFilterLength)) || sCmd.WildCmp(sFilter)) {
			it->second.AddHelp(Table);
		}
	}
	if (Table.empty()) {
		PutModule("No matches for '" + sFilter + "'");
	} else {
		PutModule(Table);
	}
}
Example #7
0
 bool HostMatches(const CString& sHostmask) {
     return sHostmask.WildCmp(m_sHostmask);
 }