mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-01-10 23:27:56 -05:00
darkirc: fix connection password
This commit is contained in:
@@ -599,18 +599,24 @@ impl Client {
|
||||
|
||||
/// `PASS <password>`
|
||||
///
|
||||
/// Used to set a ‘connection password’. If set, the password must
|
||||
/// Used to set a connection `<password>`. If set, the password must
|
||||
/// be set before USER/NICK commands.
|
||||
pub async fn handle_cmd_pass(&self, args: &str) -> Result<Vec<ReplyType>> {
|
||||
let mut tokens = args.split_ascii_whitespace();
|
||||
let nick = self.nickname.read().await.to_string();
|
||||
let Some(password) = tokens.next() else {
|
||||
|
||||
// "the final parameter can be prepended with a (':', 0x3A) character"
|
||||
// <https://modern.ircdocs.horse/#parameters>
|
||||
let Some(i) = args.find(' ') else {
|
||||
// self.penalty.fetch_add(1, SeqCst);
|
||||
return Ok(vec![ReplyType::Server((
|
||||
ERR_NEEDMOREPARAMS,
|
||||
format!("{} PASS :{}", nick, INVALID_SYNTAX),
|
||||
))])
|
||||
};
|
||||
let mut password = &args[i + 1..];
|
||||
if password.starts_with(':') {
|
||||
password = &password[1..];
|
||||
}
|
||||
|
||||
if self.server.password == bcrypt_hash_password(password) {
|
||||
self.is_pass_set.store(true, SeqCst);
|
||||
|
||||
Reference in New Issue
Block a user