From 980f27fc193666278b2f7eb4f63ca77e08615a90 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sun, 5 Jun 2016 14:43:34 +0100 Subject: Add CERTFP capability Avoid sending CERTFP commands to servers which do not support this by adding a CERTFP capability. --- include/s_serv.h | 1 + modules/core/m_server.c | 2 +- modules/m_certfp.c | 4 ++-- src/ircd.c | 1 + src/s_user.c | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/s_serv.h b/include/s_serv.h index 57fa865..b2c5cb7 100644 --- a/include/s_serv.h +++ b/include/s_serv.h @@ -67,6 +67,7 @@ struct Capability #define CAP_DLN 0x00008000 /* Can do DLINE message */ #define CAP_UNDLN 0x00010000 /* Can do UNDLINE message */ #define CAP_CHW 0x00020000 /* Can do channel wall @# */ +#define CAP_CERTFP 0x00040000 /* supports CERTFP */ /* * Capability macros. diff --git a/modules/core/m_server.c b/modules/core/m_server.c index f1851b8..b314872 100644 --- a/modules/core/m_server.c +++ b/modules/core/m_server.c @@ -104,7 +104,7 @@ sendnick_TS(struct Client *client_p, struct Client *target_p) target_p->servptr->name, target_p->info); } - if (!EmptyString(target_p->certfp)) + if (!EmptyString(target_p->certfp) && IsCapable(client_p, CAP_CERTFP)) sendto_one(client_p, ":%s CERTFP %s", ID_or_name(target_p, client_p), target_p->certfp); diff --git a/modules/m_certfp.c b/modules/m_certfp.c index e52f9f5..359a651 100644 --- a/modules/m_certfp.c +++ b/modules/m_certfp.c @@ -58,9 +58,9 @@ ms_certfp(struct Client *client_p, struct Client *source_p, MyFree(source_p->certfp); source_p->certfp = strdup(parv[1]); - sendto_server(client_p, CAP_TS6, NOCAPS, ":%s CERTFP %s", + sendto_server(client_p, CAP_TS6 | CAP_CERTFP, NOCAPS, ":%s CERTFP %s", ID(source_p), parv[1]); - sendto_server(client_p, NOCAPS, CAP_TS6, ":%s CERTFP %s", + sendto_server(client_p, CAP_CERTFP, CAP_TS6, ":%s CERTFP %s", source_p->name, parv[1]); return 0; } diff --git a/src/ircd.c b/src/ircd.c index 1862d6d..f286011 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -314,6 +314,7 @@ initialize_server_capabs(void) #ifdef HALFOPS add_capability("HOPS", CAP_HOPS, 1); #endif + add_capability("CERTFP", CAP_CERTFP, 1); } /* write_pidfile() diff --git a/src/s_user.c b/src/s_user.c index be041cf..b08d045 100644 --- a/src/s_user.c +++ b/src/s_user.c @@ -652,7 +652,7 @@ introduce_client(struct Client *source_p) source_p->servptr->name, source_p->info); } - if (!EmptyString(source_p->certfp)) + if (!EmptyString(source_p->certfp) && IsCapable(server, CAP_CERTFP)) sendto_one(server, ":%s CERTFP %s", ID(source_p), source_p->certfp); } } -- cgit