Merge pull request #125 from chills42/no-more-rustc-serialize
refactor(transport-smtp): migrate away from rustc-serialize
This commit is contained in:
@@ -16,7 +16,8 @@ email = "^0.0"
|
|||||||
log = "^0.3"
|
log = "^0.3"
|
||||||
mime = "^0.2"
|
mime = "^0.2"
|
||||||
openssl = "^0.9"
|
openssl = "^0.9"
|
||||||
rustc-serialize = "^0.3"
|
base64 = "~0.5.0"
|
||||||
|
hex = "^0.2.0"
|
||||||
rust-crypto = "^0.2"
|
rust-crypto = "^0.2"
|
||||||
time = "^0.1"
|
time = "^0.1"
|
||||||
uuid = { version = "^0.5", features = ["v4"] }
|
uuid = { version = "^0.5", features = ["v4"] }
|
||||||
|
|||||||
@@ -277,7 +277,8 @@
|
|||||||
extern crate log;
|
extern crate log;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate mime;
|
extern crate mime;
|
||||||
extern crate rustc_serialize;
|
extern crate base64;
|
||||||
|
extern crate hex;
|
||||||
extern crate crypto;
|
extern crate crypto;
|
||||||
extern crate time;
|
extern crate time;
|
||||||
extern crate uuid;
|
extern crate uuid;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
use crypto::hmac::Hmac;
|
use crypto::hmac::Hmac;
|
||||||
use crypto::mac::Mac;
|
use crypto::mac::Mac;
|
||||||
use crypto::md5::Md5;
|
use crypto::md5::Md5;
|
||||||
use rustc_serialize::hex::ToHex;
|
use hex::ToHex;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fmt::{Display, Formatter};
|
use std::fmt::{Display, Formatter};
|
||||||
use transport::smtp::NUL;
|
use transport::smtp::NUL;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
use bufstream::BufStream;
|
use bufstream::BufStream;
|
||||||
use openssl::ssl::SslContext;
|
use openssl::ssl::SslContext;
|
||||||
|
|
||||||
use rustc_serialize::base64::{self, FromBase64, ToBase64};
|
use base64;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::{BufRead, Read, Write};
|
use std::io::{BufRead, Read, Write};
|
||||||
@@ -204,9 +204,7 @@ impl<S: Connector + Timeout + Write + Read + Debug> Client<S> {
|
|||||||
if mechanism.supports_initial_response() {
|
if mechanism.supports_initial_response() {
|
||||||
self.command(&format!("AUTH {} {}",
|
self.command(&format!("AUTH {} {}",
|
||||||
mechanism,
|
mechanism,
|
||||||
try!(mechanism.response(username, password, None))
|
base64::encode_config(try!(mechanism.response(username, password, None)).as_bytes(), base64::STANDARD)))
|
||||||
.as_bytes()
|
|
||||||
.to_base64(base64::STANDARD)))
|
|
||||||
} else {
|
} else {
|
||||||
let encoded_challenge = match try!(self.command(&format!("AUTH {}", mechanism)))
|
let encoded_challenge = match try!(self.command(&format!("AUTH {}", mechanism)))
|
||||||
.first_word() {
|
.first_word() {
|
||||||
@@ -216,7 +214,7 @@ impl<S: Connector + Timeout + Write + Read + Debug> Client<S> {
|
|||||||
|
|
||||||
debug!("auth encoded challenge: {}", encoded_challenge);
|
debug!("auth encoded challenge: {}", encoded_challenge);
|
||||||
|
|
||||||
let decoded_challenge = match encoded_challenge.from_base64() {
|
let decoded_challenge = match base64::decode(&encoded_challenge) {
|
||||||
Ok(challenge) => {
|
Ok(challenge) => {
|
||||||
match String::from_utf8(challenge) {
|
match String::from_utf8(challenge) {
|
||||||
Ok(value) => value,
|
Ok(value) => value,
|
||||||
@@ -231,11 +229,10 @@ impl<S: Connector + Timeout + Write + Read + Debug> Client<S> {
|
|||||||
let mut challenge_expected = 3;
|
let mut challenge_expected = 3;
|
||||||
|
|
||||||
while challenge_expected > 0 {
|
while challenge_expected > 0 {
|
||||||
let response = try!(self.command(&try!(mechanism.response(username,
|
let response = try!(self.command(&base64::encode_config(&try!(mechanism.response(username,
|
||||||
password,
|
password,
|
||||||
Some(&decoded_challenge)))
|
Some(&decoded_challenge)))
|
||||||
.as_bytes()
|
.as_bytes(), base64::STANDARD)));
|
||||||
.to_base64(base64::STANDARD)));
|
|
||||||
|
|
||||||
if !response.has_code(334) {
|
if !response.has_code(334) {
|
||||||
return Ok(response);
|
return Ok(response);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//! Error and result type for SMTP clients
|
//! Error and result type for SMTP clients
|
||||||
|
|
||||||
use self::Error::*;
|
use self::Error::*;
|
||||||
use rustc_serialize::base64::FromBase64Error;
|
use base64::DecodeError;
|
||||||
use std::error::Error as StdError;
|
use std::error::Error as StdError;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fmt::{Display, Formatter};
|
use std::fmt::{Display, Formatter};
|
||||||
@@ -23,7 +23,7 @@ pub enum Error {
|
|||||||
/// Error parsing a response
|
/// Error parsing a response
|
||||||
ResponseParsing(&'static str),
|
ResponseParsing(&'static str),
|
||||||
/// Error parsing a base64 string in response
|
/// Error parsing a base64 string in response
|
||||||
ChallengeParsing(FromBase64Error),
|
ChallengeParsing(DecodeError),
|
||||||
/// Error parsing UTF8in response
|
/// Error parsing UTF8in response
|
||||||
Utf8Parsing(FromUtf8Error),
|
Utf8Parsing(FromUtf8Error),
|
||||||
/// Internal client error
|
/// Internal client error
|
||||||
|
|||||||
Reference in New Issue
Block a user