mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
replace sha-1 with xmpp-parsers for component handshake
This commit is contained in:
parent
7baced0c3f
commit
2e746f89e2
3 changed files with 5 additions and 12 deletions
|
@ -27,5 +27,4 @@ domain = "0.2"
|
||||||
xmpp-parsers = "0.10"
|
xmpp-parsers = "0.10"
|
||||||
idna = "0.1"
|
idna = "0.1"
|
||||||
try_from = "0.2"
|
try_from = "0.2"
|
||||||
sha-1 = "0.7"
|
|
||||||
quick-xml = "0.12"
|
quick-xml = "0.12"
|
||||||
|
|
|
@ -2,7 +2,7 @@ use std::mem::replace;
|
||||||
use futures::{Future, Poll, Async, sink, Sink, Stream};
|
use futures::{Future, Poll, Async, sink, Sink, Stream};
|
||||||
use tokio_io::{AsyncRead, AsyncWrite};
|
use tokio_io::{AsyncRead, AsyncWrite};
|
||||||
use minidom::Element;
|
use minidom::Element;
|
||||||
use sha1::{Sha1, Digest};
|
use xmpp_parsers::component::Handshake;
|
||||||
|
|
||||||
use xmpp_codec::Packet;
|
use xmpp_codec::Packet;
|
||||||
use xmpp_stream::XMPPStream;
|
use xmpp_stream::XMPPStream;
|
||||||
|
@ -28,19 +28,13 @@ impl<S: AsyncWrite> ComponentAuth<S> {
|
||||||
};
|
};
|
||||||
this.send(
|
this.send(
|
||||||
stream,
|
stream,
|
||||||
"handshake",
|
Handshake::from_password_and_stream_id(&password, &sid)
|
||||||
// TODO: sha1(sid + password)
|
|
||||||
&format!("{:x}", Sha1::digest((sid + &password).as_bytes()))
|
|
||||||
);
|
);
|
||||||
return Ok(this);
|
return Ok(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send(&mut self, stream: XMPPStream<S>, nonza_name: &str, handshake: &str) {
|
fn send(&mut self, stream: XMPPStream<S>, handshake: Handshake) {
|
||||||
let nonza = Element::builder(nonza_name)
|
let nonza = Element::from(handshake);
|
||||||
.ns(NS_JABBER_COMPONENT_ACCEPT)
|
|
||||||
.append(handshake)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
let send = stream.send(Packet::Stanza(nonza));
|
let send = stream.send(Packet::Stanza(nonza));
|
||||||
|
|
||||||
self.state = ComponentAuthState::WaitSend(send);
|
self.state = ComponentAuthState::WaitSend(send);
|
||||||
|
|
|
@ -14,7 +14,7 @@ extern crate rustc_serialize as serialize;
|
||||||
extern crate jid;
|
extern crate jid;
|
||||||
extern crate domain;
|
extern crate domain;
|
||||||
extern crate idna;
|
extern crate idna;
|
||||||
extern crate sha1;
|
extern crate xmpp_parsers;
|
||||||
|
|
||||||
pub mod xmpp_codec;
|
pub mod xmpp_codec;
|
||||||
pub mod xmpp_stream;
|
pub mod xmpp_stream;
|
||||||
|
|
Loading…
Reference in a new issue