Skip to content

Commit

Permalink
[build] Merge dadoum/master + my changes
Browse files Browse the repository at this point in the history
commit 9ee030bf8769ebd26869295ced62547ca95b3509
Author: naturecodevoid <[email protected]>
Date:   Sun Sep 17 08:53:27 2023 -0700

    Use SideStore rusty_libi, use fern instead of simplelog and env_logger for tests

commit 03f7c11
Author: Dadoum <[email protected]>
Date:   Sun Sep 17 01:03:47 2023 +0200

    [build] again...

commit a04a4a9
Author: Dadoum <[email protected]>
Date:   Sun Sep 17 00:58:42 2023 +0200

    [build] update rusty

commit 3f8382b
Author: Dadoum <[email protected]>
Date:   Sun Sep 17 00:40:49 2023 +0200

    [build] update rusty_libimobiledevice

commit 9b1b284
Author: Dadoum <[email protected]>
Date:   Sat Sep 16 22:53:20 2023 +0200

    [build] Trigger GH Action

commit 39c5b50
Author: Dadoum <[email protected]>
Date:   Sat Sep 16 17:39:49 2023 +0200

    Add a description to the staging error

Co-Authored-By: Dadoum <[email protected]>
  • Loading branch information
amsam0 and Dadoum committed Sep 17, 2023
1 parent 119941d commit 4e0543b
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 60 deletions.
9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ name = "minimuxer"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rusty_libimobiledevice = { version = "0.1", features = ["dynamic"], default-features = false }
rusty_libimobiledevice = { git = "https://github.com/SideStore/rusty_libimobiledevice", features = ["dynamic"], default-features = false }
plist_plus = { version = "0.2", features = ["dynamic"] }
plist = "1"
swift-bridge = { git = "https://github.com/naturecodevoid/swift-bridge" } # TODO: change to official repo once https://github.com/chinedufn/swift-bridge/pull/209 is merged

log = "*"
simplelog = "0.12"
fern = "0.6.2"

serde = "1.0"
serde_json = "1.0"
Expand All @@ -25,6 +23,9 @@ reqwest = { version = "0.11", features = ["blocking"] }
zip = "0.6"
chrono = "0.4"

[dev-dependencies]
env_logger = "0.10.0"

[build-dependencies]
swift-bridge-build = { git = "https://github.com/naturecodevoid/swift-bridge" } # TODO: change to official repo once https://github.com/chinedufn/swift-bridge/pull/209 is merged

Expand Down
7 changes: 4 additions & 3 deletions src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ pub fn install_ipa(bundle_id: String) -> Res<()> {
info!("Done!");
Ok(())
}
Err(e) => {
error!("Unable to install app: {:?}", e);
Err(Errors::InstallApp)
Err((err, description)) => {
// rusty_libimobiledevice will log an error that's better
// error!("Unable to install app: {:?}: {}", err, description);
Err(Errors::InstallApp(description))
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/jit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,4 @@ pub fn attach_debugger(pid: u32) -> Res<()> {
}
}
}

2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ mod ffi {
/* install */
CreateAfc,
RwAfc,
InstallApp,
InstallApp(String),
UninstallApp,

/* provision */
Expand Down
82 changes: 43 additions & 39 deletions src/muxer.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
// Jackson Coxson

use std::{
fs::File,
io::{Read, Write},
net::{IpAddr, Ipv4Addr, SocketAddrV4, TcpListener},
str::FromStr,
sync::atomic::{AtomicBool, Ordering},
};

use log::{error, info, trace, warn, LevelFilter};
use std::fs::File;
use std::io::{Read, Write};
use std::net::{IpAddr, Ipv4Addr, SocketAddrV4, TcpListener};
use std::str::FromStr;
use std::sync::atomic::{AtomicBool, Ordering};

use log::{error, info, trace, warn};
use plist::{Dictionary, Value};
use simplelog::{
ColorChoice, CombinedLogger, ConfigBuilder, TermLogger, TerminalMode, WriteLogger,
};

use crate::{heartbeat::start_beat, plist_to_bytes, raw_packet::RawPacket, Errors};

Expand Down Expand Up @@ -265,6 +260,9 @@ pub static STARTED: AtomicBool = AtomicBool::new(true); // minimuxer won't start
/// # Arguments
/// Pairing file contents as a string and log path as a string
pub fn start(pairing_file: String, log_path: String) -> crate::Res<()> {
use fern::Dispatch;
use log::LevelFilter;

let log_path = format!("{}/minimuxer.log", &log_path[7..]); // remove the file:// prefix

if STARTED.load(Ordering::Relaxed) {
Expand All @@ -274,34 +272,40 @@ pub fn start(pairing_file: String, log_path: String) -> crate::Res<()> {
}

// the logger failing to initialize isn't a problem since it will only fail if it has already been initialized
if CombinedLogger::init(vec![
TermLogger::new(
// Allow debug logging for terminal only
LevelFilter::max(),
// Allow logging from everywhere, to include rusty_libimobiledevice and any other useful debugging info
ConfigBuilder::new()
.set_target_level(LevelFilter::Error)
.add_filter_ignore_str("plist_plus") // plist_plus spams logs
if Dispatch::new()
.format(|out, message, record| {
out.finish(format_args!(
"{} [{}] {}: {}",
chrono::Local::now().format("%X"),
record.level(),
record.target(),
message
))
})
.chain(
// stdout
Dispatch::new()
.level(LevelFilter::Trace)
.level_for("plist_plus", LevelFilter::Off) // plist_plus spams logs
// crates that spam logs when signing
.add_filter_ignore_str("goblin")
.add_filter_ignore_str("reqwest")
.add_filter_ignore_str("want")
.add_filter_ignore_str("mio")
.add_filter_ignore_str("hyper")
.add_filter_ignore_str("tracing")
.build(),
TerminalMode::Mixed,
ColorChoice::Auto,
),
WriteLogger::new(
LevelFilter::Info,
ConfigBuilder::new()
.add_filter_allow("minimuxer".to_string())
.build(),
File::create(&log_path).unwrap(),
),
])
.is_ok()
.level_for("goblin", LevelFilter::Off)
.level_for("reqwest", LevelFilter::Off)
.level_for("want", LevelFilter::Off)
.level_for("mio", LevelFilter::Off)
.level_for("hyper", LevelFilter::Off)
.level_for("tracing", LevelFilter::Off) // maybe we shouldn't do this?
.chain(std::io::stdout()),
)
.chain(
// minimuxer.log
Dispatch::new()
.level(LevelFilter::Off)
.level_for("minimuxer", LevelFilter::Info)
.level_for("rusty_libimobiledevice", LevelFilter::Error)
.chain(File::create(&log_path).unwrap()),
)
.apply()
.is_ok()
{
info!("Logger initialized!!");
}
Expand Down
17 changes: 4 additions & 13 deletions src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use log::info;
use simplelog::{ColorChoice, ConfigBuilder, LevelFilter, TermLogger, TerminalMode};
use std::io::{self, Write};
use std::process::Command;
use std::sync::Once;
Expand All @@ -20,18 +19,10 @@ fn init() {
INIT.call_once(|| {
set_debug(true);

TermLogger::init(
// Allow debug logging
LevelFilter::max(),
// Allow logging from everywhere, to include rusty_libimobiledevice and any other useful debugging info
ConfigBuilder::new()
.add_filter_ignore_str("plist_plus") // plist_plus spams logs
.set_target_level(LevelFilter::Error)
.build(),
TerminalMode::Mixed,
ColorChoice::Auto,
)
.expect("logger failed to initialize");
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "trace")
}
env_logger::init();

info!("Successfully initialized tests");
println!();
Expand Down

0 comments on commit 4e0543b

Please sign in to comment.