mirror of
https://github.com/znc/znc.git
synced 2026-04-30 18:42:25 +02:00
Show fingerprints with colons
This commit is contained in:
@@ -122,7 +122,7 @@ public:
|
||||
bool IsLastServer() const;
|
||||
|
||||
const SCString& GetTrustedFingerprints() const { return m_ssTrustedFingerprints; }
|
||||
void AddTrustedFingerprint(const CString& sFP) { m_ssTrustedFingerprints.insert(sFP.AsLower()); }
|
||||
void AddTrustedFingerprint(const CString& sFP) { m_ssTrustedFingerprints.insert(sFP.Escape_n(CString::EHEXCOLON, CString::EHEXCOLON)); }
|
||||
void DelTrustedFingerprint(const CString& sFP) { m_ssTrustedFingerprints.erase(sFP); }
|
||||
|
||||
void SetIRCConnectEnabled(bool b);
|
||||
|
||||
@@ -78,7 +78,8 @@ public:
|
||||
ESQL,
|
||||
ENAMEDFMT,
|
||||
EDEBUG,
|
||||
EMSGTAG
|
||||
EMSGTAG,
|
||||
EHEXCOLON,
|
||||
} EEscape;
|
||||
|
||||
static const CaseSensitivity CaseSensitive = CaseSensitivity::CaseSensitive;
|
||||
|
||||
@@ -1148,7 +1148,7 @@ void CIRCSock::SockError(int iErrno, const CString& sDescription) {
|
||||
}
|
||||
CString sSHA1;
|
||||
if (GetPeerFingerprint(sSHA1))
|
||||
m_pNetwork->PutStatus("SHA1: " + sSHA1);
|
||||
m_pNetwork->PutStatus("SHA1: " + sSHA1.Escape_n(CString::EHEXCOLON, CString::EHEXCOLON));
|
||||
CString sSHA256 = GetSSLPeerFingerprint();
|
||||
m_pNetwork->PutStatus("SHA-256: " + sSHA256);
|
||||
m_pNetwork->PutStatus("If you trust this certificate, do /znc AddTrustedServerFingerprint " + sSHA256);
|
||||
|
||||
@@ -184,6 +184,8 @@ CString::EEscape CString::ToEscape(const CString& sEsc) {
|
||||
return EDEBUG;
|
||||
} else if (sEsc.Equals("MSGTAG")) {
|
||||
return EMSGTAG;
|
||||
} else if (sEsc.Equals("HEXCOLON")) {
|
||||
return EHEXCOLON;
|
||||
}
|
||||
|
||||
return EASCII;
|
||||
@@ -350,6 +352,35 @@ CString CString::Escape_n(EEscape eFrom, EEscape eTo) const {
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case EHEXCOLON: {
|
||||
while (!isxdigit(*p) && a < iLength) {
|
||||
a++;
|
||||
p++;
|
||||
}
|
||||
if (a == iLength) {
|
||||
continue;
|
||||
}
|
||||
if (isdigit(*p)) {
|
||||
ch = (unsigned char)((*p - '0') << 4);
|
||||
} else {
|
||||
ch = (unsigned char)((tolower(*p) - 'a' +10) << 4);
|
||||
}
|
||||
a++;
|
||||
p++;
|
||||
while (!isxdigit(*p) && a < iLength) {
|
||||
a++;
|
||||
p++;
|
||||
}
|
||||
if (a == iLength) {
|
||||
continue;
|
||||
}
|
||||
if (isdigit(*p)) {
|
||||
ch |= (unsigned char)(*p - '0');
|
||||
} else {
|
||||
ch |= (unsigned char)(tolower(*p) - 'a' +10);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -419,11 +450,20 @@ CString CString::Escape_n(EEscape eFrom, EEscape eTo) const {
|
||||
} else if (ch == '\n') { sRet += '\\'; sRet += 'n';
|
||||
} else { sRet += ch; }
|
||||
|
||||
break;
|
||||
case EHEXCOLON: {
|
||||
sRet += tolower(szHex[ch >> 4]);
|
||||
sRet += tolower(szHex[ch & 0xf]);
|
||||
sRet += ":";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sRet.reserve(0);
|
||||
if (eTo == EHEXCOLON) {
|
||||
sRet.TrimRight(":");
|
||||
}
|
||||
|
||||
return sRet;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user