Add STARTTLS keyword to the library

This commit is contained in:
Alexis Mousset
2014-11-06 10:31:48 +01:00
parent 134a907bab
commit 4fa54e2908
2 changed files with 9 additions and 0 deletions

View File

@@ -24,6 +24,8 @@ use common::SP;
pub enum Command {
/// A fake command to represent the connection step
Connect,
/// Start a TLS tunnel
StartTls,
/// Extended Hello command
ExtendedHello(String),
/// Hello command
@@ -51,6 +53,7 @@ pub enum Command {
impl Show for Command {
fn fmt(&self, f: &mut Formatter) -> Result {
f.write( match *self {
StartTls => "STARTTLS".to_string(),
Connect => "CONNECT".to_string(),
ExtendedHello(ref my_hostname) =>
format!("EHLO {}", my_hostname.clone()),

View File

@@ -28,6 +28,10 @@ pub enum Extension {
///
/// RFC 6531 : https://tools.ietf.org/html/rfc6531
SmtpUtfEight,
/// STARTTLS keyword
///
/// RFC 2487 : http://tools.ietf.org/html/rfc2487
StartTls,
/// SIZE keyword
///
/// RFC 1427 : https://tools.ietf.org/html/rfc1427
@@ -40,6 +44,7 @@ impl Show for Extension {
match self {
&EightBitMime => "8BITMIME".to_string(),
&SmtpUtfEight => "SMTPUTF8".to_string(),
&StartTls => "STARTTLS".to_string(),
&Size(ref size) => format!("SIZE={}", size)
}.as_bytes()
)
@@ -54,6 +59,7 @@ impl FromStr for Extension {
1 => match splitted[0] {
"8BITMIME" => Some(EightBitMime),
"SMTPUTF8" => Some(SmtpUtfEight),
"STARTTLS" => Some(StartTls),
_ => None
},
2 => match (splitted[0], from_str::<uint>(splitted[1])) {