mirror of
https://github.com/anope/anope.git
synced 2026-07-05 00:53:12 +02:00
store the ssl fingerprint in the userstruct
This commit is contained in:
+7
-1
@@ -907,6 +907,12 @@ class CoreExport Module : public Extensible
|
||||
*/
|
||||
virtual void OnNickInfo(User *u, NickAlias *na, bool ShowHidden) { }
|
||||
|
||||
/** Called when we get informed about a users SSL fingerprint
|
||||
* when we call this, the fingerprint should already be stored in the user struct
|
||||
* @param u pointer to the user
|
||||
*/
|
||||
virtual void OnFingerprint(User *u) { }
|
||||
|
||||
/** Called when a vhost is deleted
|
||||
* @param na The nickalias of the vhost
|
||||
*/
|
||||
@@ -1032,7 +1038,7 @@ enum Implementation
|
||||
I_OnNickRegister, I_OnNickSuspended, I_OnNickUnsuspended,
|
||||
I_OnDelNick, I_OnDelCore, I_OnChangeCoreDisplay,
|
||||
I_OnDelNickRequest, I_OnMakeNickRequest, I_OnNickClearAccess, I_OnNickAddAccess, I_OnNickEraseAccess,
|
||||
I_OnNickInfo,
|
||||
I_OnNickInfo, I_OnFingerprint,
|
||||
|
||||
/* ChanServ */
|
||||
I_OnChanForbidden, I_OnChanSuspend, I_OnChanDrop, I_OnPreChanExpire, I_OnChanExpire, I_OnAccessAdd, I_OnAccessChange,
|
||||
|
||||
@@ -48,6 +48,7 @@ class CoreExport User : public Extensible
|
||||
Anope::string vhost; /* User's virtual hostname */
|
||||
Anope::string chost; /* User's cloaked hostname */
|
||||
Anope::string realname; /* Realname */
|
||||
Anope::string fingerprint; /* SSL Fingerprint */
|
||||
sockaddrs ip; /* User's IP */
|
||||
Server *server; /* Server user is connected to */
|
||||
time_t timestamp; /* Timestamp of the nick */
|
||||
|
||||
@@ -302,6 +302,13 @@ bool event_chghost(const Anope::string &source, const std::vector<Anope::string>
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* source = numeric of the sending server
|
||||
* params[0] = uuid
|
||||
* params[1] = metadata name
|
||||
* params[2] = data
|
||||
*/
|
||||
bool event_metadata(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (params.size() < 3)
|
||||
@@ -316,6 +323,25 @@ bool event_metadata(const Anope::string &source, const std::vector<Anope::string
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* possible incoming ssl_cert messages:
|
||||
* Received: :409 METADATA 409AAAAAA ssl_cert :vTrSe c38070ce96e41cc144ed6590a68d45a6 <...> <...>
|
||||
* Received: :409 METADATA 409AAAAAC ssl_cert :vTrSE Could not get peer certificate: error:00000000:lib(0):func(0):reason(0)
|
||||
*/
|
||||
if (params[1].equals_cs("ssl_cert"))
|
||||
{
|
||||
User *u = finduser(params[0]);
|
||||
if (!u)
|
||||
return true;
|
||||
std::string data = params[2].c_str();
|
||||
size_t pos1 = data.find(' ') + 1;
|
||||
size_t pos2 = data.find(' ', pos1);
|
||||
if (u && ((pos2 - pos1) == 32)) // fingerprints should always be 32 bytes in size
|
||||
{
|
||||
u->fingerprint = data.substr(pos1, pos2 - pos1);
|
||||
FOREACH_MOD(I_OnFingerprint, OnFingerprint(u));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -317,6 +317,13 @@ bool event_chghost(const Anope::string &source, const std::vector<Anope::string>
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* source = numeric of the sending server
|
||||
* params[0] = uuid
|
||||
* params[1] = metadata name
|
||||
* params[2] = data
|
||||
*/
|
||||
bool event_metadata(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (params.size() < 3)
|
||||
@@ -331,6 +338,25 @@ bool event_metadata(const Anope::string &source, const std::vector<Anope::string
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* possible incoming ssl_cert messages:
|
||||
* Received: :409 METADATA 409AAAAAA ssl_cert :vTrSe c38070ce96e41cc144ed6590a68d45a6 <...> <...>
|
||||
* Received: :409 METADATA 409AAAAAC ssl_cert :vTrSE Could not get peer certificate: error:00000000:lib(0):func(0):reason(0)
|
||||
*/
|
||||
if (params[1].equals_cs("ssl_cert"))
|
||||
{
|
||||
User *u = finduser(params[0]);
|
||||
if (!u)
|
||||
return true;
|
||||
std::string data = params[2].c_str();
|
||||
size_t pos1 = data.find(' ') + 1;
|
||||
size_t pos2 = data.find(' ', pos1);
|
||||
if ((pos2 - pos1) == 32) // fingerprints should always be 32 bytes in size
|
||||
{
|
||||
u->fingerprint = data.substr(pos1, pos2 - pos1);
|
||||
FOREACH_MOD(I_OnFingerprint, OnFingerprint(u));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -554,6 +554,46 @@ bool event_bmask(const Anope::string &source, const std::vector<Anope::string> &
|
||||
return true;
|
||||
}
|
||||
|
||||
bool event_encap(const Anope::string &sourcd, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (params.size() < 4)
|
||||
return true;
|
||||
/*
|
||||
* Received: :dev.anope.de ENCAP * SU DukePyrolator DukePyrolator
|
||||
* params[0] = *
|
||||
* params[1] = SU
|
||||
* params[2] = nickname
|
||||
* params[3] = account
|
||||
*/
|
||||
if (params[1].equals_cs("SU"))
|
||||
{
|
||||
User *u = finduser(params[2]);
|
||||
NickCore *nc = findcore(params[3]);
|
||||
if (u && nc)
|
||||
{
|
||||
u->Login(nc);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Received: :dev.anope.de ENCAP * CERTFP DukePyrolator :3F122A9CC7811DBAD3566BF2CEC3009007C0868F
|
||||
* params[0] = *
|
||||
* params[1] = CERTFP
|
||||
* params[2] = nickname
|
||||
* params[3] = fingerprint
|
||||
*/
|
||||
if (params[1].equals_cs("CERTFP"))
|
||||
{
|
||||
User *u = finduser(params[2]);
|
||||
if (u)
|
||||
{
|
||||
u->fingerprint = params[3];
|
||||
FOREACH_MOD(I_OnFingerprint, OnFingerprint(u));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
static void AddModes()
|
||||
{
|
||||
/* Add user modes */
|
||||
@@ -617,7 +657,7 @@ class ProtoPlexus : public Module
|
||||
ProtoPlexus(const Anope::string &modname, const Anope::string &creator) : Module(modname, creator),
|
||||
message_tmode("TMODE", event_tmode), message_bmask("BMASK", event_bmask),
|
||||
message_pass("PASS", event_pass), message_tb("TB", event_tburst),
|
||||
message_sid("SID", event_sid)
|
||||
message_sid("SID", event_sid), message_encap("ENCAP", event_encap);
|
||||
{
|
||||
this->SetAuthor("Anope");
|
||||
this->SetType(PROTOCOL);
|
||||
|
||||
@@ -196,6 +196,8 @@ Log::~Log()
|
||||
{
|
||||
if (nofork && debug && this->Type >= LOG_NORMAL && this->Type <= LOG_DEBUG + debug - 1)
|
||||
std::cout << GetTimeStamp() << " Debug: " << this->buf.str() << std::endl;
|
||||
else if (nofork && this->Type <= LOG_TERMINAL)
|
||||
std::cout << GetTimeStamp() << " " << this->buf.str() << std::endl;
|
||||
else if (this->Type == LOG_TERMINAL)
|
||||
std::cout << this->buf.str() << std::endl;
|
||||
for (unsigned i = 0; Config && i < Config->LogInfos.size(); ++i)
|
||||
|
||||
Reference in New Issue
Block a user