From 24d257071c6b17d95cad976e6a0114e0e35ece2a Mon Sep 17 00:00:00 2001 From: Patrick Date: Fri, 3 Apr 2026 16:40:35 +0200 Subject: [PATCH 1/2] Route ENCAP messages directly if possible (2.11.3) --- ircd/s_serv.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/ircd/s_serv.c b/ircd/s_serv.c index 3905744d..446575b2 100644 --- a/ircd/s_serv.c +++ b/ircd/s_serv.c @@ -3793,6 +3793,40 @@ static void report_listeners(aClient *sptr, char *to) } } +static void +encap_route(aClient *cptr, char *mask, char *buf) +{ + aClient *acptr; + int exact; + + if (!strcmp(mask, me.name) || !strcmp(mask, me.serv->sid)) + return; + + exact = (strchr(mask, '*') == NULL && + strchr(mask, '?') == NULL && + strchr(mask, '#') == NULL); + + if (!exact) + { + sendto_serv_v(cptr, SV_UID, "%s", buf); + return; + } + + acptr = find_sid(mask, NULL); + if (!acptr) + acptr = find_server(mask, NULL); + + if (!acptr) + { + sendto_flag(SCH_ERROR, + "Cannot route ENCAP to unknown target %s", mask); + return; + } + + if (acptr->from != cptr) + sendto_one(acptr, "%s", buf); +} + /* ** allows ENCAPsulation of commands ** parv[0] is ignored (though it's source) @@ -3823,8 +3857,8 @@ int m_encap(aClient *cptr, aClient *sptr, int parc, char *parv[]) else len += sprintf(buf+len, " %s", parv[i]); } - /* ...and broadcast it. */ - sendto_serv_v(cptr, SV_UID, "%s", buf); + + encap_route(cptr, parv[1], buf); /* FIXME: in 2.11.1 */ /* Do we match parv[1]? */ From b69fd5253076c1e0ad400fff67fe13d28b05410d Mon Sep 17 00:00:00 2001 From: Patrick Date: Fri, 3 Apr 2026 17:02:41 +0200 Subject: [PATCH 2/2] Route ENCAP messages directly if possible (2.11.3) - ignore unknown targets --- ircd/s_serv.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/ircd/s_serv.c b/ircd/s_serv.c index 446575b2..b449dc41 100644 --- a/ircd/s_serv.c +++ b/ircd/s_serv.c @@ -3818,8 +3818,6 @@ encap_route(aClient *cptr, char *mask, char *buf) if (!acptr) { - sendto_flag(SCH_ERROR, - "Cannot route ENCAP to unknown target %s", mask); return; }