add logging
This commit is contained in:
parent
bde8a37d3f
commit
8ded30e09e
4 changed files with 136 additions and 44 deletions
111
Cargo.lock
generated
111
Cargo.lock
generated
|
@ -30,12 +30,12 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
checksum = "9a7d5b8723950951411ee34d271d99dddcc2035a16ab25310ea2c8cfd4369652"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"termion",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
|
@ -503,6 +503,12 @@ dependencies = [
|
|||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "0.2.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76f033c7ad61445c5b347c7382dd1237847eb1bce590fe50365dcb33d546be73"
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
|
@ -590,7 +596,7 @@ version = "0.2.7"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8d96b2e1c8da3957d58100b09f102c6d9cfdfced01b7ec5a8974044bb09dbd4"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"lazy_static 1.4.0",
|
||||
"libc",
|
||||
"log",
|
||||
"openssl",
|
||||
|
@ -630,7 +636,7 @@ checksum = "5d51546d704f52ef14b3c962b5776e53d5b862e5790e40a350d366c209bd7f7a"
|
|||
dependencies = [
|
||||
"autocfg 0.1.7",
|
||||
"byteorder",
|
||||
"lazy_static",
|
||||
"lazy_static 1.4.0",
|
||||
"libm",
|
||||
"num-integer",
|
||||
"num-iter",
|
||||
|
@ -681,6 +687,12 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "numtoa"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b8f8bdf33df195859076e54ab11ee78a1b208382d3a26ec40d142ffc1ecc49ef"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.7.2"
|
||||
|
@ -911,6 +923,15 @@ dependencies = [
|
|||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_termios"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8440d8acb4fd3d277125b4bd01a6f38aee8d814b3b5fc09b3f2b825d37d3fe8f"
|
||||
dependencies = [
|
||||
"redox_syscall",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.4.5"
|
||||
|
@ -955,7 +976,7 @@ dependencies = [
|
|||
"hyper-tls",
|
||||
"ipnet",
|
||||
"js-sys",
|
||||
"lazy_static",
|
||||
"lazy_static 1.4.0",
|
||||
"log",
|
||||
"mime",
|
||||
"native-tls",
|
||||
|
@ -993,7 +1014,7 @@ checksum = "3648b669b10afeab18972c105e284a7b953a669b0be3514c27f9b17acab2f9cd"
|
|||
dependencies = [
|
||||
"byteorder",
|
||||
"digest",
|
||||
"lazy_static",
|
||||
"lazy_static 1.4.0",
|
||||
"num-bigint-dig",
|
||||
"num-integer",
|
||||
"num-iter",
|
||||
|
@ -1028,7 +1049,7 @@ version = "0.1.19"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"lazy_static 1.4.0",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
|
@ -1187,6 +1208,19 @@ dependencies = [
|
|||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stderrlog"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32e5ee9b90a5452c570a0b0ac1c99ae9498db7e56e33d74366de7f2a7add7f25"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"chrono",
|
||||
"log",
|
||||
"termcolor",
|
||||
"thread_local",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "stdweb"
|
||||
version = "0.4.20"
|
||||
|
@ -1243,6 +1277,7 @@ dependencies = [
|
|||
"base64",
|
||||
"clap",
|
||||
"hmac-sha1",
|
||||
"log",
|
||||
"rand 0.7.3",
|
||||
"reqwest",
|
||||
"rpassword",
|
||||
|
@ -1250,6 +1285,7 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_json",
|
||||
"standback",
|
||||
"stderrlog",
|
||||
"text_io",
|
||||
]
|
||||
|
||||
|
@ -1302,6 +1338,27 @@ dependencies = [
|
|||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termion"
|
||||
version = "1.5.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "077185e2eac69c3f8379a4298e1e07cd36beb962290d4a51199acf0fdc10607e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"numtoa",
|
||||
"redox_syscall",
|
||||
"redox_termios",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "text_io"
|
||||
version = "0.1.8"
|
||||
|
@ -1337,6 +1394,16 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thread_local"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1697c4b57aeeb7a536b647165a2825faddffb1d3bad386d507709bd51a90bb14"
|
||||
dependencies = [
|
||||
"lazy_static 0.2.11",
|
||||
"unreachable",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.1.43"
|
||||
|
@ -1462,7 +1529,7 @@ version = "0.1.17"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f50de3927f93d202783f4513cda820ab47ef17f624b03c096e86ef00c67e6b5f"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"lazy_static 1.4.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1507,6 +1574,15 @@ version = "0.2.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||
|
||||
[[package]]
|
||||
name = "unreachable"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
|
||||
dependencies = [
|
||||
"void",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "2.2.1"
|
||||
|
@ -1537,6 +1613,12 @@ version = "0.9.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe"
|
||||
|
||||
[[package]]
|
||||
name = "void"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
|
||||
|
||||
[[package]]
|
||||
name = "want"
|
||||
version = "0.3.0"
|
||||
|
@ -1578,7 +1660,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "046ceba58ff062da072c7cb4ba5b22a37f00a302483f7e2a6cdc18fedbdc1fd3"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"lazy_static",
|
||||
"lazy_static 1.4.0",
|
||||
"log",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -1653,6 +1735,15 @@ version = "0.4.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
|
|
|
@ -18,3 +18,5 @@ rsa = "0.3"
|
|||
rand = "0.7.3" # rsa is not compatible with rand 0.8: https://github.com/RustCrypto/RSA/issues/81
|
||||
standback = "0.2.17" # required to fix a compilation error on a transient dependency
|
||||
clap = "2.33.3"
|
||||
log = "0.4.14"
|
||||
stderrlog = "0.4"
|
||||
|
|
|
@ -4,6 +4,7 @@ use std::path::Path;
|
|||
use serde::{Serialize, Deserialize};
|
||||
use std::error::Error;
|
||||
use steamguard_cli::SteamGuardAccount;
|
||||
use log::*;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct Manifest {
|
||||
|
@ -33,6 +34,7 @@ pub struct ManifestEntry {
|
|||
|
||||
impl Manifest {
|
||||
pub fn load(path: &Path) -> Result<Manifest, Box<dyn Error>> {
|
||||
debug!("loading manifest: {:?}", &path);
|
||||
match File::open(path) {
|
||||
Ok(file) => {
|
||||
let reader = BufReader::new(file);
|
||||
|
@ -56,6 +58,7 @@ impl Manifest {
|
|||
pub fn load_accounts(&mut self) {
|
||||
for entry in &self.entries {
|
||||
let path = Path::new(&self.folder).join(&entry.filename);
|
||||
debug!("loading account: {:?}", path);
|
||||
match File::open(path) {
|
||||
Ok(f) => {
|
||||
let reader = BufReader::new(f);
|
||||
|
@ -65,12 +68,12 @@ impl Manifest {
|
|||
self.accounts.push(account);
|
||||
}
|
||||
Err(e) => {
|
||||
panic!("invalid json")
|
||||
error!("invalid json: {}", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
panic!(e)
|
||||
error!("unable to open account: {}", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
56
src/main.rs
56
src/main.rs
|
@ -5,6 +5,7 @@ use ::std::*;
|
|||
use text_io::read;
|
||||
use std::path::Path;
|
||||
use clap::{App, Arg, crate_version};
|
||||
use log::*;
|
||||
|
||||
mod steamapi;
|
||||
mod accountmanager;
|
||||
|
@ -40,6 +41,13 @@ fn main() {
|
|||
.short("p")
|
||||
.help("Specify your encryption passkey.")
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("verbosity")
|
||||
.short("v")
|
||||
.help("Log what is going on verbosely.")
|
||||
.takes_value(false)
|
||||
.multiple(true)
|
||||
)
|
||||
.subcommand(
|
||||
App::new("trade")
|
||||
.about("Interactive interface for trade confirmations")
|
||||
|
@ -52,41 +60,29 @@ fn main() {
|
|||
)
|
||||
.get_matches();
|
||||
|
||||
println!("Hello, world!");
|
||||
|
||||
// let server_time = steamapi::get_server_time();
|
||||
// println!("server time: {}", server_time);
|
||||
let verbosity = matches.occurrences_of("verbosity") as usize + 2;
|
||||
stderrlog::new()
|
||||
.verbosity(verbosity)
|
||||
.module(module_path!()).init().unwrap();
|
||||
|
||||
// let mut account = SteamGuardAccount::new();
|
||||
// account.shared_secret = parse_shared_secret(String::from("K5I0Fmm+sN0yF41vIslTVm+0nPE="));
|
||||
let path = Path::new(matches.value_of("mafiles-path").unwrap()).join("manifest.json");
|
||||
let mut manifest: accountmanager::Manifest;
|
||||
match accountmanager::Manifest::load(path.as_path()) {
|
||||
Ok(m) => {
|
||||
manifest = m;
|
||||
}
|
||||
Err(e) => {
|
||||
error!("Could not load manifest: {}", e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// let code = account.generate_code(server_time);
|
||||
// println!("{}", code);
|
||||
|
||||
// print!("Username: ");
|
||||
// let _ = std::io::stdout().flush();
|
||||
// let username: String = read!("{}\n");
|
||||
// let password = rpassword::prompt_password_stdout("Password: ").unwrap();
|
||||
// // println!("{}:{}", username, password);
|
||||
// let login = steamapi::UserLogin::new(username, password);
|
||||
// let result = login.login();
|
||||
// println!("result: {:?}", result);
|
||||
|
||||
let path = Path::new("test_maFiles/manifest.json");
|
||||
let manifest = accountmanager::Manifest::load(path);
|
||||
println!("{:?}", manifest);
|
||||
match manifest {
|
||||
Ok(mut m) => {
|
||||
m.load_accounts();
|
||||
for account in m.accounts {
|
||||
println!("{:?}", account);
|
||||
manifest.load_accounts();
|
||||
for account in manifest.accounts {
|
||||
trace!("{:?}", account);
|
||||
let server_time = steamapi::get_server_time();
|
||||
let code = account.generate_code(server_time);
|
||||
println!("{}", code);
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
println!("{}", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue