Skip to content

Commit b911745

Browse files
committed
Add RPL_VISIBLEHOST numeric as an alternative for resolving username/hostname.
Increase safety buffer on `relay_bytes`.
1 parent 7e99ac0 commit b911745

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

data/src/client.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2459,6 +2459,16 @@ impl Client {
24592459
sent_time: message.server_time_or_now(),
24602460
})]);
24612461
}
2462+
Command::Numeric(RPL_VISIBLEHOST, args) => {
2463+
let hostname = ok!(args.get(1));
2464+
2465+
if let Some((username, hostname)) = hostname.split_once('@') {
2466+
self.resolved_user = Some(username.to_string());
2467+
self.resolved_host = Some(hostname.to_string());
2468+
} else {
2469+
self.resolved_host = Some(hostname.to_string());
2470+
}
2471+
}
24622472
Command::Numeric(RPL_MONONLINE, args) => {
24632473
let casemapping =
24642474
isupport::get_casemapping_or_default(&self.isupport);
@@ -3788,9 +3798,7 @@ impl Client {
37883798

37893799
// Known bytes or a reasonable, conservative estimate of
37903800
// ':nick!user@host ' that must be prepended to relay a
3791-
// PRIVMSG/NOTICE, plus bytes for ':' that some servers will prepend
3792-
// to a relayed PRIVMSG's text (even if the content does not contain
3793-
// spaces)
3801+
// PRIVMSG/NOTICE, plus a safety buffer of 10 bytes
37943802
pub fn relay_bytes(&self) -> usize {
37953803
self.nickname().as_str().len()
37963804
+ if let Some(resolved_user) = &self.resolved_user {
@@ -3811,7 +3819,7 @@ impl Client {
38113819
} else {
38123820
64
38133821
}
3814-
+ 5
3822+
+ 14
38153823
}
38163824

38173825
pub fn multiline(&self) -> Option<Multiline> {

irc/proto/src/command.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ pub enum Numeric {
513513
RPL_YOUREOPER = 381,
514514
RPL_REHASHING = 382,
515515
RPL_TIME = 391,
516+
RPL_VISIBLEHOST = 396,
516517
ERR_UNKNOWNERROR = 400,
517518
ERR_NOSUCHNICK = 401,
518519
ERR_NOSUCHSERVER = 402,

0 commit comments

Comments
 (0)