consolidate debug output
This commit is contained in:
parent
8b7a49d03a
commit
000f848dd0
4 changed files with 20 additions and 22 deletions
|
@ -36,7 +36,6 @@ impl<S: AsyncWrite> ClientAuth<S> {
|
||||||
Box::new(Anonymous::new()),
|
Box::new(Anonymous::new()),
|
||||||
];
|
];
|
||||||
|
|
||||||
println!("stream_features: {}", stream.stream_features);
|
|
||||||
let mech_names: Vec<String> =
|
let mech_names: Vec<String> =
|
||||||
match stream.stream_features.get_child("mechanisms", Some(NS_XMPP_SASL)) {
|
match stream.stream_features.get_child("mechanisms", Some(NS_XMPP_SASL)) {
|
||||||
None =>
|
None =>
|
||||||
|
@ -46,12 +45,12 @@ impl<S: AsyncWrite> ClientAuth<S> {
|
||||||
.map(|mech_el| mech_el.content_str())
|
.map(|mech_el| mech_el.content_str())
|
||||||
.collect(),
|
.collect(),
|
||||||
};
|
};
|
||||||
println!("Offered mechanisms: {:?}", mech_names);
|
println!("SASL mechanisms offered: {:?}", mech_names);
|
||||||
|
|
||||||
for mut mech in mechs {
|
for mut mech in mechs {
|
||||||
let name = mech.name().to_owned();
|
let name = mech.name().to_owned();
|
||||||
if mech_names.iter().any(|name1| *name1 == name) {
|
if mech_names.iter().any(|name1| *name1 == name) {
|
||||||
println!("Selected mechanism: {:?}", name);
|
println!("SASL mechanism selected: {:?}", name);
|
||||||
let initial = try!(mech.initial());
|
let initial = try!(mech.initial());
|
||||||
let mut this = ClientAuth {
|
let mut this = ClientAuth {
|
||||||
state: ClientAuthState::Invalid,
|
state: ClientAuthState::Invalid,
|
||||||
|
@ -79,7 +78,6 @@ impl<S: AsyncWrite> ClientAuth<S> {
|
||||||
);
|
);
|
||||||
nonza.text(content.to_base64(base64::URL_SAFE));
|
nonza.text(content.to_base64(base64::URL_SAFE));
|
||||||
|
|
||||||
println!("send {}", nonza);
|
|
||||||
let send = stream.send(Packet::Stanza(nonza));
|
let send = stream.send(Packet::Stanza(nonza));
|
||||||
|
|
||||||
self.state = ClientAuthState::WaitSend(send);
|
self.state = ClientAuthState::WaitSend(send);
|
||||||
|
@ -97,7 +95,6 @@ impl<S: AsyncRead + AsyncWrite> Future for ClientAuth<S> {
|
||||||
ClientAuthState::WaitSend(mut send) =>
|
ClientAuthState::WaitSend(mut send) =>
|
||||||
match send.poll() {
|
match send.poll() {
|
||||||
Ok(Async::Ready(stream)) => {
|
Ok(Async::Ready(stream)) => {
|
||||||
println!("send done");
|
|
||||||
self.state = ClientAuthState::WaitRecv(stream);
|
self.state = ClientAuthState::WaitRecv(stream);
|
||||||
self.poll()
|
self.poll()
|
||||||
},
|
},
|
||||||
|
|
|
@ -31,10 +31,7 @@ impl<S: AsyncWrite> ClientBind<S> {
|
||||||
// return the (probably // usable) stream immediately
|
// return the (probably // usable) stream immediately
|
||||||
ClientBind::Unsupported(stream),
|
ClientBind::Unsupported(stream),
|
||||||
Some(_) => {
|
Some(_) => {
|
||||||
println!("Bind is supported!");
|
|
||||||
|
|
||||||
let iq = make_bind_request(stream.jid.resource.as_ref());
|
let iq = make_bind_request(stream.jid.resource.as_ref());
|
||||||
println!("Send {}", iq);
|
|
||||||
let send = stream.send(Packet::Stanza(iq));
|
let send = stream.send(Packet::Stanza(iq));
|
||||||
ClientBind::WaitSend(send)
|
ClientBind::WaitSend(send)
|
||||||
},
|
},
|
||||||
|
|
|
@ -37,7 +37,6 @@ impl<S: AsyncRead + AsyncWrite> StartTlsClient<S> {
|
||||||
"starttls".to_owned(), Some(NS_XMPP_TLS.to_owned()),
|
"starttls".to_owned(), Some(NS_XMPP_TLS.to_owned()),
|
||||||
vec![]
|
vec![]
|
||||||
);
|
);
|
||||||
println!("send {}", nonza);
|
|
||||||
let packet = Packet::Stanza(nonza);
|
let packet = Packet::Stanza(nonza);
|
||||||
let send = xmpp_stream.send(packet);
|
let send = xmpp_stream.send(packet);
|
||||||
|
|
||||||
|
@ -60,7 +59,6 @@ impl<S: AsyncRead + AsyncWrite> Future for StartTlsClient<S> {
|
||||||
StartTlsClientState::SendStartTls(mut send) =>
|
StartTlsClientState::SendStartTls(mut send) =>
|
||||||
match send.poll() {
|
match send.poll() {
|
||||||
Ok(Async::Ready(xmpp_stream)) => {
|
Ok(Async::Ready(xmpp_stream)) => {
|
||||||
println!("starttls sent");
|
|
||||||
let new_state = StartTlsClientState::AwaitProceed(xmpp_stream);
|
let new_state = StartTlsClientState::AwaitProceed(xmpp_stream);
|
||||||
retry = true;
|
retry = true;
|
||||||
(new_state, Ok(Async::NotReady))
|
(new_state, Ok(Async::NotReady))
|
||||||
|
@ -75,7 +73,6 @@ impl<S: AsyncRead + AsyncWrite> Future for StartTlsClient<S> {
|
||||||
Ok(Async::Ready(Some(Packet::Stanza(ref stanza))))
|
Ok(Async::Ready(Some(Packet::Stanza(ref stanza))))
|
||||||
if stanza.name == "proceed" =>
|
if stanza.name == "proceed" =>
|
||||||
{
|
{
|
||||||
println!("* proceed *");
|
|
||||||
let stream = xmpp_stream.stream.into_inner();
|
let stream = xmpp_stream.stream.into_inner();
|
||||||
let connect = TlsConnector::builder().unwrap()
|
let connect = TlsConnector::builder().unwrap()
|
||||||
.build().unwrap()
|
.build().unwrap()
|
||||||
|
@ -96,7 +93,7 @@ impl<S: AsyncRead + AsyncWrite> Future for StartTlsClient<S> {
|
||||||
StartTlsClientState::StartingTls(mut connect) =>
|
StartTlsClientState::StartingTls(mut connect) =>
|
||||||
match connect.poll() {
|
match connect.poll() {
|
||||||
Ok(Async::Ready(tls_stream)) => {
|
Ok(Async::Ready(tls_stream)) => {
|
||||||
println!("Got a TLS stream!");
|
println!("TLS stream established");
|
||||||
let start = XMPPStream::from_stream(tls_stream, self.jid.clone());
|
let start = XMPPStream::from_stream(tls_stream, self.jid.clone());
|
||||||
let new_state = StartTlsClientState::Start(start);
|
let new_state = StartTlsClientState::Start(start);
|
||||||
retry = true;
|
retry = true;
|
||||||
|
|
|
@ -20,7 +20,6 @@ impl XMPPRoot {
|
||||||
fn new(root: xml::StartTag) -> Self {
|
fn new(root: xml::StartTag) -> Self {
|
||||||
let mut builder = xml::ElementBuilder::new();
|
let mut builder = xml::ElementBuilder::new();
|
||||||
let mut attributes = HashMap::new();
|
let mut attributes = HashMap::new();
|
||||||
println!("root attributes: {:?}", root.attributes);
|
|
||||||
for (name_ns, value) in root.attributes {
|
for (name_ns, value) in root.attributes {
|
||||||
match name_ns {
|
match name_ns {
|
||||||
(ref name, None) if name == "xmlns" =>
|
(ref name, None) if name == "xmlns" =>
|
||||||
|
@ -73,10 +72,13 @@ impl Decoder for XMPPCodec {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn decode(&mut self, buf: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> {
|
fn decode(&mut self, buf: &mut BytesMut) -> Result<Option<Self::Item>, Self::Error> {
|
||||||
println!("XMPPCodec.decode {:?}", buf.len());
|
|
||||||
match from_utf8(buf.take().as_ref()) {
|
match from_utf8(buf.take().as_ref()) {
|
||||||
Ok(s) =>
|
Ok(s) => {
|
||||||
self.parser.feed_str(s),
|
if s.len() > 0 {
|
||||||
|
println!("<< {}", s);
|
||||||
|
self.parser.feed_str(s);
|
||||||
|
}
|
||||||
|
},
|
||||||
Err(e) =>
|
Err(e) =>
|
||||||
return Err(Error::new(ErrorKind::InvalidInput, e)),
|
return Err(Error::new(ErrorKind::InvalidInput, e)),
|
||||||
}
|
}
|
||||||
|
@ -110,7 +112,7 @@ impl Decoder for XMPPCodec {
|
||||||
match root.handle_event(event) {
|
match root.handle_event(event) {
|
||||||
None => (),
|
None => (),
|
||||||
Some(Ok(stanza)) => {
|
Some(Ok(stanza)) => {
|
||||||
println!("stanza: {}", stanza);
|
// Emit the stanza
|
||||||
result = Some(Packet::Stanza(stanza));
|
result = Some(Packet::Stanza(stanza));
|
||||||
break
|
break
|
||||||
},
|
},
|
||||||
|
@ -151,13 +153,18 @@ impl Encoder for XMPPCodec {
|
||||||
}
|
}
|
||||||
write!(buf, ">\n").unwrap();
|
write!(buf, ">\n").unwrap();
|
||||||
|
|
||||||
println!("Encode start to {}", buf);
|
print!(">> {}", buf);
|
||||||
write!(dst, "{}", buf)
|
write!(dst, "{}", buf)
|
||||||
},
|
},
|
||||||
Packet::Stanza(stanza) =>
|
Packet::Stanza(stanza) => {
|
||||||
write!(dst, "{}", stanza),
|
println!(">> {}", stanza);
|
||||||
Packet::Text(text) =>
|
write!(dst, "{}", stanza)
|
||||||
write!(dst, "{}", xml::escape(&text)),
|
},
|
||||||
|
Packet::Text(text) => {
|
||||||
|
let escaped = xml::escape(&text);
|
||||||
|
println!(">> {}", escaped);
|
||||||
|
write!(dst, "{}", escaped)
|
||||||
|
},
|
||||||
// TODO: Implement all
|
// TODO: Implement all
|
||||||
_ => Ok(())
|
_ => Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue