mirror of
https://github.com/znc/znc.git
synced 2026-05-09 23:04:47 +02:00
Merge remote-tracking branch 'origin/1.6'
This commit is contained in:
+1
-1
@@ -48,7 +48,7 @@ LIB_SRCS := $(addprefix src/,$(LIB_SRCS))
|
||||
BIN_SRCS := src/main.cpp
|
||||
LIB_OBJS := $(patsubst %cpp,%o,$(LIB_SRCS))
|
||||
BIN_OBJS := $(patsubst %cpp,%o,$(BIN_SRCS))
|
||||
TESTS := StringTest ConfigTest UtilsTest ThreadTest NickTest ClientTest
|
||||
TESTS := StringTest ConfigTest UtilsTest ThreadTest NickTest ClientTest NetworkTest
|
||||
TESTS := $(addprefix test/,$(addsuffix .o,$(TESTS)))
|
||||
CLEAN := znc src/*.o test/*.o core core.* .version_extra .depend modules/.depend unittest
|
||||
DISTCLEAN := Makefile config.log config.status znc-buildmod include/znc/zncconfig.h \
|
||||
|
||||
+2
-2
@@ -70,11 +70,11 @@ public:
|
||||
AddCommand("Help", static_cast<CModCommand::ModCmdFunc>(&CSASLMod::PrintHelp),
|
||||
"search", "Generate this output");
|
||||
AddCommand("Set", static_cast<CModCommand::ModCmdFunc>(&CSASLMod::Set),
|
||||
"username password", "Set username and password for the PLAIN mechanism");
|
||||
"<username> [<password>]", "Set username and password for the mechanisms that need them. Password is optional");
|
||||
AddCommand("Mechanism", static_cast<CModCommand::ModCmdFunc>(&CSASLMod::SetMechanismCommand),
|
||||
"[mechanism[ ...]]", "Set the mechanisms to be attempted (in order)");
|
||||
AddCommand("RequireAuth", static_cast<CModCommand::ModCmdFunc>(&CSASLMod::RequireAuthCommand),
|
||||
"[yes|no]", "Don't connect if SASL cannot be authenticated");
|
||||
"[yes|no]", "Don't connect unless SASL authentication succeeds");
|
||||
|
||||
m_bAuthenticated = false;
|
||||
}
|
||||
|
||||
@@ -93,13 +93,13 @@ public:
|
||||
else
|
||||
m_sPassword = CBlowfish::MD5(sArgs);
|
||||
|
||||
AddTimer(new CSaveBuffJob(this, 60, 0, "SaveBuff", "Saves the current buffer to disk every 1 minute"));
|
||||
|
||||
return( !m_bBootError );
|
||||
}
|
||||
|
||||
virtual bool OnBoot() override
|
||||
{
|
||||
AddTimer(new CSaveBuffJob(this, 60, 0, "SaveBuff", "Saves the current buffer to disk every 1 minute"));
|
||||
|
||||
CDir saveDir(GetSavePath());
|
||||
for (CFile* pFile : saveDir) {
|
||||
CString sName;
|
||||
|
||||
+4
-2
@@ -787,8 +787,9 @@ CChan* CIRCNetwork::FindChan(CString sName) const {
|
||||
std::vector<CChan*> CIRCNetwork::FindChans(const CString& sWild) const {
|
||||
std::vector<CChan*> vChans;
|
||||
vChans.reserve(m_vChans.size());
|
||||
const CString sLower = sWild.AsLower();
|
||||
for (std::vector<CChan*>::const_iterator it = m_vChans.begin(); it != m_vChans.end(); ++it) {
|
||||
if ((*it)->GetName().WildCmp(sWild))
|
||||
if ((*it)->GetName().AsLower().WildCmp(sLower))
|
||||
vChans.push_back(*it);
|
||||
}
|
||||
return vChans;
|
||||
@@ -946,8 +947,9 @@ CQuery* CIRCNetwork::FindQuery(const CString& sName) const {
|
||||
std::vector<CQuery*> CIRCNetwork::FindQueries(const CString& sWild) const {
|
||||
std::vector<CQuery*> vQueries;
|
||||
vQueries.reserve(m_vQueries.size());
|
||||
const CString sLower = sWild.AsLower();
|
||||
for (std::vector<CQuery*>::const_iterator it = m_vQueries.begin(); it != m_vQueries.end(); ++it) {
|
||||
if ((*it)->GetName().WildCmp(sWild))
|
||||
if ((*it)->GetName().AsLower().WildCmp(sLower))
|
||||
vQueries.push_back(*it);
|
||||
}
|
||||
return vQueries;
|
||||
|
||||
@@ -119,7 +119,7 @@ inline char Curl_raw_toupper(char in)
|
||||
* The function is capable of comparing a-z case insensitively even for
|
||||
* non-ascii.
|
||||
*/
|
||||
int Curl_raw_equal(const char *first, const char *second)
|
||||
static int Curl_raw_equal(const char *first, const char *second)
|
||||
{
|
||||
while(*first && *second) {
|
||||
if(Curl_raw_toupper(*first) != Curl_raw_toupper(*second))
|
||||
@@ -133,7 +133,7 @@ int Curl_raw_equal(const char *first, const char *second)
|
||||
return this as a successful match */
|
||||
return (Curl_raw_toupper(*first) == Curl_raw_toupper(*second));
|
||||
}
|
||||
int Curl_raw_nequal(const char *first, const char *second, size_t max)
|
||||
static int Curl_raw_nequal(const char *first, const char *second, size_t max)
|
||||
{
|
||||
while(*first && *second && max) {
|
||||
if(Curl_raw_toupper(*first) != Curl_raw_toupper(*second)) {
|
||||
@@ -234,7 +234,7 @@ static int hostmatch(char *hostname, char *pattern)
|
||||
CURL_HOST_MATCH : CURL_HOST_NOMATCH;
|
||||
}
|
||||
|
||||
int Curl_cert_hostcheck(const char *match_pattern, const char *hostname)
|
||||
static int Curl_cert_hostcheck(const char *match_pattern, const char *hostname)
|
||||
{
|
||||
char *matchp;
|
||||
char *hostp;
|
||||
|
||||
+1
-1
@@ -87,7 +87,7 @@ CThreadPool::~CThreadPool() {
|
||||
CMutexLocker guard(m_mutex);
|
||||
m_done = true;
|
||||
|
||||
if (m_num_threads > 0) {
|
||||
while (m_num_threads > 0) {
|
||||
m_cond.broadcast();
|
||||
m_exit_cond.wait(m_mutex);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (C) 2004-2015 ZNC, see the NOTICE file for details.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <znc/IRCNetwork.h>
|
||||
#include <znc/User.h>
|
||||
#include <znc/znc.h>
|
||||
|
||||
class NetworkTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() { CZNC::CreateInstance(); }
|
||||
void TearDown() { CZNC::DestroyInstance(); }
|
||||
};
|
||||
|
||||
TEST_F(NetworkTest, FindChan) {
|
||||
CUser user("user");
|
||||
CIRCNetwork network(&user, "network");
|
||||
|
||||
EXPECT_TRUE(network.AddChan("#foo", false));
|
||||
EXPECT_TRUE(network.AddChan("#Bar", false));
|
||||
EXPECT_TRUE(network.AddChan("#BAZ", false));
|
||||
|
||||
EXPECT_TRUE(network.FindChan("#foo"));
|
||||
EXPECT_TRUE(network.FindChan("#Bar"));
|
||||
EXPECT_TRUE(network.FindChan("#BAZ"));
|
||||
|
||||
EXPECT_TRUE(network.FindChan("#Foo"));
|
||||
EXPECT_TRUE(network.FindChan("#BAR"));
|
||||
EXPECT_TRUE(network.FindChan("#baz"));
|
||||
|
||||
EXPECT_FALSE(network.FindChan("#f"));
|
||||
EXPECT_FALSE(network.FindChan("&foo"));
|
||||
EXPECT_FALSE(network.FindChan("##foo"));
|
||||
}
|
||||
|
||||
TEST_F(NetworkTest, FindChans) {
|
||||
CUser user("user");
|
||||
CIRCNetwork network(&user, "network");
|
||||
|
||||
EXPECT_TRUE(network.AddChan("#foo", false));
|
||||
EXPECT_TRUE(network.AddChan("#Bar", false));
|
||||
EXPECT_TRUE(network.AddChan("#BAZ", false));
|
||||
|
||||
EXPECT_EQ(network.FindChans("#f*").size(), 1);
|
||||
EXPECT_EQ(network.FindChans("#b*").size(), 2);
|
||||
EXPECT_EQ(network.FindChans("#?A*").size(), 2);
|
||||
EXPECT_EQ(network.FindChans("*z").size(), 1);
|
||||
}
|
||||
|
||||
TEST_F(NetworkTest, FindQuery) {
|
||||
CUser user("user");
|
||||
CIRCNetwork network(&user, "network");
|
||||
|
||||
EXPECT_TRUE(network.AddQuery("foo"));
|
||||
EXPECT_TRUE(network.AddQuery("Bar"));
|
||||
EXPECT_TRUE(network.AddQuery("BAZ"));
|
||||
|
||||
EXPECT_TRUE(network.FindQuery("foo"));
|
||||
EXPECT_TRUE(network.FindQuery("Bar"));
|
||||
EXPECT_TRUE(network.FindQuery("BAZ"));
|
||||
|
||||
EXPECT_TRUE(network.FindQuery("Foo"));
|
||||
EXPECT_TRUE(network.FindQuery("BAR"));
|
||||
EXPECT_TRUE(network.FindQuery("baz"));
|
||||
|
||||
EXPECT_FALSE(network.FindQuery("f"));
|
||||
EXPECT_FALSE(network.FindQuery("fo"));
|
||||
EXPECT_FALSE(network.FindQuery("FF"));
|
||||
}
|
||||
|
||||
TEST_F(NetworkTest, FindQueries) {
|
||||
CUser user("user");
|
||||
CIRCNetwork network(&user, "network");
|
||||
|
||||
EXPECT_TRUE(network.AddQuery("foo"));
|
||||
EXPECT_TRUE(network.AddQuery("Bar"));
|
||||
EXPECT_TRUE(network.AddQuery("BAZ"));
|
||||
|
||||
EXPECT_EQ(network.FindQueries("f*").size(), 1);
|
||||
EXPECT_EQ(network.FindQueries("b*").size(), 2);
|
||||
EXPECT_EQ(network.FindQueries("?A*").size(), 2);
|
||||
EXPECT_EQ(network.FindQueries("*z").size(), 1);
|
||||
}
|
||||
Reference in New Issue
Block a user