From 931269dd980e880558da0cf994457488127d1998 Mon Sep 17 00:00:00 2001 From: "Y. T. Chung" Date: Sat, 18 Feb 2017 01:03:55 +0800 Subject: [PATCH] upgrade base64 --- Cargo.lock | 6 +++--- Cargo.toml | 4 ++-- src/bin/ssurl.rs | 7 +++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 195cbb03..9c22e620 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,7 +3,7 @@ name = "shadowsocks-rust" version = "1.2.0" dependencies = [ "argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)", - "base64 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "base64 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "clap 2.20.3 (registry+https://github.com/rust-lang/crates.io-index)", "env_logger 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -54,7 +54,7 @@ dependencies = [ [[package]] name = "base64" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -649,7 +649,7 @@ dependencies = [ "checksum aho-corasick 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "0638fd549427caa90c499814196d1b9e3725eb4d15d7339d6de073a680ed0ca2" "checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6" "checksum argon2rs 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f67b0b6a86dae6e67ff4ca2b6201396074996379fba2b92ff649126f37cb392" -"checksum base64 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d156a04ec694d726e92ea3c13e4a62949b4f0488a9344f04341d679ec6b127b" +"checksum base64 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "065a0ce220ab84d0b6d5ae3e7bb77232209519c366f51f946fe28c19e84989d0" "checksum bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" "checksum blake2-rfc 0.2.17 (registry+https://github.com/rust-lang/crates.io-index)" = "0c6a476f32fef3402f1161f89d0d39822809627754a126f8441ff2a9d45e2d59" "checksum byteorder 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c40977b0ee6b9885c9013cd41d9feffdd22deb3bb4dc3a71d901cc7a77de18c8" diff --git a/Cargo.toml b/Cargo.toml index cce98824..c9579e67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -47,8 +47,8 @@ net2 = "0.2" num_cpus = "1.1" lazy_static = "0.2" serde_json = "0.9" -base64 = "0.3" +base64 = "0.4" [dependencies.argon2rs] version = "0.2" -optional = true \ No newline at end of file +optional = true diff --git a/src/bin/ssurl.rs b/src/bin/ssurl.rs index 6ef96fae..ab8ad421 100644 --- a/src/bin/ssurl.rs +++ b/src/bin/ssurl.rs @@ -8,7 +8,7 @@ use clap::{App, Arg}; use qrcode::QrCode; -use base64::Base64Mode; +use base64::{encode_config, decode_config, URL_SAFE_NO_PAD}; use shadowsocks::VERSION; use shadowsocks::config::{Config, ConfigType, ServerConfig, ServerAddr}; @@ -21,8 +21,7 @@ fn encode_url(svr: &ServerConfig) -> String { svr.method().to_string(), svr.password(), svr.addr()); - format!("ss://{}", - base64::encode_mode(url.as_bytes(), Base64Mode::UrlSafe)) + format!("ss://{}", encode_config(url.as_bytes(), URL_SAFE_NO_PAD)) } fn print_qrcode(encoded: &str) { @@ -68,7 +67,7 @@ fn decode(encoded: &str, need_qrcode: bool) { panic!("Malformed input: {:?}", encoded); } - let decoded = base64::decode_mode(&encoded[5..], Base64Mode::UrlSafe).unwrap(); + let decoded = decode_config(&encoded[5..], URL_SAFE_NO_PAD).unwrap(); let decoded = String::from_utf8(decoded).unwrap(); let mut sp1 = decoded.split('@');