-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for the draft/extended-monitor capability #254
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,6 +95,7 @@ unsigned int CLICAP_USERHOST_IN_NAMES; | |
unsigned int CLICAP_CAP_NOTIFY; | ||
unsigned int CLICAP_CHGHOST; | ||
unsigned int CLICAP_ECHO_MESSAGE; | ||
unsigned int CLICAP_EXTENDED_MONITOR; | ||
|
||
/* | ||
* initialize our builtin capability table. --nenolod | ||
|
@@ -142,6 +143,7 @@ init_builtin_capabs(void) | |
CLICAP_CAP_NOTIFY = capability_put(cli_capindex, "cap-notify", NULL); | ||
CLICAP_CHGHOST = capability_put(cli_capindex, "chghost", &high_priority); | ||
CLICAP_ECHO_MESSAGE = capability_put(cli_capindex, "echo-message", NULL); | ||
CLICAP_EXTENDED_MONITOR = capability_put(cli_capindex, "draft/extended-monitor", &high_priority); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this need high priority? It's a draft cap, and anybody supporting it should support 3.2-style CAP LS (which doesn't need priority) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense 👍 |
||
} | ||
|
||
static CNCB serv_connect_callback; | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1637,6 +1637,10 @@ change_nick_user_host(struct Client *target_p, const char *nick, const char *use | |||||
sendto_common_channels_local_butone(target_p, CLICAP_CHGHOST, NOCAPS, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of abusing current_serial semantics, this should exclude users with extended-monitor enabled:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We still want to sent messages to users sharing a channel and who have the extended-monitor cap but who are not currently monitoring the user. That's why we can't just send to neighbours first, excluding those who have the cap, then send to all those who are monitoring the user. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Err, yes. The correct implementation would end up being more complex than this, my brain just failed to process it correctly. |
||||||
":%s!%s@%s CHGHOST %s %s", | ||||||
target_p->name, target_p->username, target_p->host, user, host); | ||||||
struct monitor *monptr = find_monitor(target_p->name, 0); | ||||||
if(monptr) | ||||||
sendto_monitor_with_capability_butserial(target_p, monptr, CLICAP_EXTENDED_MONITOR | CLICAP_CHGHOST, NOCAPS, true, ":%s!%s@%s CHGHOST %s %s", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eliminate current_serial abuse
Suggested change
|
||||||
target_p->name, target_p->username, target_p->host, user, host); | ||||||
|
||||||
if(MyClient(target_p) && changed_case) | ||||||
sendto_one(target_p, ":%s!%s@%s NICK %s", | ||||||
|
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1163,34 +1163,33 @@ sendto_local_clients_with_capability(int cap, const char *pattern, ...) | |||||||||||
msgbuf_cache_free(&msgbuf_cache); | ||||||||||||
} | ||||||||||||
|
||||||||||||
/* sendto_monitor() | ||||||||||||
/* | ||||||||||||
* _sendto_monitor_with_capability_butserial() | ||||||||||||
* | ||||||||||||
* inputs - monitor nick to send to, format, va_args | ||||||||||||
* outputs - message to local users monitoring the given nick | ||||||||||||
* side effects - | ||||||||||||
* Shared implementation of sendto_monitor_with_capability_butserial and _sendto_monitor | ||||||||||||
*/ | ||||||||||||
void | ||||||||||||
sendto_monitor(struct Client *source_p, struct monitor *monptr, const char *pattern, ...) | ||||||||||||
_sendto_monitor_with_capability_butserial(struct Client *source_p, struct monitor *monptr, int caps, int negcaps, bool skipserial, const char *pattern, va_list * args) | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eliminate current_serial abuse
Suggested change
|
||||||||||||
{ | ||||||||||||
va_list args; | ||||||||||||
struct Client *target_p; | ||||||||||||
rb_dlink_node *ptr; | ||||||||||||
rb_dlink_node *next_ptr; | ||||||||||||
struct MsgBuf msgbuf; | ||||||||||||
struct MsgBuf_cache msgbuf_cache; | ||||||||||||
rb_strf_t strings = { .format = pattern, .format_args = &args, .next = NULL }; | ||||||||||||
rb_strf_t strings = { .format = pattern, .format_args = args, .next = NULL }; | ||||||||||||
|
||||||||||||
build_msgbuf_tags(&msgbuf, source_p); | ||||||||||||
|
||||||||||||
va_start(args, pattern); | ||||||||||||
msgbuf_cache_init(&msgbuf_cache, &msgbuf, &strings); | ||||||||||||
va_end(args); | ||||||||||||
|
||||||||||||
RB_DLINK_FOREACH_SAFE(ptr, next_ptr, monptr->users.head) | ||||||||||||
{ | ||||||||||||
target_p = ptr->data; | ||||||||||||
|
||||||||||||
if(IsIOError(target_p)) | ||||||||||||
if(IsIOError(target_p) || | ||||||||||||
(skipserial && target_p->serial == current_serial) || | ||||||||||||
!IsCapable(target_p, caps) || | ||||||||||||
Comment on lines
+1189
to
+1191
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eliminate current_serial abuse
Suggested change
|
||||||||||||
!NotCapable(target_p, negcaps)) | ||||||||||||
continue; | ||||||||||||
|
||||||||||||
_send_linebuf(target_p, msgbuf_cache_get(&msgbuf_cache, CLIENT_CAPS_ONLY(target_p))); | ||||||||||||
|
@@ -1199,6 +1198,38 @@ sendto_monitor(struct Client *source_p, struct monitor *monptr, const char *patt | |||||||||||
msgbuf_cache_free(&msgbuf_cache); | ||||||||||||
} | ||||||||||||
|
||||||||||||
/* sendto_monitor_with_capability_butserial() | ||||||||||||
* | ||||||||||||
* inputs - monitor nick to send to, caps, negate caps, whether to send to clients having current serial, format, va_args | ||||||||||||
* outputs - message to local users monitoring the given nick | ||||||||||||
* side effects - | ||||||||||||
*/ | ||||||||||||
void | ||||||||||||
sendto_monitor_with_capability_butserial(struct Client *source_p, struct monitor *monptr, int caps, int negcaps, bool skipserial, const char *pattern, ...) | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eliminate current_serial abuse
Suggested change
|
||||||||||||
{ | ||||||||||||
va_list args; | ||||||||||||
|
||||||||||||
va_start(args, pattern); | ||||||||||||
_sendto_monitor_with_capability_butserial(source_p, monptr, caps, negcaps, skipserial, pattern, &args); | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eliminate current_serial abuse
Suggested change
|
||||||||||||
va_end(args); | ||||||||||||
} | ||||||||||||
|
||||||||||||
/* sendto_monitor() | ||||||||||||
* | ||||||||||||
* inputs - monitor nick to send to, format, va_args | ||||||||||||
* outputs - message to local users monitoring the given nick | ||||||||||||
* side effects - | ||||||||||||
*/ | ||||||||||||
void | ||||||||||||
sendto_monitor(struct Client *source_p, struct monitor *monptr, const char *pattern, ...) | ||||||||||||
{ | ||||||||||||
va_list args; | ||||||||||||
|
||||||||||||
va_start(args, pattern); | ||||||||||||
_sendto_monitor_with_capability_butserial(source_p, monptr, NOCAPS, NOCAPS, false, pattern, &args); | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eliminate current_serial abuse
Suggested change
|
||||||||||||
va_end(args); | ||||||||||||
} | ||||||||||||
|
||||||||||||
/* _sendto_anywhere() | ||||||||||||
* | ||||||||||||
* inputs - real_target, target, source, va_args | ||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -26,6 +26,7 @@ | |||||
#include "client.h" | ||||||
#include "match.h" | ||||||
#include "ircd.h" | ||||||
#include "monitor.h" | ||||||
#include "numeric.h" | ||||||
#include "send.h" | ||||||
#include "msg.h" | ||||||
|
@@ -89,6 +90,10 @@ m_away(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p | |||||
|
||||||
sendto_common_channels_local_butone(source_p, CLICAP_AWAY_NOTIFY, NOCAPS, ":%s!%s@%s AWAY", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exclude extended-monitor
Suggested change
|
||||||
source_p->name, source_p->username, source_p->host); | ||||||
struct monitor *monptr = find_monitor(source_p->name, 0); | ||||||
if(monptr) | ||||||
sendto_monitor_with_capability_butserial(source_p, monptr, CLICAP_EXTENDED_MONITOR | CLICAP_AWAY_NOTIFY, NOCAPS, true, ":%s!%s@%s AWAY", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eliminate current_serial abuse
Suggested change
|
||||||
source_p->name, source_p->username, source_p->host); | ||||||
} | ||||||
if(MyConnect(source_p)) | ||||||
sendto_one_numeric(source_p, RPL_UNAWAY, form_str(RPL_UNAWAY)); | ||||||
|
@@ -127,6 +132,14 @@ m_away(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p | |||||
source_p->username, | ||||||
source_p->host, | ||||||
source_p->user->away); | ||||||
struct monitor *monptr = find_monitor(source_p->name, 0); | ||||||
if(monptr) | ||||||
sendto_monitor_with_capability_butserial(source_p, monptr, CLICAP_EXTENDED_MONITOR | CLICAP_AWAY_NOTIFY, NOCAPS, true, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adjust the regular away-notify to exclude extended-monitor (due to a GitHub limitation, I can't comment on that line). Eliminate current_serial abuse
Suggested change
|
||||||
":%s!%s@%s AWAY :%s", | ||||||
source_p->name, | ||||||
source_p->username, | ||||||
source_p->host, | ||||||
source_p->user->away); | ||||||
} | ||||||
|
||||||
if(MyConnect(source_p)) | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -139,6 +139,11 @@ me_su(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, | |||||
sendto_common_channels_local(target_p, CLICAP_ACCOUNT_NOTIFY, NOCAPS, ":%s!%s@%s ACCOUNT %s", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exclude extended-monitor
Suggested change
|
||||||
target_p->name, target_p->username, target_p->host, | ||||||
EmptyString(target_p->user->suser) ? "*" : target_p->user->suser); | ||||||
struct monitor *monptr = find_monitor(target_p->name, 0); | ||||||
if(monptr) | ||||||
sendto_monitor_with_capability_butserial(target_p, monptr, CLICAP_EXTENDED_MONITOR | CLICAP_ACCOUNT_NOTIFY, NOCAPS, true, ":%s!%s@%s ACCOUNT %s", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eliminate current_serial abuse
Suggested change
|
||||||
target_p->name, target_p->username, target_p->host, | ||||||
EmptyString(target_p->user->suser) ? "*" : target_p->user->suser); | ||||||
|
||||||
invalidate_bancache_user(target_p); | ||||||
} | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eliminate current_serial abuse