diff --git a/Cargo.lock b/Cargo.lock index 3de3a15..e4fbd88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,15 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + [[package]] name = "adler" version = "1.0.2" @@ -71,6 +80,21 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" +[[package]] +name = "backtrace" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] + [[package]] name = "base64" version = "0.21.7" @@ -147,6 +171,33 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" +[[package]] +name = "color-eyre" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55146f5e46f237f7423d74111267d4597b59b0dad0ffaf7303bce9945d843ad5" +dependencies = [ + "backtrace", + "color-spantrace", + "eyre", + "indenter", + "once_cell", + "owo-colors", + "tracing-error", +] + +[[package]] +name = "color-spantrace" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2" +dependencies = [ + "once_cell", + "owo-colors", + "tracing-core", + "tracing-error", +] + [[package]] name = "colorchoice" version = "1.0.0" @@ -192,6 +243,16 @@ dependencies = [ "arrayvec", ] +[[package]] +name = "eyre" +version = "0.6.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" +dependencies = [ + "indenter", + "once_cell", +] + [[package]] name = "flate2" version = "1.0.28" @@ -222,6 +283,12 @@ dependencies = [ "wasi", ] +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + [[package]] name = "heck" version = "0.4.1" @@ -238,6 +305,12 @@ dependencies = [ "unicode-normalization", ] +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + [[package]] name = "itoa" version = "1.0.10" @@ -317,6 +390,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "object" +version = "0.32.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6a622008b6e321afc04970976f62ee297fdbaa6f95318ca343e3eebb9648441" +dependencies = [ + "memchr", +] + [[package]] name = "once_cell" version = "1.19.0" @@ -329,6 +411,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" +[[package]] +name = "owo-colors" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" + [[package]] name = "pcap" version = "1.2.0" @@ -481,6 +569,7 @@ version = "0.1.0" dependencies = [ "base64 0.22.0", "clap", + "color-eyre", "pcap", "reliquary", "serde", @@ -515,6 +604,12 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + [[package]] name = "rustls" version = "0.22.2" @@ -704,6 +799,16 @@ dependencies = [ "valuable", ] +[[package]] +name = "tracing-error" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e" +dependencies = [ + "tracing", + "tracing-subscriber", +] + [[package]] name = "tracing-log" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index 5f44738..b65b32b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ license = "MIT" [dependencies] base64 = "0.22.0" clap = { version = "4.5.2", features = ["derive"] } +color-eyre = "0.6.3" pcap = "1.2.0" serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.114" @@ -18,4 +19,4 @@ ureq = { version = "2.9.6", features = ["json"] } [dependencies.reliquary] git = "https://github.com/IceDynamix/reliquary" -tag = "v0.1.0" \ No newline at end of file +tag = "v0.1.0" diff --git a/src/main.rs b/src/main.rs index b48e339..8d07be9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,6 +36,8 @@ fn main() { ) .init(); + color_eyre::install().unwrap(); + let args = Args::parse(); debug!(?args); @@ -53,6 +55,9 @@ fn main() { serde_json::to_writer_pretty(&file, &export).unwrap(); info!("wrote output to {}", &args.output.display()); } + + info!("press enter to close"); + std::io::stdin().read_line(&mut String::new()).unwrap(); } #[instrument(skip_all)] @@ -72,8 +77,8 @@ fn file_capture(args: &Args, mut exporter: E, mut sniffer: GameSniffer) -> Op if commands.is_empty() { invalid += 1; - if invalid >= 10 { - error!("received 10 packets that could not be segmented"); + if invalid >= 50 { + error!("received 50 packets that could not be segmented"); warn!("you probably started capturing when you were already in-game"); warn!("the capture needs to start on the main menu screen before hyperdrive"); return None; @@ -115,6 +120,7 @@ fn live_capture(args: &Args, mut exporter: E, mut sniffer: GameSniffer) -> Op } let mut invalid = 0; + let mut warning_sent = false; info!("instructions: go to main menu screen and go into train hyperdrive"); info!("listening with a timeout of {} seconds...", args.timeout); @@ -126,14 +132,14 @@ fn live_capture(args: &Args, mut exporter: E, mut sniffer: GameSniffer) -> Op if commands.is_empty() { invalid += 1; - if invalid >= 10 { - error!("received a large number of packets that could not be segmented"); + if invalid >= 25 && !warning_sent { + error!("received a large number of packets that could not be parsed"); warn!("you probably started capturing when you were already in-game"); - warn!("please go to the main menu screen and re-enter the game"); - invalid = -50; + warn!("please log out and log back in"); + warning_sent = true; } } else { - invalid -= 1; + invalid -= 10; for command in commands { exporter.read_command(command);