Merge branch 'master' into 1.7.x

This commit is contained in:
Alexey Sokolov
2018-04-06 20:22:37 +01:00
34 changed files with 6003 additions and 806 deletions
+1
View File
@@ -192,6 +192,7 @@ if(Boost_LOCALE_FOUND AND GETTEXT_MSGFMT_EXECUTABLE)
set(HAVE_I18N true)
else()
set(HAVE_I18N false)
message(STATUS "Boost.Locale is not found, disabling i18n support")
endif()
if(HAVE_I18N AND GETTEXT_MSGMERGE_EXECUTABLE)
+13 -4
View File
@@ -43,8 +43,8 @@ modperl:
* SWIG if building from git
modpython:
* python and its bundled libpython
* perl is required
* python3 and its bundled libpython
* perl is a build dependency
* macOS: Python from Homebrew is preferred over system version
* SWIG if building from git
@@ -54,6 +54,11 @@ cyrusauth:
Character Encodings:
* To get proper character encoding and charsets install ICU (`libicu4-dev`)
I18N (UI translation)
* CMake-based build only
* Boost.Locale
* gettext is a build dependency
## Installing ZNC
Currently there are 2 build systems in place: CMake and `./configure`.
@@ -67,7 +72,9 @@ but calls CMake with CMake-style parameters.
Installation from source code is performed using the CMake toolchain.
```shell
cmake .
mkdir build
cd build
cmake ..
make
make install
```
@@ -87,7 +94,9 @@ If you are building from git, you will need to run `./autogen.sh` first to
produce the `configure` script.
```shell
./configure
mkdir build
cd build
../configure
make
make install
```
+2 -1
View File
@@ -21,6 +21,7 @@
#include <znc/Nick.h>
#include <znc/ZNCString.h>
#include <znc/Buffer.h>
#include <znc/Translation.h>
#include <map>
// Forward Declarations
@@ -31,7 +32,7 @@ class CConfig;
class CFile;
// !Forward Declarations
class CChan {
class CChan : private CCoreTranslationMixin {
public:
typedef enum {
Voice = '+',
+1 -1
View File
@@ -35,7 +35,7 @@ class CMessage;
class CChan;
// !Forward Declarations
class CAuthBase {
class CAuthBase : private CCoreTranslationMixin {
public:
CAuthBase(const CString& sUsername, const CString& sPassword,
CZNCSock* pSock)
+1 -1
View File
@@ -37,7 +37,7 @@ class CIRCNetworkPingTimer;
class CIRCNetworkJoinTimer;
class CMessage;
class CIRCNetwork {
class CIRCNetwork : private CCoreTranslationMixin {
public:
static bool IsValidNetwork(const CString& sNetwork);
+2 -2
View File
@@ -335,7 +335,7 @@ CModule* TModLoad(ModHandle p, CUser* pUser, CIRCNetwork* pNetwork,
}
/** A helper class for handling commands in modules. */
class CModCommand {
class CModCommand : private CCoreTranslationMixin {
public:
/// Type for the callback function that handles the actual command.
typedef void (CModule::*ModCmdFunc)(const CString& sLine);
@@ -1386,7 +1386,7 @@ class CModule {
std::map<CString, CModCommand> m_mCommands;
};
class CModules : public std::vector<CModule*> {
class CModules : public std::vector<CModule*>, private CCoreTranslationMixin {
public:
CModules();
~CModules();
+3 -2
View File
@@ -24,7 +24,7 @@
class CModule;
class CZNCSock : public Csock, public CCoreTranslationMixin {
class CZNCSock : public Csock, protected CCoreTranslationMixin {
public:
CZNCSock(int timeout = 60);
CZNCSock(const CString& sHost, u_short port, int timeout = 60);
@@ -72,7 +72,8 @@ class CZNCSock : public Csock, public CCoreTranslationMixin {
enum EAddrType { ADDR_IPV4ONLY, ADDR_IPV6ONLY, ADDR_ALL };
class CSockManager : public TSocketManager<CZNCSock> {
class CSockManager : public TSocketManager<CZNCSock>,
private CCoreTranslationMixin {
public:
CSockManager();
virtual ~CSockManager();
+2 -1
View File
@@ -21,6 +21,7 @@
#include <znc/Utils.h>
#include <znc/Buffer.h>
#include <znc/Nick.h>
#include <znc/Translation.h>
#include <set>
#include <vector>
@@ -34,7 +35,7 @@ class CIRCSock;
class CUserTimer;
class CServer;
class CUser {
class CUser : private CCoreTranslationMixin {
public:
CUser(const CString& sUserName);
~CUser();
+7
View File
@@ -697,4 +697,11 @@ class CInlineFormatMessage {
CString m_sFormat;
};
// For gtest
#ifdef GTEST_FAIL
inline void PrintTo(const CString& s, std::ostream* os) {
*os << '"' << s.Escape_n(CString::EDEBUG) << '"';
}
#endif
#endif // !ZNCSTRING_H
+3 -1
View File
@@ -35,7 +35,7 @@ class CConfigWriteTimer;
class CConfig;
class CFile;
class CZNC {
class CZNC : private CCoreTranslationMixin {
public:
CZNC();
~CZNC();
@@ -253,6 +253,8 @@ class CZNC {
static void DumpConfig(const CConfig* Config);
private:
static CString FormatBindError();
CFile* InitPidFile();
bool ReadConfig(CConfig& config, CString& sError);
+3 -2
View File
@@ -676,8 +676,9 @@ def make_inherit(cl, parent, attr):
for x in parent.__dict__:
if not x.startswith('_') and x not in cl.__dict__:
setattr(cl, x, make_caller(parent, x, attr))
if '_s' in parent.__dict__:
parent = parent._s
if parent.__bases__:
# Multiple inheritance is not supported (yet?)
parent = parent.__bases__[0]
else:
break
+2 -2
View File
@@ -16,7 +16,7 @@ msgstr ""
#: block_motd.cpp:26
msgid "[<server>]"
msgstr ""
msgstr "[<server>]"
#: block_motd.cpp:27
msgid ""
@@ -30,7 +30,7 @@ msgstr ""
#: block_motd.cpp:58
msgid "MOTD blocked by ZNC"
msgstr ""
msgstr "MOTD блокирован ZNC"
#: block_motd.cpp:104
msgid "Block the MOTD from IRC so it's not sent to your client(s)."
+34 -33
View File
@@ -16,149 +16,150 @@ msgstr ""
#: dcc.cpp:88
msgid "<nick> <file>"
msgstr ""
msgstr "<nick> <file>"
#: dcc.cpp:89
msgid "Send a file from ZNC to someone"
msgstr ""
msgstr "Отправить файл из ZNC кому-либо"
#: dcc.cpp:91
msgid "<file>"
msgstr ""
msgstr "<file>"
#: dcc.cpp:92
msgid "Send a file from ZNC to your client"
msgstr ""
msgstr "Отправить файл из ZNC на ваш клиент"
#: dcc.cpp:94
msgid "List current transfers"
msgstr ""
msgstr "Список текущих передач"
#: dcc.cpp:103
msgid "You must be admin to use the DCC module"
msgstr ""
msgstr "Вы должны быть администратором для использования модуля DCC"
#: dcc.cpp:140
msgid "Attempting to send [{1}] to [{2}]."
msgstr ""
msgstr "Попытка отправить [{1}] [{2}]."
#: dcc.cpp:149 dcc.cpp:554
msgid "Receiving [{1}] from [{2}]: File already exists."
msgstr ""
msgstr "Получение [{1}] с [{2}]: файл уже существует."
#: dcc.cpp:167
msgid ""
"Attempting to connect to [{1} {2}] in order to download [{3}] from [{4}]."
msgstr ""
msgstr "Попытка подключиться к [{1} {2}], чтобы загрузить [{3}] с [{4}]."
#: dcc.cpp:179
msgid "Usage: Send <nick> <file>"
msgstr ""
msgstr "Использование: Send <nick> <file>"
#: dcc.cpp:186 dcc.cpp:206
msgid "Illegal path."
msgstr ""
msgstr "Некорректные пути."
#: dcc.cpp:199
msgid "Usage: Get <file>"
msgstr ""
msgstr "Использование: Get <file>"
#: dcc.cpp:215 dcc.cpp:232 dcc.cpp:234
msgctxt "list"
msgid "Type"
msgstr ""
msgstr "Тип"
#: dcc.cpp:216 dcc.cpp:238 dcc.cpp:241
msgctxt "list"
msgid "State"
msgstr ""
msgstr "Состояние"
#: dcc.cpp:217 dcc.cpp:243
msgctxt "list"
msgid "Speed"
msgstr ""
msgstr "Скорость"
#: dcc.cpp:218 dcc.cpp:227
msgctxt "list"
msgid "Nick"
msgstr ""
msgstr "Ник"
#: dcc.cpp:219 dcc.cpp:228
msgctxt "list"
msgid "IP"
msgstr ""
msgstr "IP"
#: dcc.cpp:220 dcc.cpp:229
msgctxt "list"
msgid "File"
msgstr ""
msgstr "Файл"
#: dcc.cpp:232
msgctxt "list-type"
msgid "Sending"
msgstr ""
msgstr "Отправка"
#: dcc.cpp:234
msgctxt "list-type"
msgid "Getting"
msgstr ""
msgstr "Получение"
#: dcc.cpp:239
msgctxt "list-state"
msgid "Waiting"
msgstr ""
msgstr "Ожидание"
#: dcc.cpp:244
msgid "{1} KiB/s"
msgstr ""
msgstr "{1} Кб/сек"
#: dcc.cpp:250
msgid "You have no active DCC transfers."
msgstr ""
msgstr "У вас нет активных передач DCC."
#: dcc.cpp:267
msgid "Attempting to resume send from position {1} of file [{2}] for [{3}]"
msgstr ""
msgstr "Попытка возобновить отправку от позиции {1} файла [{2}] на [{3}]"
#: dcc.cpp:277
msgid "Couldn't resume file [{1}] for [{2}]: not sending anything."
msgstr ""
"Не удалось возобновить отправку файла [{1}] [{2}]: не отправлено ничего."
#: dcc.cpp:286
msgid "Bad DCC file: {1}"
msgstr ""
msgstr "Плохой файл DCC: {1}"
#: dcc.cpp:341
msgid "Sending [{1}] to [{2}]: File not open!"
msgstr ""
msgstr "Отправка [{1}] [{2}]: файл не открыт!"
#: dcc.cpp:345
msgid "Receiving [{1}] from [{2}]: File not open!"
msgstr ""
msgstr "Получение [{1}] с [{2}]: файл не открыт!"
#: dcc.cpp:385
msgid "Sending [{1}] to [{2}]: Connection refused."
msgstr ""
msgstr "Отправка [{1}] [{2}]: Отказанное соединение."
#: dcc.cpp:389
msgid "Receiving [{1}] from [{2}]: Connection refused."
msgstr ""
msgstr "Получение [{1}] с [{2}]: Отказанное соединение."
#: dcc.cpp:397
msgid "Sending [{1}] to [{2}]: Timeout."
msgstr ""
msgstr "Отправка [{1}] с [{2}]: время ожидания истекло."
#: dcc.cpp:401
msgid "Receiving [{1}] from [{2}]: Timeout."
msgstr ""
msgstr "Получение[{1}] с [{2}]: время ожидания истекло."
#: dcc.cpp:411
msgid "Sending [{1}] to [{2}]: Socket error {3}: {4}"
msgstr ""
msgstr "Отправка [{1}] [{2}]: ошибка сокета {3}: {4}"
#: dcc.cpp:415
msgid "Receiving [{1}] from [{2}]: Socket error {3}: {4}"
msgstr ""
msgstr "Получение [{1}] с [{2}]: ошибка сокета {3}: {4}"
#: dcc.cpp:423
msgid "Sending [{1}] to [{2}]: Transfer started."
+1 -1
View File
@@ -16,7 +16,7 @@ msgstr ""
#: kickrejoin.cpp:56
msgid "<secs>"
msgstr ""
msgstr "<secs>"
#: kickrejoin.cpp:56
msgid "Set the rejoin delay"
+23 -23
View File
@@ -17,99 +17,99 @@ msgstr ""
#: modules/po/../data/listsockets/tmpl/index.tmpl:7 listsockets.cpp:214
#: listsockets.cpp:230
msgid "Name"
msgstr ""
msgstr "Имя"
#: modules/po/../data/listsockets/tmpl/index.tmpl:8 listsockets.cpp:215
#: listsockets.cpp:231
msgid "Created"
msgstr ""
msgstr "Создан"
#: modules/po/../data/listsockets/tmpl/index.tmpl:9 listsockets.cpp:216
#: listsockets.cpp:232
msgid "State"
msgstr ""
msgstr "Состояние"
#: modules/po/../data/listsockets/tmpl/index.tmpl:10 listsockets.cpp:218
#: listsockets.cpp:235
msgid "SSL"
msgstr ""
msgstr "SSL"
#: modules/po/../data/listsockets/tmpl/index.tmpl:11 listsockets.cpp:220
#: listsockets.cpp:240
msgid "Local"
msgstr ""
msgstr "Локальное"
#: modules/po/../data/listsockets/tmpl/index.tmpl:12 listsockets.cpp:221
#: listsockets.cpp:242
msgid "Remote"
msgstr ""
msgstr "Удаленное"
#: modules/po/../data/listsockets/tmpl/index.tmpl:13
msgid "Data In"
msgstr ""
msgstr "Входящий трафик"
#: modules/po/../data/listsockets/tmpl/index.tmpl:14
msgid "Data Out"
msgstr ""
msgstr "Исходящий трафик"
#: listsockets.cpp:62
msgid "[-n]"
msgstr ""
msgstr "[-n]"
#: listsockets.cpp:62
msgid "Shows the list of active sockets. Pass -n to show IP addresses"
msgstr ""
msgstr "Показать список активных сокетов. Укажите -n для показа IP-адресов"
#: listsockets.cpp:70
msgid "You must be admin to use this module"
msgstr ""
msgstr "Вы должны быть администратором для использования этого модуля"
#: listsockets.cpp:96
msgid "List sockets"
msgstr ""
msgstr "Список сокетов"
#: listsockets.cpp:116 listsockets.cpp:236
msgctxt "ssl"
msgid "Yes"
msgstr ""
msgstr "Да"
#: listsockets.cpp:116 listsockets.cpp:237
msgctxt "ssl"
msgid "No"
msgstr ""
msgstr "Нет"
#: listsockets.cpp:142
msgid "Listener"
msgstr ""
msgstr "Слушатель"
#: listsockets.cpp:144
msgid "Inbound"
msgstr ""
msgstr "Входящие"
#: listsockets.cpp:147
msgid "Outbound"
msgstr ""
msgstr "Исходящие"
#: listsockets.cpp:149
msgid "Connecting"
msgstr ""
msgstr "Подключение…"
#: listsockets.cpp:152
msgid "UNKNOWN"
msgstr ""
msgstr "НЕИЗВЕСТНО"
#: listsockets.cpp:207
msgid "You have no open sockets."
msgstr ""
msgstr "У вас нет открытых сокетов."
#: listsockets.cpp:222 listsockets.cpp:244
msgid "In"
msgstr ""
msgstr "Входящие данные"
#: listsockets.cpp:223 listsockets.cpp:246
msgid "Out"
msgstr ""
msgstr "Исходящие данные"
#: listsockets.cpp:262
msgid "Lists active sockets"
msgstr ""
msgstr "Список активных сокетов"
+24 -23
View File
@@ -16,96 +16,97 @@ msgstr ""
#: modules/po/../data/send_raw/tmpl/index.tmpl:9
msgid "Send a raw IRC line"
msgstr ""
msgstr "Отправить сырую строку IRC"
#: modules/po/../data/send_raw/tmpl/index.tmpl:14
msgid "User:"
msgstr ""
msgstr "Пользователь:"
#: modules/po/../data/send_raw/tmpl/index.tmpl:15
msgid "To change user, click to Network selector"
msgstr ""
msgstr "Чтобы изменить пользователя, щелкните на селектор сети"
#: modules/po/../data/send_raw/tmpl/index.tmpl:19
msgid "User/Network:"
msgstr ""
msgstr "Пользователь/сеть:"
#: modules/po/../data/send_raw/tmpl/index.tmpl:32
msgid "Send to:"
msgstr ""
msgstr "Отправить:"
#: modules/po/../data/send_raw/tmpl/index.tmpl:34
msgid "Client"
msgstr ""
msgstr "Клиент"
#: modules/po/../data/send_raw/tmpl/index.tmpl:35
msgid "Server"
msgstr ""
msgstr "Сервер"
#: modules/po/../data/send_raw/tmpl/index.tmpl:40
msgid "Line:"
msgstr ""
msgstr "Строка:"
#: modules/po/../data/send_raw/tmpl/index.tmpl:45
msgid "Send"
msgstr ""
msgstr "Отправить"
#: send_raw.cpp:32
msgid "Sent [{1}] to {2}/{3}"
msgstr ""
msgstr "Отправил [{1}] {2}/{3}"
#: send_raw.cpp:36 send_raw.cpp:56
msgid "Network {1} not found for user {2}"
msgstr ""
msgstr "Сеть {1} не найдена для пользователя {2}"
#: send_raw.cpp:40 send_raw.cpp:60
msgid "User {1} not found"
msgstr ""
msgstr "Пользователь {1} не найден"
#: send_raw.cpp:52
msgid "Sent [{1}] to IRC server of {2}/{3}"
msgstr ""
msgstr "Послал [{1}] к IRC серверу {2}/{3}"
#: send_raw.cpp:75
msgid "You must have admin privileges to load this module"
msgstr ""
msgstr "Вы должны иметь привилегии администратора для загрузки этого модуля"
#: send_raw.cpp:82
msgid "Send Raw"
msgstr ""
msgstr "Отправить сырым"
#: send_raw.cpp:92
msgid "User not found"
msgstr ""
msgstr "Пользователь не найден"
#: send_raw.cpp:99
msgid "Network not found"
msgstr ""
msgstr "Сеть не найдена"
#: send_raw.cpp:116
msgid "Line sent"
msgstr ""
msgstr "Строка отправлена"
#: send_raw.cpp:140 send_raw.cpp:143
msgid "[user] [network] [data to send]"
msgstr ""
msgstr "[user] [network] [данные для отправки]"
#: send_raw.cpp:141
msgid "The data will be sent to the user's IRC client(s)"
msgstr ""
msgstr "Данные будут отправлены IRC-клиент(ам) этого пользователя"
#: send_raw.cpp:144
msgid "The data will be sent to the IRC server the user is connected to"
msgstr ""
"Данные будут передаваться на IRC-сервер, если пользователь подключен к нему"
#: send_raw.cpp:147
msgid "[data to send]"
msgstr ""
msgstr "[данные для отправки]"
#: send_raw.cpp:148
msgid "The data will be sent to your current client"
msgstr ""
msgstr "Данные будут отправлены на ваш текущий клиент"
#: send_raw.cpp:159
msgid "Lets you send some raw IRC lines as/to someone else"
msgstr ""
msgstr "Позволяет отправлять некоторые сырые строки IRC кому-либо"
+4 -3
View File
@@ -16,16 +16,17 @@ msgstr ""
#: shell.cpp:37
msgid "Failed to execute: {1}"
msgstr ""
msgstr "Не удалось выполнить: {1}"
#: shell.cpp:75
msgid "You must be admin to use the shell module"
msgstr ""
msgstr "Вы должны быть администратором для использования модуля shell"
#: shell.cpp:169
msgid "Gives shell access"
msgstr ""
msgstr "Дает доступ к оболочке"
#: shell.cpp:172
msgid "Gives shell access. Only ZNC admins can use it."
msgstr ""
"Дает доступ к оболочке. Только администраторы ZNC могут использовать это."
+8 -8
View File
@@ -232,7 +232,7 @@ msgstr "Порт"
#: modules/po/../data/webadmin/tmpl/add_edit_network.tmpl:103
#: modules/po/../data/webadmin/tmpl/settings.tmpl:15
msgid "SSL"
msgstr ""
msgstr "SSL"
#: modules/po/../data/webadmin/tmpl/add_edit_network.tmpl:104
msgid "Password"
@@ -658,7 +658,7 @@ msgstr ""
#: modules/po/../data/webadmin/tmpl/add_edit_user.tmpl:322
msgid "Timeout before reconnect:"
msgstr ""
msgstr "Время ожидания до повторного подключения:"
#: modules/po/../data/webadmin/tmpl/add_edit_user.tmpl:324
msgid ""
@@ -837,19 +837,19 @@ msgstr "Хост"
#: modules/po/../data/webadmin/tmpl/settings.tmpl:16
msgid "IPv4"
msgstr ""
msgstr "IPv4"
#: modules/po/../data/webadmin/tmpl/settings.tmpl:17
msgid "IPv6"
msgstr ""
msgstr "IPv6"
#: modules/po/../data/webadmin/tmpl/settings.tmpl:18
msgid "IRC"
msgstr ""
msgstr "IRC"
#: modules/po/../data/webadmin/tmpl/settings.tmpl:19
msgid "HTTP"
msgstr ""
msgstr "HTTP"
#: modules/po/../data/webadmin/tmpl/settings.tmpl:20
msgid "URIPrefix"
@@ -941,7 +941,7 @@ msgstr ""
#: modules/po/../data/webadmin/tmpl/settings.tmpl:158
msgid "MOTD:"
msgstr ""
msgstr "MOTD:"
#: modules/po/../data/webadmin/tmpl/settings.tmpl:162
msgid "“Message of the Day”, sent to all ZNC users on connect."
@@ -1054,7 +1054,7 @@ msgstr "Ошибка: пароли не совпадают"
#: webadmin.cpp:323
msgid "Timeout can't be less than 30 seconds!"
msgstr ""
msgstr "Время ожидания не может быть меньше 30 секунд!"
#: webadmin.cpp:407 webadmin.cpp:435 webadmin.cpp:1189 webadmin.cpp:2064
msgid "Unable to load module [{1}]: {2}"
+2 -2
View File
@@ -635,7 +635,7 @@ void CChan::SendBuffer(CClient* pClient, const CBuffer& Buffer) {
if (!bSkipStatusMsg) {
m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + GetName() +
" :Buffer Playback...",
" :" + t_s("Buffer Playback..."),
pUseClient);
}
@@ -673,7 +673,7 @@ void CChan::SendBuffer(CClient* pClient, const CBuffer& Buffer) {
&bSkipStatusMsg);
if (!bSkipStatusMsg) {
m_pNetwork->PutUser(":***!znc@znc.in PRIVMSG " + GetName() +
" :Playback Complete.",
" :" + t_s("Playback Complete."),
pUseClient);
}
+42 -39
View File
@@ -72,7 +72,7 @@ using std::vector;
} \
} \
} else { \
PutStatus("No such module [" + MOD + "]"); \
PutStatus(t_f("No such module {1}")(MOD)); \
} \
}
@@ -361,9 +361,9 @@ void CAuthBase::RefuseLogin(const CString& sReason) {
// login. Use sReason because there are other reasons than "wrong
// password" for a login to be rejected (e.g. fail2ban).
if (pUser) {
pUser->PutStatusNotice("A client from [" + GetRemoteIP() + "] attempted "
"to login as you, but was rejected [" +
sReason + "].");
pUser->PutStatusNotice(t_f(
"A client from {1} attempted to login as you, but was rejected: "
"{2}")(GetRemoteIP(), sReason));
}
GLOBALMODULECALL(OnFailedLogin(GetUsername(), GetRemoteIP()), NOTHING);
@@ -397,7 +397,7 @@ void CClient::AcceptLogin(CUser& User) {
if (!m_sNetwork.empty()) {
m_pNetwork = m_pUser->FindNetwork(m_sNetwork);
if (!m_pNetwork) {
PutStatus("Network (" + m_sNetwork + ") doesn't exist.");
PutStatus(t_f("Network {1} doesn't exist.")(m_sNetwork));
}
} else if (!m_pUser->GetNetworks().empty()) {
// If a user didn't supply a network, and they have a network called
@@ -411,21 +411,20 @@ void CClient::AcceptLogin(CUser& User) {
if (!m_pNetwork) m_pNetwork = *m_pUser->GetNetworks().begin();
if (m_pNetwork && m_pUser->GetNetworks().size() > 1) {
PutStatusNotice(
"You have several networks configured, but no network was "
"specified for the connection.");
PutStatusNotice("Selecting network [" + m_pNetwork->GetName() +
"]. To see list of all configured networks, use "
"/znc ListNetworks");
t_s("You have several networks configured, but no network was "
"specified for the connection."));
PutStatusNotice(
t_f("Selecting network {1}. To see list of all configured "
"networks, use /znc ListNetworks")(m_pNetwork->GetName()));
PutStatusNotice(t_f(
"If you want to choose another network, use /znc JumpNetwork "
"<network>, or connect to ZNC with username " +
m_pUser->GetUserName() + "/<network> (instead of just " +
m_pUser->GetUserName() + ")");
"<network>, or connect to ZNC with username {1}/<network> "
"(instead of just {1})")(m_pUser->GetUserName()));
}
} else {
PutStatusNotice(
"You have no networks configured. Use /znc AddNetwork <network> to "
"add one.");
t_s("You have no networks configured. Use /znc AddNetwork "
"<network> to add one."));
}
SetNetwork(m_pNetwork, false);
@@ -435,7 +434,7 @@ void CClient::AcceptLogin(CUser& User) {
NETWORKMODULECALL(OnClientLogin(), m_pUser, m_pNetwork, this, NOTHING);
}
void CClient::Timeout() { PutClient("ERROR :Closing link [Timeout]"); }
void CClient::Timeout() { PutClient("ERROR :" + t_s("Closing link: Timeout")); }
void CClient::Connected() { DEBUG(GetSockName() << " == Connected();"); }
@@ -457,15 +456,15 @@ void CClient::Disconnected() {
void CClient::ReachedMaxBuffer() {
DEBUG(GetSockName() << " == ReachedMaxBuffer()");
if (IsAttached()) {
PutClient("ERROR :Closing link [Too long raw line]");
PutClient("ERROR :" + t_s("Closing link: Too long raw line"));
}
Close();
}
void CClient::BouncedOff() {
PutStatusNotice(
"You are being disconnected because another user just authenticated as "
"you.");
t_s("You are being disconnected because another user just "
"authenticated as you."));
Close(Csock::CLT_AFTERWRITE);
}
@@ -1018,9 +1017,9 @@ bool CClient::OnCTCPMessage(CCTCPMessage& Message) {
if (!GetIRCSock()) {
// Some lagmeters do a NOTICE to their own nick, ignore those.
if (!sTarget.Equals(m_sNick))
PutStatus("Your CTCP to [" + Message.GetTarget() +
"] got lost, "
"you are not connected to IRC!");
PutStatus(t_f(
"Your CTCP to {1} got lost, you are not connected to IRC!")(
Message.GetTarget()));
continue;
}
@@ -1145,9 +1144,9 @@ bool CClient::OnNoticeMessage(CNoticeMessage& Message) {
if (!GetIRCSock()) {
// Some lagmeters do a NOTICE to their own nick, ignore those.
if (!sTarget.Equals(m_sNick))
PutStatus("Your notice to [" + Message.GetTarget() +
"] got lost, "
"you are not connected to IRC!");
PutStatus(
t_f("Your notice to {1} got lost, you are not connected to "
"IRC!")(Message.GetTarget()));
continue;
}
@@ -1185,7 +1184,7 @@ bool CClient::OnPartMessage(CPartMessage& Message) {
CChan* pChan = m_pNetwork ? m_pNetwork->FindChan(sChan) : nullptr;
if (pChan && !pChan->IsOn()) {
PutStatusNotice("Removing channel [" + sChan + "]");
PutStatusNotice(t_f("Removing channel {1}")(sChan));
m_pNetwork->DelChan(sChan);
} else {
sChans += (sChans.empty()) ? sChan : CString("," + sChan);
@@ -1261,9 +1260,9 @@ bool CClient::OnTextMessage(CTextMessage& Message) {
if (!GetIRCSock()) {
// Some lagmeters do a PRIVMSG to their own nick, ignore those.
if (!sTarget.Equals(m_sNick))
PutStatus("Your message to [" + Message.GetTarget() +
"] got lost, "
"you are not connected to IRC!");
PutStatus(
t_f("Your message to {1} got lost, you are not connected "
"to IRC!")(Message.GetTarget()));
continue;
}
@@ -1315,13 +1314,13 @@ bool CClient::OnOtherMessage(CMessage& Message) {
if (sTarget.Equals("status")) {
if (sModCommand.empty())
PutStatus("Hello. How may I help you?");
PutStatus(t_s("Hello. How may I help you?"));
else
UserCommand(sModCommand);
} else {
if (sModCommand.empty())
CALLMOD(sTarget, this, m_pUser, m_pNetwork,
PutModule("Hello. How may I help you?"))
PutModule(t_s("Hello. How may I help you?")))
else
CALLMOD(sTarget, this, m_pUser, m_pNetwork,
OnModCommand(sModCommand))
@@ -1335,16 +1334,18 @@ bool CClient::OnOtherMessage(CMessage& Message) {
CString sPatterns = Message.GetParams(0);
if (sPatterns.empty()) {
PutStatusNotice("Usage: /attach <#chans>");
PutStatusNotice(t_s("Usage: /attach <#chans>"));
return true;
}
set<CChan*> sChans = MatchChans(sPatterns);
unsigned int uAttachedChans = AttachChans(sChans);
PutStatusNotice("There were [" + CString(sChans.size()) +
"] channels matching [" + sPatterns + "]");
PutStatusNotice("Attached [" + CString(uAttachedChans) + "] channels");
PutStatusNotice(t_p("There was {1} channel matching [{2}]",
"There were {1} channels matching [{2}]",
sChans.size())(sChans.size(), sPatterns));
PutStatusNotice(t_p("Attached {1} channel", "Attached {1} channels",
uAttachedChans)(uAttachedChans));
return true;
} else if (sCommand.Equals("DETACH")) {
@@ -1355,16 +1356,18 @@ bool CClient::OnOtherMessage(CMessage& Message) {
CString sPatterns = Message.GetParams(0);
if (sPatterns.empty()) {
PutStatusNotice("Usage: /detach <#chans>");
PutStatusNotice(t_s("Usage: /detach <#chans>"));
return true;
}
set<CChan*> sChans = MatchChans(sPatterns);
unsigned int uDetached = DetachChans(sChans);
PutStatusNotice("There were [" + CString(sChans.size()) +
"] channels matching [" + sPatterns + "]");
PutStatusNotice("Detached [" + CString(uDetached) + "] channels");
PutStatusNotice(t_p("There was {1} channel matching [{2}]",
"There were {1} channels matching [{2}]",
sChans.size())(sChans.size(), sPatterns));
PutStatusNotice(t_p("Detached {1} channel", "Detached {1} channels",
uDetached)(uDetached));
return true;
} else if (sCommand.Equals("PROTOCTL")) {
+605 -534
View File
File diff suppressed because it is too large Load Diff
+19 -14
View File
@@ -233,7 +233,8 @@ void CIRCNetwork::Clone(const CIRCNetwork& Network, bool bCloneName) {
if (pSock) {
PutStatus(
"Jumping servers because this server is no longer in the list");
t_s("Jumping servers because this server is no longer in the "
"list"));
pSock->Quit();
}
}
@@ -468,7 +469,9 @@ bool CIRCNetwork::ParseConfig(CConfig* pConfig, CString& sError,
}
if (!bFound) {
sNotice =
"Loading network module [simple_away] instead";
"NOTICE: awaynick was retired, loading network "
"module [simple_away] instead; if you still need "
"awaynick, install it as an external module";
sModName = "simple_away";
// not a fatal error if simple_away is not available
LoadModule(sModName, sArgs, sNotice, sModRet);
@@ -635,7 +638,7 @@ void CIRCNetwork::ClientConnected(CClient* pClient) {
if (m_RawBuffer.IsEmpty()) {
pClient->PutClient(":irc.znc.in 001 " + pClient->GetNick() +
" :- Welcome to ZNC -");
" :" + t_s("Welcome to ZNC"));
} else {
const CString& sClientNick = pClient->GetNick(false);
MCString msParams;
@@ -723,12 +726,13 @@ void CIRCNetwork::ClientConnected(CClient* pClient) {
// Tell them why they won't connect
if (!GetIRCConnectEnabled())
pClient->PutStatus(
"You are currently disconnected from IRC. "
"Use 'connect' to reconnect.");
t_s("You are currently disconnected from IRC. Use 'connect' to "
"reconnect."));
if (CDebug::Debug()) {
pClient->PutStatus("ZNC is presently running in DEBUG mode. Sensitive"
" data during your current session may be exposed to the host.");
pClient->PutStatus(
t_s("ZNC is presently running in DEBUG mode. Sensitive data during "
"your current session may be exposed to the host."));
}
}
@@ -758,7 +762,7 @@ std::vector<CClient*> CIRCNetwork::FindClients(
void CIRCNetwork::SetUser(CUser* pUser) {
for (CClient* pClient : m_vClients) {
pClient->PutStatus(
"This network is being deleted or moved to another user.");
t_s("This network is being deleted or moved to another user."));
pClient->SetNetwork(nullptr);
}
@@ -987,8 +991,8 @@ bool CIRCNetwork::JoinChan(CChan* pChan) {
if (m_pUser->JoinTries() != 0 &&
pChan->GetJoinTries() >= m_pUser->JoinTries()) {
PutStatus("The channel " + pChan->GetName() +
" could not be joined, disabling it.");
PutStatus(t_f("The channel {1} could not be joined, disabling it.")(
pChan->GetName()));
pChan->Disable();
} else {
pChan->IncJoinTries();
@@ -1116,7 +1120,7 @@ bool CIRCNetwork::DelServer(const CString& sName, unsigned short uPort,
if (pIRCSock) {
pIRCSock->Quit();
PutStatus("Your current server was removed, jumping...");
PutStatus(t_s("Your current server was removed, jumping..."));
}
} else if (!bSawCurrentServer) {
// Our current server comes after the server which we
@@ -1278,8 +1282,9 @@ bool CIRCNetwork::Connect() {
bool bSSL = pServer->IsSSL();
#ifndef HAVE_LIBSSL
if (bSSL) {
PutStatus("Cannot connect to [" + pServer->GetString(false) +
"], ZNC is not compiled with SSL.");
PutStatus(
t_f("Cannot connect to {1}, because ZNC is not compiled with SSL "
"support.")(pServer->GetString(false)));
CZNC::Get().AddNetworkToQueue(this);
return false;
}
@@ -1299,7 +1304,7 @@ bool CIRCNetwork::Connect() {
&bAbort);
if (bAbort) {
DEBUG("Some module aborted the connection attempt");
PutStatus("Some module aborted the connection attempt");
PutStatus(t_s("Some module aborted the connection attempt"));
delete pIRCSock;
CZNC::Get().AddNetworkToQueue(this);
return false;
+25 -25
View File
@@ -481,7 +481,7 @@ bool CIRCSock::OnCTCPMessage(CCTCPMessage& Message) {
bool CIRCSock::OnErrorMessage(CMessage& Message) {
// ERROR :Closing Link: nick[24.24.24.24] (Excess Flood)
CString sError = Message.GetParam(0);
m_pNetwork->PutStatus("Error from Server [" + sError + "]");
m_pNetwork->PutStatus(t_f("Error from server: {1}")(sError));
return true;
}
@@ -682,8 +682,8 @@ bool CIRCSock::OnNumericMessage(CNumericMessage& Message) {
if (m_bAuthed && sServer == "irc.znc.in") {
// m_bAuthed == true => we already received another 001 => we
// might be in a traffic loop
m_pNetwork->PutStatus(
"ZNC seems to be connected to itself, disconnecting...");
m_pNetwork->PutStatus(t_s(
"ZNC seems to be connected to itself, disconnecting..."));
Quit();
return true;
}
@@ -730,11 +730,11 @@ bool CIRCSock::OnNumericMessage(CNumericMessage& Message) {
CString sPort = Message.GetParam(2);
CString sInfo = Message.GetParam(3);
m_pNetwork->PutStatus(
"Server [" + m_pNetwork->GetCurrentServer()->GetString(false) +
"] redirects us to [" + sHost + ":" + sPort +
"] with reason [" + sInfo + "]");
t_f("Server {1} redirects us to {2}:{3} with reason: {3}")(
m_pNetwork->GetCurrentServer()->GetString(false), sHost,
sPort, sInfo));
m_pNetwork->PutStatus(
"Perhaps you want to add it as a new server.");
t_s("Perhaps you want to add it as a new server."));
// Don't send server redirects to the client
return true;
}
@@ -963,9 +963,9 @@ bool CIRCSock::OnNumericMessage(CNumericMessage& Message) {
}
if (pChan) {
pChan->Disable();
m_pNetwork->PutStatus("Channel [" + pChan->GetName() +
"] is linked to "
"another channel and was thus disabled.");
m_pNetwork->PutStatus(
t_f("Channel {1} is linked to another channel and was thus "
"disabled.")(pChan->GetName()));
}
break;
}
@@ -976,7 +976,7 @@ bool CIRCSock::OnNumericMessage(CNumericMessage& Message) {
// TLS
if (!GetSSL()) {
StartTLS();
m_pNetwork->PutStatus("Switched to SSL (STARTTLS)");
m_pNetwork->PutStatus(t_s("Switched to SSL (STARTTLS)"));
}
return true;
@@ -1029,7 +1029,7 @@ bool CIRCSock::OnQuitMessage(CQuitMessage& Message) {
bool bIsVisible = false;
if (Nick.NickEquals(GetNick())) {
m_pNetwork->PutStatus("You quit [" + Message.GetReason() + "]");
m_pNetwork->PutStatus(t_f("You quit: {1}")(Message.GetReason()));
// We don't call module hooks and we don't
// forward this quit to clients (Some clients
// disconnect if they receive such a QUIT)
@@ -1235,7 +1235,7 @@ void CIRCSock::Disconnected() {
if (!m_pNetwork->GetUser()->IsBeingDeleted() &&
m_pNetwork->GetIRCConnectEnabled() &&
m_pNetwork->GetServers().size() != 0) {
m_pNetwork->PutStatus("Disconnected from IRC. Reconnecting...");
m_pNetwork->PutStatus(t_s("Disconnected from IRC. Reconnecting..."));
}
m_pNetwork->ClearRawBuffer();
m_pNetwork->ClearMotdBuffer();
@@ -1265,11 +1265,11 @@ void CIRCSock::SockError(int iErrno, const CString& sDescription) {
DEBUG(GetSockName() << " == SockError(" << iErrno << " " << sError << ")");
if (!m_pNetwork->GetUser()->IsBeingDeleted()) {
if (GetConState() != CST_OK) {
m_pNetwork->PutStatus("Cannot connect to IRC (" + sError +
"). Retrying...");
m_pNetwork->PutStatus(
t_f("Cannot connect to IRC ({1}). Retrying...")(sError));
} else {
m_pNetwork->PutStatus("Disconnected from IRC (" + sError +
"). Reconnecting...");
m_pNetwork->PutStatus(
t_f("Disconnected from IRC ({1}). Reconnecting...")(sError));
}
#ifdef HAVE_LIBSSL
if (iErrno == errnoBadSSLCert) {
@@ -1299,9 +1299,8 @@ void CIRCSock::SockError(int iErrno, const CString& sDescription) {
CString sSHA256 = GetSSLPeerFingerprint();
m_pNetwork->PutStatus("SHA-256: " + sSHA256);
m_pNetwork->PutStatus(
"If you trust this certificate, do /znc "
"AddTrustedServerFingerprint " +
sSHA256);
t_f("If you trust this certificate, do /znc "
"AddTrustedServerFingerprint {1}")(sSHA256));
}
}
#endif
@@ -1316,7 +1315,8 @@ void CIRCSock::SockError(int iErrno, const CString& sDescription) {
void CIRCSock::Timeout() {
DEBUG(GetSockName() << " == Timeout()");
if (!m_pNetwork->GetUser()->IsBeingDeleted()) {
m_pNetwork->PutStatus("IRC connection timed out. Reconnecting...");
m_pNetwork->PutStatus(
t_s("IRC connection timed out. Reconnecting..."));
}
m_pNetwork->ClearRawBuffer();
m_pNetwork->ClearMotdBuffer();
@@ -1328,7 +1328,7 @@ void CIRCSock::Timeout() {
void CIRCSock::ConnectionRefused() {
DEBUG(GetSockName() << " == ConnectionRefused()");
if (!m_pNetwork->GetUser()->IsBeingDeleted()) {
m_pNetwork->PutStatus("Connection Refused. Reconnecting...");
m_pNetwork->PutStatus(t_s("Connection Refused. Reconnecting..."));
}
m_pNetwork->ClearRawBuffer();
m_pNetwork->ClearMotdBuffer();
@@ -1336,7 +1336,7 @@ void CIRCSock::ConnectionRefused() {
void CIRCSock::ReachedMaxBuffer() {
DEBUG(GetSockName() << " == ReachedMaxBuffer()");
m_pNetwork->PutStatus("Received a too long line from the IRC server!");
m_pNetwork->PutStatus(t_s("Received a too long line from the IRC server!"));
Quit();
}
@@ -1440,7 +1440,7 @@ void CIRCSock::SendAltNick(const CString& sBadNick) {
} else {
char cLetter = 0;
if (sBadNick.empty()) {
m_pNetwork->PutUser("No free nick available");
m_pNetwork->PutUser(t_s("No free nick available"));
Quit();
return;
}
@@ -1448,7 +1448,7 @@ void CIRCSock::SendAltNick(const CString& sBadNick) {
cLetter = sBadNick.back();
if (cLetter == 'z') {
m_pNetwork->PutUser("No free nick found");
m_pNetwork->PutUser(t_s("No free nick found"));
Quit();
return;
}
+39 -41
View File
@@ -525,8 +525,9 @@ bool CModule::AddCommand(const CString& sCmd, const COptionalTranslation& Args,
}
void CModule::AddHelpCommand() {
AddCommand("Help", &CModule::HandleHelpCommand, "search",
"Generate this output");
AddCommand("Help", t_d("<search>", "modhelpcmd"),
t_d("Generate this output", "modhelpcmd"),
[=](const CString& sLine) { HandleHelpCommand(sLine); });
}
bool CModule::RemCommand(const CString& sCmd) {
@@ -569,7 +570,7 @@ void CModule::HandleHelpCommand(const CString& sLine) {
}
}
if (Table.empty()) {
PutModule("No matches for '" + sFilter + "'");
PutModule(t_f("No matches for '{1}'")(sFilter));
} else {
PutModule(Table);
}
@@ -687,9 +688,9 @@ void CModule::OnUnknownModCommand(const CString& sLine) {
// This function is only called if OnModCommand wasn't
// overriden, so no false warnings for modules which don't use
// CModCommand for command handling.
PutModule("This module doesn't implement any commands.");
PutModule(t_s("This module doesn't implement any commands."));
else
PutModule("Unknown command!");
PutModule(t_s("Unknown command!"));
}
void CModule::OnQuit(const CNick& Nick, const CString& sMessage,
@@ -1629,7 +1630,7 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs,
sRetMsg = "";
if (FindModule(sModule) != nullptr) {
sRetMsg = "Module [" + sModule + "] already loaded.";
sRetMsg = t_f("Module {1} already loaded.")(sModule);
return false;
}
@@ -1643,7 +1644,7 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs,
CModInfo Info;
if (!FindModPath(sModule, sModPath, sDataPath)) {
sRetMsg = "Unable to find module [" + sModule + "]";
sRetMsg = t_f("Unable to find module {1}")(sModule);
return false;
}
Info.SetName(sModule);
@@ -1655,20 +1656,20 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs,
if (!Info.SupportsType(eType)) {
dlclose(p);
sRetMsg = "Module [" + sModule + "] does not support module type [" +
CModInfo::ModuleTypeToString(eType) + "].";
sRetMsg = t_f("Module {1} does not support module type {1}.")(
sModule, CModInfo::ModuleTypeToString(eType));
return false;
}
if (!pUser && eType == CModInfo::UserModule) {
dlclose(p);
sRetMsg = "Module [" + sModule + "] requires a user.";
sRetMsg = t_f("Module {1} requires a user.")(sModule);
return false;
}
if (!pNetwork && eType == CModInfo::NetworkModule) {
dlclose(p);
sRetMsg = "Module [" + sModule + "] requires a network.";
sRetMsg = t_f("Module {1} requires a network.")(sModule);
return false;
}
@@ -1684,15 +1685,15 @@ bool CModules::LoadModule(const CString& sModule, const CString& sArgs,
bLoaded = pModule->OnLoad(sArgs, sRetMsg);
} catch (const CModule::EModException&) {
bLoaded = false;
sRetMsg = "Caught an exception";
sRetMsg = t_s("Caught an exception");
}
if (!bLoaded) {
UnloadModule(sModule, sModPath);
if (!sRetMsg.empty())
sRetMsg = "Module [" + sModule + "] aborted: " + sRetMsg;
sRetMsg = t_f("Module {1} aborted: {2}")(sModule, sRetMsg);
else
sRetMsg = "Module [" + sModule + "] aborted.";
sRetMsg = t_f("Module {1} aborted.")(sModule);
return false;
}
@@ -1716,7 +1717,7 @@ bool CModules::UnloadModule(const CString& sModule, CString& sRetMsg) {
sRetMsg = "";
if (!pModule) {
sRetMsg = "Module [" + sMod + "] not loaded.";
sRetMsg = t_f("Module [{1}] not loaded.")(sMod);
return false;
}
@@ -1740,12 +1741,12 @@ bool CModules::UnloadModule(const CString& sModule, CString& sRetMsg) {
}
dlclose(p);
sRetMsg = "Module [" + sMod + "] unloaded";
sRetMsg = t_f("Module {1} unloaded.")(sMod);
return true;
}
sRetMsg = "Unable to unload module [" + sMod + "]";
sRetMsg = t_f("Unable to unload module {1}.")(sMod);
return false;
}
@@ -1758,7 +1759,7 @@ bool CModules::ReloadModule(const CString& sModule, const CString& sArgs,
CModule* pModule = FindModule(sMod);
if (!pModule) {
sRetMsg = "Module [" + sMod + "] not loaded";
sRetMsg = t_f("Module [{1}] not loaded.")(sMod);
return false;
}
@@ -1774,7 +1775,7 @@ bool CModules::ReloadModule(const CString& sModule, const CString& sArgs,
return false;
}
sRetMsg = "Reloaded module [" + sMod + "]";
sRetMsg = t_f("Reloaded module {1}.")(sMod);
return true;
}
@@ -1789,7 +1790,7 @@ bool CModules::GetModInfo(CModInfo& ModInfo, const CString& sModule,
if (bHandled) return bSuccess;
if (!FindModPath(sModule, sModPath, sTmp)) {
sRetMsg = "Unable to find module [" + sModule + "]";
sRetMsg = t_f("Unable to find module {1}.")(sModule);
return false;
}
@@ -1915,9 +1916,8 @@ ModHandle CModules::OpenModule(const CString& sModule, const CString& sModPath,
((sModule[a] < 'a') || (sModule[a] > 'z')) &&
((sModule[a] < 'A') || (sModule[a] > 'Z')) && (sModule[a] != '_')) {
sRetMsg =
"Module names can only contain letters, numbers and "
"underscores, [" +
sModule + "] is invalid.";
t_f("Module names can only contain letters, numbers and "
"underscores, [{1}] is invalid")(sModule);
return nullptr;
}
}
@@ -1940,8 +1940,8 @@ ModHandle CModules::OpenModule(const CString& sModule, const CString& sModPath,
// dlerror() returns pointer to static buffer, which may be overwritten
// very soon with another dl call also it may just return null.
const char* cDlError = dlerror();
CString sDlError = cDlError ? cDlError : "Unknown error";
sRetMsg = "Unable to open module [" + sModule + "] [" + sDlError + "]";
CString sDlError = cDlError ? cDlError : t_s("Unknown error");
sRetMsg = t_f("Unable to open module {1}: {2}")(sModule, sDlError);
return nullptr;
}
@@ -1950,30 +1950,28 @@ ModHandle CModules::OpenModule(const CString& sModule, const CString& sModPath,
*reinterpret_cast<void**>(&fpZNCModuleEntry) = dlsym(p, "ZNCModuleEntry");
if (!fpZNCModuleEntry) {
dlclose(p);
sRetMsg = "Could not find ZNCModuleEntry in module [" + sModule + "]";
sRetMsg = t_f("Could not find ZNCModuleEntry in module {1}")(sModule);
return nullptr;
}
const CModuleEntry* pModuleEntry = fpZNCModuleEntry();
if (std::strcmp(pModuleEntry->pcVersion, VERSION_STR) ||
std::strcmp(pModuleEntry->pcVersionExtra, VERSION_EXTRA)) {
sRetMsg = "Version mismatch for module [" + sModule +
"] (core is " VERSION_STR VERSION_EXTRA
", module is built for " +
CString(pModuleEntry->pcVersion) +
pModuleEntry->pcVersionExtra + "), recompile this module.";
sRetMsg = t_f(
"Version mismatch for module {1}: core is {2}, module is built for "
"{3}. Recompile this module.")(
sModule, VERSION_STR VERSION_EXTRA,
CString(pModuleEntry->pcVersion) + pModuleEntry->pcVersionExtra);
dlclose(p);
return nullptr;
}
if (std::strcmp(pModuleEntry->pcCompileOptions,
ZNC_COMPILE_OPTIONS_STRING)) {
sRetMsg =
"Module [" + sModule +
"] is built incompatibly (core is '" ZNC_COMPILE_OPTIONS_STRING
"', module is '" +
CString(pModuleEntry->pcCompileOptions) +
"'), recompile this module.";
sRetMsg = t_f(
"Module {1} is built incompatibly: core is '{2}', module is '{3}'. "
"Recompile this module.")(sModule, ZNC_COMPILE_OPTIONS_STRING,
pModuleEntry->pcCompileOptions);
dlclose(p);
return nullptr;
}
@@ -2001,14 +1999,14 @@ CModCommand::CModCommand(const CString& sCmd, CmdFunc func,
: m_sCmd(sCmd), m_pFunc(std::move(func)), m_Args(Args), m_Desc(Desc) {}
void CModCommand::InitHelp(CTable& Table) {
Table.AddColumn("Command");
Table.AddColumn("Description");
Table.AddColumn(t_s("Command", "modhelpcmd"));
Table.AddColumn(t_s("Description", "modhelpcmd"));
}
void CModCommand::AddHelp(CTable& Table) const {
Table.AddRow();
Table.SetCell("Command", GetCommand() + " " + GetArgs());
Table.SetCell("Description", GetDescription());
Table.SetCell(t_s("Command", "modhelpcmd"), GetCommand() + " " + GetArgs());
Table.SetCell(t_s("Description", "modhelpcmd"), GetDescription());
}
CString CModule::t_s(const CString& sEnglish, const CString& sContext) const {
+7 -3
View File
@@ -15,6 +15,7 @@
*/
#include <znc/SSLVerifyHost.h>
#include <znc/Translation.h>
#ifdef HAVE_LIBSSL
#if defined(OPENSSL_VERSION_NUMBER) && !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100007
@@ -432,6 +433,9 @@ static HostnameValidationResult validate_hostname(const char* hostname,
bool ZNC_SSLVerifyHost(const CString& sHost, const X509* pCert,
CString& sError) {
struct Tr : CCoreTranslationMixin {
using CCoreTranslationMixin::t_s;
};
DEBUG("SSLVerifyHost: checking " << sHost);
ZNC_iSECPartners::HostnameValidationResult eResult =
ZNC_iSECPartners::validate_hostname(sHost.c_str(), pCert);
@@ -441,15 +445,15 @@ bool ZNC_SSLVerifyHost(const CString& sHost, const X509* pCert,
return true;
case ZNC_iSECPartners::MatchNotFound:
DEBUG("SSLVerifyHost: host doesn't match");
sError = "hostname doesn't match";
sError = Tr::t_s("hostname doesn't match");
return false;
case ZNC_iSECPartners::MalformedCertificate:
DEBUG("SSLVerifyHost: malformed cert");
sError = "malformed hostname in certificate";
sError = Tr::t_s("malformed hostname in certificate");
return false;
default:
DEBUG("SSLVerifyHost: error");
sError = "hostname verification error";
sError = Tr::t_s("hostname verification error");
return false;
}
}
+11 -7
View File
@@ -30,7 +30,7 @@
#ifdef HAVE_LIBSSL
// Copypasted from
// https://wiki.mozilla.org/Security/Server_Side_TLS#Intermediate_compatibility_.28default.29
// at 2016-06-03
// at 2018-04-01
static CString ZNC_DefaultCipher() {
return "ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-"
"ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-"
@@ -333,16 +333,19 @@ void CSockManager::SetTDNSThreadFinished(TDNSTask* task, bool bBind,
try {
if (ssTargets4.empty() && ssTargets6.empty()) {
throw "Can't resolve server hostname";
throw t_s("Can't resolve server hostname");
} else if (task->sBindhost.empty()) {
// Choose random target
std::tie(sTargetHost, std::ignore) =
RandomFrom2SetsWithBias(ssTargets4, ssTargets6, gen);
} else if (ssBinds4.empty() && ssBinds6.empty()) {
throw "Can't resolve bind hostname. Try /znc ClearBindHost and /znc ClearUserBindHost";
throw t_s(
"Can't resolve bind hostname. Try /znc ClearBindHost and /znc "
"ClearUserBindHost");
} else if (ssBinds4.empty()) {
if (ssTargets6.empty()) {
throw "Server address is IPv4-only, but bindhost is IPv6-only";
throw t_s(
"Server address is IPv4-only, but bindhost is IPv6-only");
} else {
// Choose random target and bindhost from IPv6-only sets
sTargetHost = RandomFromSet(ssTargets6, gen);
@@ -350,7 +353,8 @@ void CSockManager::SetTDNSThreadFinished(TDNSTask* task, bool bBind,
}
} else if (ssBinds6.empty()) {
if (ssTargets4.empty()) {
throw "Server address is IPv6-only, but bindhost is IPv4-only";
throw t_s(
"Server address is IPv6-only, but bindhost is IPv4-only");
} else {
// Choose random target and bindhost from IPv4-only sets
sTargetHost = RandomFromSet(ssTargets4, gen);
@@ -370,7 +374,7 @@ void CSockManager::SetTDNSThreadFinished(TDNSTask* task, bool bBind,
<< "] using bindhost [" << sBindhost << "]");
FinishConnect(sTargetHost, task->iPort, task->sSockName, task->iTimeout,
task->bSSL, sBindhost, task->pcSock);
} catch (const char* s) {
} catch (const CString& s) {
DEBUG(task->sSockName << ", dns resolving error: " << s);
task->pcSock->SetSockName(task->sSockName);
task->pcSock->SockError(-1, s);
@@ -508,7 +512,7 @@ void CSocket::ReachedMaxBuffer() {
DEBUG(GetSockName() << " == ReachedMaxBuffer()");
if (m_pModule)
m_pModule->PutModule(
"Some socket reached its max buffer limit and was closed!");
t_s("Some socket reached its max buffer limit and was closed!"));
Close();
}
+11 -11
View File
@@ -504,11 +504,11 @@ bool CUser::ParseConfig(CConfig* pConfig, CString& sError) {
CIRCNetwork* CUser::AddNetwork(const CString& sNetwork, CString& sErrorRet) {
if (!CIRCNetwork::IsValidNetwork(sNetwork)) {
sErrorRet =
"Invalid network name. It should be alphanumeric. Not to be "
"confused with server name";
t_s("Invalid network name. It should be alphanumeric. Not to be "
"confused with server name");
return nullptr;
} else if (FindNetwork(sNetwork)) {
sErrorRet = "Network [" + sNetwork.Token(0) + "] already exists";
sErrorRet = t_f("Network {1} already exists")(sNetwork);
return nullptr;
}
@@ -674,8 +674,8 @@ void CUser::UserConnected(CClient* pClient) {
BounceAllClients();
}
pClient->PutClient(":irc.znc.in 001 " + pClient->GetNick() +
" :- Welcome to ZNC -");
pClient->PutClient(":irc.znc.in 001 " + pClient->GetNick() + " :" +
t_s("Welcome to ZNC"));
m_vClients.push_back(pClient);
}
@@ -774,8 +774,8 @@ bool CUser::Clone(const CUser& User, CString& sErrorRet, bool bCloneNetworks) {
for (CClient* pSock : m_vClients) {
if (!IsHostAllowed(pSock->GetRemoteIP())) {
pSock->PutStatusNotice(
"You are being disconnected because your IP is no longer "
"allowed to connect to this user");
t_s("You are being disconnected because your IP is no longer "
"allowed to connect to this user"));
pSock->Close();
}
}
@@ -904,17 +904,17 @@ bool CUser::IsValid(CString& sErrMsg, bool bSkipPass) const {
sErrMsg.clear();
if (!bSkipPass && m_sPass.empty()) {
sErrMsg = "Pass is empty";
sErrMsg = t_s("Password is empty");
return false;
}
if (m_sUserName.empty()) {
sErrMsg = "Username is empty";
sErrMsg = t_s("Username is empty");
return false;
}
if (!CUser::IsValidUserName(m_sUserName)) {
sErrMsg = "Username is invalid";
sErrMsg = t_s("Username is invalid");
return false;
}
@@ -1185,7 +1185,7 @@ bool CUser::LoadModule(const CString& sModName, const CString& sArgs,
CModInfo ModInfo;
if (!CZNC::Get().GetModules().GetModInfo(ModInfo, sModName, sModRet)) {
sError = "Unable to find modinfo [" + sModName + "] [" + sModRet + "]";
sError = t_f("Unable to find modinfo {1}: {2}")(sModName, sModRet);
return false;
}
+1661 -1
View File
File diff suppressed because it is too large Load Diff
+1661 -1
View File
File diff suppressed because it is too large Load Diff
+1679 -3
View File
File diff suppressed because it is too large Load Diff
+11 -11
View File
@@ -34,12 +34,6 @@ using std::list;
using std::tuple;
using std::make_tuple;
static inline CString FormatBindError() {
CString sError = (errno == 0 ? CString("unknown error, check the host name")
: CString(strerror(errno)));
return "Unable to bind [" + sError + "]";
}
CZNC::CZNC()
: m_TimeStarted(time(nullptr)),
m_eConfigState(ECONFIG_NOTHING),
@@ -1566,7 +1560,7 @@ bool CZNC::DeleteUser(const CString& sUsername) {
bool CZNC::AddUser(CUser* pUser, CString& sErrorRet, bool bStartup) {
if (FindUser(pUser->GetUserName()) != nullptr) {
sErrorRet = "User already exists";
sErrorRet = t_s("User already exists");
DEBUG("User [" << pUser->GetUserName() << "] - already exists");
return false;
}
@@ -1674,7 +1668,7 @@ bool CZNC::AddListener(unsigned short uPort, const CString& sBindHost,
#ifndef HAVE_IPV6
if (ADDR_IPV6ONLY == eAddr) {
sError = "IPV6 is not enabled";
sError = t_s("IPv6 is not enabled");
CUtils::PrintStatus(false, sError);
return false;
}
@@ -1682,7 +1676,7 @@ bool CZNC::AddListener(unsigned short uPort, const CString& sBindHost,
#ifndef HAVE_LIBSSL
if (bSSL) {
sError = "SSL is not enabled";
sError = t_s("SSL is not enabled");
CUtils::PrintStatus(false, sError);
return false;
}
@@ -1690,7 +1684,7 @@ bool CZNC::AddListener(unsigned short uPort, const CString& sBindHost,
CString sPemFile = GetPemLocation();
if (bSSL && !CFile::Exists(sPemFile)) {
sError = "Unable to locate pem file: [" + sPemFile + "]";
sError = t_f("Unable to locate pem file: {1}")(sPemFile);
CUtils::PrintStatus(false, sError);
// If stdin is e.g. /dev/null and we call GetBoolInput(),
@@ -1709,7 +1703,7 @@ bool CZNC::AddListener(unsigned short uPort, const CString& sBindHost,
}
#endif
if (!uPort) {
sError = "Invalid port";
sError = t_s("Invalid port");
CUtils::PrintStatus(false, sError);
return false;
}
@@ -1822,6 +1816,12 @@ bool CZNC::DelListener(CListener* pListener) {
return false;
}
CString CZNC::FormatBindError() {
CString sError = (errno == 0 ? t_s(("unknown error, check the host name"))
: CString(strerror(errno)));
return t_f("Unable to bind: {1}")(sError);
}
static CZNC* s_pZNC = nullptr;
void CZNC::CreateInstance() {
+1 -1
View File
@@ -211,7 +211,7 @@ TEST_F(IRCSockTest, OnErrorMessage) {
EXPECT_THAT(
m_pTestClient->vsLines,
ElementsAre(
":*status!znc@znc.in PRIVMSG me :Error from Server [foo bar]"));
":*status!znc@znc.in PRIVMSG me :Error from server: foo bar"));
}
TEST_F(IRCSockTest, OnInviteMessage) {
-5
View File
@@ -17,11 +17,6 @@
#include <gtest/gtest.h>
#include <znc/ZNCString.h>
// GTest uses this function to output objects
static void PrintTo(const CString& s, std::ostream* o) {
*o << '"' << s.Escape_n(CString::EASCII, CString::EDEBUG) << '"';
}
class EscapeTest : public ::testing::Test {
protected:
void testEncode(const CString& in, const CString& expectedOut,
+95
View File
@@ -57,5 +57,100 @@ TEST_F(ZNCTest, Modpython) {
client.ReadUntil("Hi\xEF\xBF\xBD, github issue");
}
TEST_F(ZNCTest, ModpythonSocket) {
if (QProcessEnvironment::systemEnvironment().value(
"DISABLED_ZNC_PERL_PYTHON_TEST") == "1") {
return;
}
auto znc = Run();
znc->CanLeak();
InstallModule("socktest.py", R"(
import znc
class acc(znc.Socket):
def OnReadData(self, data):
self.GetModule().PutModule('received {} bytes'.format(len(data)))
self.Close()
class lis(znc.Socket):
def OnAccepted(self, host, port):
sock = self.GetModule().CreateSocket(acc)
sock.DisableReadLine()
return sock
class socktest(znc.Module):
def OnLoad(self, args, ret):
listen = self.CreateSocket(lis)
self.port = listen.Listen()
return True
def OnModCommand(self, cmd):
sock = self.CreateSocket()
sock.Connect('127.0.0.1', self.port)
sock.WriteBytes(b'blah')
)");
auto ircd = ConnectIRCd();
auto client = LoginClient();
client.Write("znc loadmod modpython");
client.Write("znc loadmod socktest");
client.Write("PRIVMSG *socktest :foo");
client.ReadUntil("received 4 bytes");
}
TEST_F(ZNCTest, ModperlSocket) {
if (QProcessEnvironment::systemEnvironment().value(
"DISABLED_ZNC_PERL_PYTHON_TEST") == "1") {
return;
}
auto znc = Run();
znc->CanLeak();
InstallModule("socktest.pm", R"(
package socktest::acc;
use base 'ZNC::Socket';
sub OnReadData {
my ($self, $data, $len) = @_;
$self->GetModule->PutModule("received $len bytes");
$self->Close;
}
package socktest::lis;
use base 'ZNC::Socket';
sub OnAccepted {
my $self = shift;
return $self->GetModule->CreateSocket('socktest::acc');
}
package socktest::conn;
use base 'ZNC::Socket';
package socktest;
use base 'ZNC::Module';
sub OnLoad {
my $self = shift;
my $listen = $self->CreateSocket('socktest::lis');
$self->{port} = $listen->Listen;
return 1;
}
sub OnModCommand {
my ($self, $cmd) = @_;
my $sock = $self->CreateSocket('socktest::conn');
$sock->Connect('127.0.0.1', $self->{port});
$sock->Write('blah');
}
1;
)");
auto ircd = ConnectIRCd();
auto client = LoginClient();
client.Write("znc loadmod modperl");
client.Write("znc loadmod socktest");
client.Write("PRIVMSG *socktest :foo");
client.ReadUntil("received 4 bytes");
}
} // namespace
} // namespace znc_inttest